mach-ja76pf.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * jjPlus JA76PF board support
  3. */
  4. #include <linux/i2c.h>
  5. #include <linux/i2c-gpio.h>
  6. #include <linux/platform_device.h>
  7. #include <asm/mach-ath79/ath79.h>
  8. #include "dev-eth.h"
  9. #include "dev-gpio-buttons.h"
  10. #include "dev-leds-gpio.h"
  11. #include "dev-m25p80.h"
  12. #include "dev-usb.h"
  13. #include "machtypes.h"
  14. #include "pci.h"
  15. #define JA76PF_KEYS_POLL_INTERVAL 20 /* msecs */
  16. #define JA76PF_KEYS_DEBOUNCE_INTERVAL (3 * JA76PF_KEYS_POLL_INTERVAL)
  17. #define JA76PF_GPIO_I2C_SCL 0
  18. #define JA76PF_GPIO_I2C_SDA 1
  19. #define JA76PF_GPIO_LED_1 5
  20. #define JA76PF_GPIO_LED_2 4
  21. #define JA76PF_GPIO_LED_3 3
  22. #define JA76PF_GPIO_BTN_RESET 11
  23. static struct gpio_led ja76pf_leds_gpio[] __initdata = {
  24. {
  25. .name = "jjplus:green:led1",
  26. .gpio = JA76PF_GPIO_LED_1,
  27. .active_low = 1,
  28. }, {
  29. .name = "jjplus:green:led2",
  30. .gpio = JA76PF_GPIO_LED_2,
  31. .active_low = 1,
  32. }, {
  33. .name = "jjplus:green:led3",
  34. .gpio = JA76PF_GPIO_LED_3,
  35. .active_low = 1,
  36. }
  37. };
  38. static struct gpio_keys_button ja76pf_gpio_keys[] __initdata = {
  39. {
  40. .desc = "reset",
  41. .type = EV_KEY,
  42. .code = KEY_RESTART,
  43. .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
  44. .gpio = JA76PF_GPIO_BTN_RESET,
  45. .active_low = 1,
  46. }
  47. };
  48. static struct i2c_gpio_platform_data ja76pf_i2c_gpio_data = {
  49. .sda_pin = JA76PF_GPIO_I2C_SDA,
  50. .scl_pin = JA76PF_GPIO_I2C_SCL,
  51. };
  52. static struct platform_device ja76pf_i2c_gpio_device = {
  53. .name = "i2c-gpio",
  54. .id = 0,
  55. .dev = {
  56. .platform_data = &ja76pf_i2c_gpio_data,
  57. }
  58. };
  59. static const char *ja76pf_part_probes[] = {
  60. "RedBoot",
  61. NULL,
  62. };
  63. static struct flash_platform_data ja76pf_flash_data = {
  64. .part_probes = ja76pf_part_probes,
  65. };
  66. #define JA76PF_WAN_PHYMASK (1 << 4)
  67. #define JA76PF_LAN_PHYMASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 < 3))
  68. #define JA76PF_MDIO_PHYMASK (JA76PF_LAN_PHYMASK | JA76PF_WAN_PHYMASK)
  69. static void __init ja76pf_init(void)
  70. {
  71. ath79_register_m25p80(&ja76pf_flash_data);
  72. ath79_register_mdio(0, ~JA76PF_MDIO_PHYMASK);
  73. ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  74. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  75. ath79_eth0_data.phy_mask = JA76PF_LAN_PHYMASK;
  76. ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  77. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  78. ath79_eth1_data.phy_mask = JA76PF_WAN_PHYMASK;
  79. ath79_eth1_data.speed = SPEED_1000;
  80. ath79_eth1_data.duplex = DUPLEX_FULL;
  81. ath79_register_eth(0);
  82. ath79_register_eth(1);
  83. platform_device_register(&ja76pf_i2c_gpio_device);
  84. ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf_leds_gpio),
  85. ja76pf_leds_gpio);
  86. ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
  87. ARRAY_SIZE(ja76pf_gpio_keys),
  88. ja76pf_gpio_keys);
  89. ath79_register_usb();
  90. ath79_register_pci();
  91. }
  92. MIPS_MACHINE(ATH79_MACH_JA76PF, "JA76PF", "jjPlus JA76PF", ja76pf_init);
  93. #define JA76PF2_GPIO_LED_D2 5
  94. #define JA76PF2_GPIO_LED_D3 4
  95. #define JA76PF2_GPIO_LED_D4 3
  96. #define JA76PF2_GPIO_BTN_RESET 7
  97. #define JA76PF2_GPIO_BTN_WPS 8
  98. static struct gpio_led ja76pf2_leds_gpio[] __initdata = {
  99. {
  100. .name = "jjplus:green:led1",
  101. .gpio = JA76PF2_GPIO_LED_D2,
  102. .active_low = 1,
  103. }, {
  104. .name = "jjplus:green:led2",
  105. .gpio = JA76PF2_GPIO_LED_D3,
  106. .active_low = 0,
  107. }, {
  108. .name = "jjplus:green:led3",
  109. .gpio = JA76PF2_GPIO_LED_D4,
  110. .active_low = 0,
  111. }
  112. };
  113. static struct gpio_keys_button ja76pf2_gpio_keys[] __initdata = {
  114. {
  115. .desc = "reset",
  116. .type = EV_KEY,
  117. .code = KEY_RESTART,
  118. .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
  119. .gpio = JA76PF2_GPIO_BTN_RESET,
  120. .active_low = 1,
  121. },
  122. {
  123. .desc = "wps",
  124. .type = EV_KEY,
  125. .code = KEY_WPS_BUTTON,
  126. .debounce_interval = JA76PF_KEYS_DEBOUNCE_INTERVAL,
  127. .gpio = JA76PF2_GPIO_BTN_WPS,
  128. .active_low = 1,
  129. },
  130. };
  131. #define JA76PF2_LAN_PHYMASK BIT(0)
  132. #define JA76PF2_WAN_PHYMASK BIT(4)
  133. #define JA76PF2_MDIO_PHYMASK (JA76PF2_LAN_PHYMASK | JA76PF2_WAN_PHYMASK)
  134. static void __init ja76pf2_init(void)
  135. {
  136. ath79_register_m25p80(&ja76pf_flash_data);
  137. ath79_register_mdio(0, ~JA76PF2_MDIO_PHYMASK);
  138. /* MAC0 is connected to the CPU port of the AR8316 switch */
  139. ath79_init_mac(ath79_eth0_data.mac_addr, ath79_mac_base, 0);
  140. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  141. ath79_eth0_data.phy_mask = BIT(0);
  142. /* MAC1 is connected to the PHY4 of the AR8316 switch */
  143. ath79_init_mac(ath79_eth1_data.mac_addr, ath79_mac_base, 1);
  144. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  145. ath79_eth1_data.phy_mask = BIT(4);
  146. ath79_register_eth(0);
  147. ath79_register_eth(1);
  148. ath79_register_leds_gpio(-1, ARRAY_SIZE(ja76pf2_leds_gpio),
  149. ja76pf2_leds_gpio);
  150. ath79_register_gpio_keys_polled(-1, JA76PF_KEYS_POLL_INTERVAL,
  151. ARRAY_SIZE(ja76pf2_gpio_keys),
  152. ja76pf2_gpio_keys);
  153. ath79_register_pci();
  154. }
  155. MIPS_MACHINE(ATH79_MACH_JA76PF2, "JA76PF2", "jjPlus JA76PF2", ja76pf2_init);