mach-c60.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * AirTight Networks C-60 board support
  3. *
  4. * Copyright (C) 2016 Christian Lamparter <chunkeey@googlemail.com>
  5. *
  6. * Based on AirTight Networks C-55 board support
  7. *
  8. * Copyright (C) 2014-2015 Chris Blake <chrisrblake93@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include <linux/pci.h>
  15. #include <linux/phy.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/nand.h>
  18. #include <linux/mtd/partitions.h>
  19. #include <linux/mtd/physmap.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/platform/ar934x_nfc.h>
  22. #include <linux/ar8216_platform.h>
  23. #include <linux/ath9k_platform.h>
  24. #include <asm/mach-ath79/ar71xx_regs.h>
  25. #include "common.h"
  26. #include "pci.h"
  27. #include "dev-ap9x-pci.h"
  28. #include "dev-eth.h"
  29. #include "dev-gpio-buttons.h"
  30. #include "dev-leds-gpio.h"
  31. #include "dev-m25p80.h"
  32. #include "dev-spi.h"
  33. #include "dev-wmac.h"
  34. #include "dev-usb.h"
  35. #include "dev-nfc.h"
  36. #include "machtypes.h"
  37. #define C60_GPIO_LED_PWR_AMBER 11
  38. #define C60_GPIO_LED_WLAN2_GREEN 12
  39. #define C60_GPIO_LED_WLAN2_AMBER 13
  40. #define C60_GPIO_LED_PWR_GREEN 16
  41. #define C60_GPIO_BTN_RESET 17
  42. /* GPIOs of the AR9300 PCIe chip */
  43. #define C60_GPIO_WMAC_LED_WLAN1_AMBER 0
  44. #define C60_GPIO_WMAC_LED_WLAN1_GREEN 3
  45. #define C60_KEYS_POLL_INTERVAL 20 /* msecs */
  46. #define C60_KEYS_DEBOUNCE_INTERVAL (3 * C60_KEYS_POLL_INTERVAL)
  47. #define C60_ART_ADDR 0x1f7f0000
  48. #define C60_ART_SIZE 0xffff
  49. #define C60_MAC_OFFSET 0
  50. #define C60_WMAC_CALDATA_OFFSET 0x1000
  51. #define C60_PCIE_CALDATA_OFFSET 0x5000
  52. static struct gpio_led c60_leds_gpio[] __initdata = {
  53. {
  54. .name = "c-60:amber:pwr",
  55. .gpio = C60_GPIO_LED_PWR_AMBER,
  56. .active_low = 1,
  57. },
  58. {
  59. .name = "c-60:green:pwr",
  60. .gpio = C60_GPIO_LED_PWR_GREEN,
  61. .active_low = 1,
  62. },
  63. {
  64. .name = "c-60:green:wlan2",
  65. .gpio = C60_GPIO_LED_WLAN2_GREEN,
  66. .active_low = 1,
  67. },
  68. {
  69. .name = "c-60:amber:wlan2",
  70. .gpio = C60_GPIO_LED_WLAN2_AMBER,
  71. .active_low = 1,
  72. },
  73. };
  74. static struct gpio_keys_button c60_gpio_keys[] __initdata = {
  75. {
  76. .desc = "Reset button",
  77. .type = EV_KEY,
  78. .code = KEY_RESTART,
  79. .debounce_interval = C60_KEYS_DEBOUNCE_INTERVAL,
  80. .gpio = C60_GPIO_BTN_RESET,
  81. .active_low = 1,
  82. },
  83. };
  84. static struct ar8327_pad_cfg c60_ar8327_pad0_cfg = {
  85. .mode = AR8327_PAD_MAC_RGMII,
  86. .txclk_delay_en = true,
  87. .rxclk_delay_en = true,
  88. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  89. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  90. };
  91. static struct ar8327_platform_data c60_ar8327_data = {
  92. .pad0_cfg = &c60_ar8327_pad0_cfg,
  93. .port0_cfg = {
  94. .force_link = 1,
  95. .speed = AR8327_PORT_SPEED_1000,
  96. .duplex = 1,
  97. .txpause = 1,
  98. .rxpause = 1,
  99. }
  100. };
  101. static struct mdio_board_info c60_mdio0_info[] = {
  102. {
  103. .bus_id = "ag71xx-mdio.0",
  104. .phy_addr = 0,
  105. .platform_data = &c60_ar8327_data,
  106. },
  107. };
  108. static struct nand_ecclayout c60_nand_ecclayout = {
  109. .eccbytes = 7,
  110. .eccpos = { 4, 8, 9, 10, 13, 14, 15 },
  111. .oobavail = 9,
  112. .oobfree = { { 0, 3 }, { 6, 2 }, { 11, 2 }, }
  113. };
  114. static int c60_nand_scan_fixup(struct mtd_info *mtd)
  115. {
  116. struct nand_chip *chip = mtd->priv;
  117. chip->ecc.size = 512;
  118. chip->ecc.strength = 4;
  119. chip->ecc.layout = &c60_nand_ecclayout;
  120. return 0;
  121. }
  122. static struct gpio_led c60_wmac0_leds_gpio[] = {
  123. {
  124. .name = "c-60:amber:wlan1",
  125. .gpio = C60_GPIO_WMAC_LED_WLAN1_AMBER,
  126. .active_low = 1,
  127. },
  128. {
  129. .name = "c-60:green:wlan1",
  130. .gpio = C60_GPIO_WMAC_LED_WLAN1_GREEN,
  131. .active_low = 1,
  132. },
  133. };
  134. static void __init c60_setup(void)
  135. {
  136. u8 tmpmac[6];
  137. u8 *art = (u8 *) KSEG1ADDR(C60_ART_ADDR);
  138. /* NAND */
  139. ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_SOFT_BCH);
  140. ath79_nfc_set_scan_fixup(c60_nand_scan_fixup);
  141. ath79_register_nfc();
  142. /* SPI Storage*/
  143. ath79_register_m25p80(NULL);
  144. /* AR8327 Switch Ethernet */
  145. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  146. mdiobus_register_board_info(c60_mdio0_info,
  147. ARRAY_SIZE(c60_mdio0_info));
  148. ath79_register_mdio(0, 0x0);
  149. /* GMAC0 is connected to an AR8327N switch */
  150. ath79_init_mac(ath79_eth0_data.mac_addr, art + C60_MAC_OFFSET, 0);
  151. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  152. ath79_eth0_data.phy_mask = BIT(0);
  153. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  154. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  155. ath79_register_eth(0);
  156. /* LEDs & GPIO */
  157. ath79_register_leds_gpio(-1, ARRAY_SIZE(c60_leds_gpio),
  158. c60_leds_gpio);
  159. ath79_register_gpio_keys_polled(-1, C60_KEYS_POLL_INTERVAL,
  160. ARRAY_SIZE(c60_gpio_keys),
  161. c60_gpio_keys);
  162. ap9x_pci_setup_wmac_leds(0, c60_wmac0_leds_gpio,
  163. ARRAY_SIZE(c60_wmac0_leds_gpio));
  164. /* USB */
  165. ath79_register_usb();
  166. /* WiFi */
  167. ath79_init_mac(tmpmac, art + C60_MAC_OFFSET, 1);
  168. ap91_pci_init(art + C60_PCIE_CALDATA_OFFSET, tmpmac);
  169. ath79_init_mac(tmpmac, art + C60_MAC_OFFSET, 2);
  170. ath79_register_wmac(art + C60_WMAC_CALDATA_OFFSET, tmpmac);
  171. }
  172. MIPS_MACHINE(ATH79_MACH_C60, "C-60", "AirTight Networks C-60",
  173. c60_setup);