1
0

609-MIPS-ath79-ap136-fixes.patch 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. --- a/arch/mips/ath79/mach-ap136.c
  2. +++ b/arch/mips/ath79/mach-ap136.c
  3. @@ -18,23 +18,29 @@
  4. *
  5. */
  6. -#include <linux/pci.h>
  7. -#include <linux/ath9k_platform.h>
  8. +#include <linux/platform_device.h>
  9. +#include <linux/ar8216_platform.h>
  10. -#include "machtypes.h"
  11. +#include <asm/mach-ath79/ar71xx_regs.h>
  12. +
  13. +#include "common.h"
  14. +#include "pci.h"
  15. +#include "dev-ap9x-pci.h"
  16. #include "dev-gpio-buttons.h"
  17. +#include "dev-eth.h"
  18. #include "dev-leds-gpio.h"
  19. -#include "dev-spi.h"
  20. +#include "dev-m25p80.h"
  21. +#include "dev-nfc.h"
  22. #include "dev-usb.h"
  23. #include "dev-wmac.h"
  24. -#include "pci.h"
  25. +#include "machtypes.h"
  26. -#define AP136_GPIO_LED_STATUS_RED 14
  27. -#define AP136_GPIO_LED_STATUS_GREEN 19
  28. #define AP136_GPIO_LED_USB 4
  29. -#define AP136_GPIO_LED_WLAN_2G 13
  30. #define AP136_GPIO_LED_WLAN_5G 12
  31. +#define AP136_GPIO_LED_WLAN_2G 13
  32. +#define AP136_GPIO_LED_STATUS_RED 14
  33. #define AP136_GPIO_LED_WPS_RED 15
  34. +#define AP136_GPIO_LED_STATUS_GREEN 19
  35. #define AP136_GPIO_LED_WPS_GREEN 20
  36. #define AP136_GPIO_BTN_WPS 16
  37. @@ -43,37 +49,39 @@
  38. #define AP136_KEYS_POLL_INTERVAL 20 /* msecs */
  39. #define AP136_KEYS_DEBOUNCE_INTERVAL (3 * AP136_KEYS_POLL_INTERVAL)
  40. -#define AP136_WMAC_CALDATA_OFFSET 0x1000
  41. -#define AP136_PCIE_CALDATA_OFFSET 0x5000
  42. +#define AP136_MAC0_OFFSET 0
  43. +#define AP136_MAC1_OFFSET 6
  44. +#define AP136_WMAC_CALDATA_OFFSET 0x1000
  45. +#define AP136_PCIE_CALDATA_OFFSET 0x5000
  46. static struct gpio_led ap136_leds_gpio[] __initdata = {
  47. {
  48. - .name = "qca:green:status",
  49. + .name = "ap136:green:status",
  50. .gpio = AP136_GPIO_LED_STATUS_GREEN,
  51. .active_low = 1,
  52. },
  53. {
  54. - .name = "qca:red:status",
  55. + .name = "ap136:red:status",
  56. .gpio = AP136_GPIO_LED_STATUS_RED,
  57. .active_low = 1,
  58. },
  59. {
  60. - .name = "qca:green:wps",
  61. + .name = "ap136:green:wps",
  62. .gpio = AP136_GPIO_LED_WPS_GREEN,
  63. .active_low = 1,
  64. },
  65. {
  66. - .name = "qca:red:wps",
  67. + .name = "ap136:red:wps",
  68. .gpio = AP136_GPIO_LED_WPS_RED,
  69. .active_low = 1,
  70. },
  71. {
  72. - .name = "qca:red:wlan-2g",
  73. + .name = "ap136:red:wlan-2g",
  74. .gpio = AP136_GPIO_LED_WLAN_2G,
  75. .active_low = 1,
  76. },
  77. {
  78. - .name = "qca:red:usb",
  79. + .name = "ap136:red:usb",
  80. .gpio = AP136_GPIO_LED_USB,
  81. .active_low = 1,
  82. }
  83. @@ -98,59 +106,151 @@ static struct gpio_keys_button ap136_gpi
  84. },
  85. };
  86. -static struct spi_board_info ap136_spi_info[] = {
  87. - {
  88. - .bus_num = 0,
  89. - .chip_select = 0,
  90. - .max_speed_hz = 25000000,
  91. - .modalias = "mx25l6405d",
  92. - }
  93. +static struct ar8327_pad_cfg ap136_ar8327_pad0_cfg;
  94. +static struct ar8327_pad_cfg ap136_ar8327_pad6_cfg;
  95. +
  96. +static struct ar8327_platform_data ap136_ar8327_data = {
  97. + .pad0_cfg = &ap136_ar8327_pad0_cfg,
  98. + .pad6_cfg = &ap136_ar8327_pad6_cfg,
  99. + .port0_cfg = {
  100. + .force_link = 1,
  101. + .speed = AR8327_PORT_SPEED_1000,
  102. + .duplex = 1,
  103. + .txpause = 1,
  104. + .rxpause = 1,
  105. + },
  106. + .port6_cfg = {
  107. + .force_link = 1,
  108. + .speed = AR8327_PORT_SPEED_1000,
  109. + .duplex = 1,
  110. + .txpause = 1,
  111. + .rxpause = 1,
  112. + },
  113. };
  114. -static struct ath79_spi_platform_data ap136_spi_data = {
  115. - .bus_num = 0,
  116. - .num_chipselect = 1,
  117. +static struct mdio_board_info ap136_mdio0_info[] = {
  118. + {
  119. + .bus_id = "ag71xx-mdio.0",
  120. + .mdio_addr = 0,
  121. + .platform_data = &ap136_ar8327_data,
  122. + },
  123. };
  124. -#ifdef CONFIG_PCI
  125. -static struct ath9k_platform_data ap136_ath9k_data;
  126. +static void __init ap136_common_setup(void)
  127. +{
  128. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  129. +
  130. + ath79_register_m25p80(NULL);
  131. +
  132. + ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
  133. + ap136_leds_gpio);
  134. + ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
  135. + ARRAY_SIZE(ap136_gpio_keys),
  136. + ap136_gpio_keys);
  137. +
  138. + ath79_register_usb();
  139. + ath79_register_nfc();
  140. +
  141. + ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET, NULL);
  142. +
  143. + ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  144. -static int ap136_pci_plat_dev_init(struct pci_dev *dev)
  145. + ath79_register_mdio(0, 0x0);
  146. + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP136_MAC0_OFFSET, 0);
  147. +
  148. + mdiobus_register_board_info(ap136_mdio0_info,
  149. + ARRAY_SIZE(ap136_mdio0_info));
  150. +
  151. + /* GMAC0 is connected to the RMGII interface */
  152. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  153. + ath79_eth0_data.phy_mask = BIT(0);
  154. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  155. +
  156. + ath79_register_eth(0);
  157. +
  158. + /* GMAC1 is connected tot eh SGMII interface */
  159. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  160. + ath79_eth1_data.speed = SPEED_1000;
  161. + ath79_eth1_data.duplex = DUPLEX_FULL;
  162. +
  163. + ath79_register_eth(1);
  164. +}
  165. +
  166. +static void __init ap136_010_setup(void)
  167. {
  168. - if (dev->bus->number == 1 && (PCI_SLOT(dev->devfn)) == 0)
  169. - dev->dev.platform_data = &ap136_ath9k_data;
  170. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  171. - return 0;
  172. + /* GMAC0 of the AR8327 switch is connected to GMAC0 via RGMII */
  173. + ap136_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII;
  174. + ap136_ar8327_pad0_cfg.txclk_delay_en = true;
  175. + ap136_ar8327_pad0_cfg.rxclk_delay_en = true;
  176. + ap136_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  177. + ap136_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  178. +
  179. + /* GMAC6 of the AR8327 switch is connected to GMAC1 via SGMII */
  180. + ap136_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII;
  181. + ap136_ar8327_pad6_cfg.rxclk_delay_en = true;
  182. + ap136_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0;
  183. +
  184. + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  185. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  186. +
  187. + ap136_common_setup();
  188. + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
  189. }
  190. -static void __init ap136_pci_init(u8 *eeprom)
  191. +MIPS_MACHINE(ATH79_MACH_AP136_010, "AP136-010",
  192. + "Atheros AP136-010 reference board",
  193. + ap136_010_setup);
  194. +
  195. +static void __init ap136_020_common_setup(void)
  196. {
  197. - memcpy(ap136_ath9k_data.eeprom_data, eeprom,
  198. - sizeof(ap136_ath9k_data.eeprom_data));
  199. + /* GMAC0 of the AR8327 switch is connected to GMAC1 via SGMII */
  200. + ap136_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_SGMII;
  201. + ap136_ar8327_pad0_cfg.sgmii_delay_en = true;
  202. +
  203. + /* GMAC6 of the AR8327 switch is connected to GMAC0 via RGMII */
  204. + ap136_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_RGMII;
  205. + ap136_ar8327_pad6_cfg.txclk_delay_en = true;
  206. + ap136_ar8327_pad6_cfg.rxclk_delay_en = true;
  207. + ap136_ar8327_pad6_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1;
  208. + ap136_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2;
  209. - ath79_pci_set_plat_dev_init(ap136_pci_plat_dev_init);
  210. - ath79_register_pci();
  211. + ath79_eth0_pll_data.pll_1000 = 0x56000000;
  212. + ath79_eth1_pll_data.pll_1000 = 0x03000101;
  213. +
  214. + ap136_common_setup();
  215. }
  216. -#else
  217. -static inline void ap136_pci_init(u8 *eeprom) {}
  218. -#endif /* CONFIG_PCI */
  219. -static void __init ap136_setup(void)
  220. +static void __init ap136_020_setup(void)
  221. {
  222. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  223. - ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
  224. - ap136_leds_gpio);
  225. - ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
  226. - ARRAY_SIZE(ap136_gpio_keys),
  227. - ap136_gpio_keys);
  228. - ath79_register_spi(&ap136_spi_data, ap136_spi_info,
  229. - ARRAY_SIZE(ap136_spi_info));
  230. - ath79_register_usb();
  231. - ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET);
  232. - ap136_pci_init(art + AP136_PCIE_CALDATA_OFFSET);
  233. + ap136_020_common_setup();
  234. + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
  235. }
  236. -MIPS_MACHINE(ATH79_MACH_AP136_010, "AP136-010",
  237. - "Atheros AP136-010 reference board",
  238. - ap136_setup);
  239. +MIPS_MACHINE(ATH79_MACH_AP136_020, "AP136-020",
  240. + "Atheros AP136-020 reference board",
  241. + ap136_020_setup);
  242. +
  243. +/*
  244. + * AP135-020 is similar to AP136-020, any future AP135 specific init
  245. + * code can be added here.
  246. + */
  247. +static void __init ap135_020_setup(void)
  248. +{
  249. + ap136_leds_gpio[0].name = "ap135:green:status";
  250. + ap136_leds_gpio[1].name = "ap135:red:status";
  251. + ap136_leds_gpio[2].name = "ap135:green:wps";
  252. + ap136_leds_gpio[3].name = "ap135:red:wps";
  253. + ap136_leds_gpio[4].name = "ap135:red:wlan-2g";
  254. + ap136_leds_gpio[5].name = "ap135:red:usb";
  255. +
  256. + ap136_020_common_setup();
  257. + ath79_register_pci();
  258. +}
  259. +
  260. +MIPS_MACHINE(ATH79_MACH_AP135_020, "AP135-020",
  261. + "Atheros AP135-020 reference board",
  262. + ap135_020_setup);
  263. --- a/arch/mips/ath79/Kconfig
  264. +++ b/arch/mips/ath79/Kconfig
  265. @@ -17,16 +17,17 @@ config ATH79_MACH_AP121
  266. Atheros AP121 reference board.
  267. config ATH79_MACH_AP136
  268. - bool "Atheros AP136 reference board"
  269. + bool "Atheros AP136/AP135 reference board"
  270. select SOC_QCA955X
  271. select ATH79_DEV_GPIO_BUTTONS
  272. select ATH79_DEV_LEDS_GPIO
  273. + select ATH79_DEV_NFC
  274. select ATH79_DEV_SPI
  275. select ATH79_DEV_USB
  276. select ATH79_DEV_WMAC
  277. help
  278. Say 'Y' here if you want your kernel to support the
  279. - Atheros AP136 reference board.
  280. + Atheros AP136 or AP135 reference boards.
  281. config ATH79_MACH_AP81
  282. bool "Atheros AP81 reference board"