mach-cap324.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * PowerCloud Systems CAP324 board support
  3. *
  4. * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2012-2013 PowerCloud Systems
  6. * Copyright (C) 2015 Daniel Dickinson
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/pci.h>
  13. #include <linux/phy.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/ath9k_platform.h>
  16. #include <asm/mach-ath79/ar71xx_regs.h>
  17. #include "common.h"
  18. #include "dev-ap9x-pci.h"
  19. #include "dev-eth.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-m25p80.h"
  23. #include "dev-spi.h"
  24. #include "dev-usb.h"
  25. #include "dev-wmac.h"
  26. #include "machtypes.h"
  27. #define CAP324_GPIO_LED_POWER_GREEN 12
  28. #define CAP324_GPIO_LED_POWER_AMBER 13
  29. #define CAP324_GPIO_LED_LAN_GREEN 14
  30. #define CAP324_GPIO_LED_LAN_AMBER 15
  31. #define CAP324_GPIO_LED_WLAN_GREEN 18
  32. #define CAP324_GPIO_LED_WLAN_AMBER 19
  33. #define CAP324_GPIO_BTN_RESET 17
  34. #define CAP324_KEYS_POLL_INTERVAL 20 /* msecs */
  35. #define CAP324_KEYS_DEBOUNCE_INTERVAL (3 * CAP324_KEYS_POLL_INTERVAL)
  36. #define CAP324_MAC_OFFSET 0
  37. #define CAP324_WMAC_CALDATA_OFFSET 0x1000
  38. #define CAP324_PCIE_CALDATA_OFFSET 0x5000
  39. static struct gpio_led cap324_leds_gpio[] __initdata = {
  40. {
  41. .name = "pcs:green:power",
  42. .gpio = CAP324_GPIO_LED_POWER_GREEN,
  43. .active_low = 1,
  44. },
  45. {
  46. .name = "pcs:amber:power",
  47. .gpio = CAP324_GPIO_LED_POWER_AMBER,
  48. .active_low = 1,
  49. },
  50. {
  51. .name = "pcs:green:lan",
  52. .gpio = CAP324_GPIO_LED_LAN_GREEN,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "pcs:amber:lan",
  57. .gpio = CAP324_GPIO_LED_LAN_AMBER,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "pcs:green:wlan",
  62. .gpio = CAP324_GPIO_LED_WLAN_GREEN,
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "pcs:amber:wlan",
  67. .gpio = CAP324_GPIO_LED_WLAN_AMBER,
  68. .active_low = 1,
  69. },
  70. };
  71. static struct gpio_keys_button cap324_gpio_keys[] __initdata = {
  72. {
  73. .desc = "Reset button",
  74. .type = EV_KEY,
  75. .code = KEY_RESTART,
  76. .debounce_interval = CAP324_KEYS_DEBOUNCE_INTERVAL,
  77. .gpio = CAP324_GPIO_BTN_RESET,
  78. .active_low = 1,
  79. },
  80. };
  81. static void __init cap324_setup(void)
  82. {
  83. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  84. u8 mac[6];
  85. ath79_gpio_output_select(CAP324_GPIO_LED_LAN_GREEN,
  86. AR934X_GPIO_OUT_GPIO);
  87. ath79_gpio_output_select(CAP324_GPIO_LED_LAN_AMBER,
  88. AR934X_GPIO_OUT_GPIO);
  89. ath79_register_m25p80(NULL);
  90. ath79_register_leds_gpio(-1, ARRAY_SIZE(cap324_leds_gpio),
  91. cap324_leds_gpio);
  92. ath79_register_gpio_keys_polled(-1, CAP324_KEYS_POLL_INTERVAL,
  93. ARRAY_SIZE(cap324_gpio_keys),
  94. cap324_gpio_keys);
  95. ath79_init_mac(mac, art + CAP324_MAC_OFFSET, -1);
  96. ath79_wmac_disable_2ghz();
  97. ath79_register_wmac(art + CAP324_WMAC_CALDATA_OFFSET, mac);
  98. ath79_init_mac(mac, art + CAP324_MAC_OFFSET, -2);
  99. ap91_pci_init(art + CAP324_PCIE_CALDATA_OFFSET, mac);
  100. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  101. AR934X_ETH_CFG_SW_ONLY_MODE);
  102. ath79_register_mdio(0, 0x0);
  103. ath79_init_mac(ath79_eth0_data.mac_addr,
  104. art + CAP324_MAC_OFFSET, -2);
  105. /* GMAC0 is connected to an external PHY */
  106. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  107. ath79_eth0_data.phy_mask = BIT(0);
  108. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  109. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  110. ath79_register_eth(0);
  111. }
  112. MIPS_MACHINE(ATH79_MACH_CAP324, "CAP324", "PowerCloud CAP324",
  113. cap324_setup);