mach-cap4200ag.c 3.4 KB

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