mach-smart-300.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * NC-LINK SMART-300 board support
  3. *
  4. * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/gpio.h>
  13. #include <asm/mach-ath79/ath79.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. #include <asm/mach-ath79/ag71xx_platform.h>
  16. #include "common.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-wmac.h"
  22. #include "machtypes.h"
  23. #define SMART_300_GPIO_LED_WLAN 13
  24. #define SMART_300_GPIO_LED_WAN 18
  25. #define SMART_300_GPIO_LED_LAN4 19
  26. #define SMART_300_GPIO_LED_LAN3 12
  27. #define SMART_300_GPIO_LED_LAN2 21
  28. #define SMART_300_GPIO_LED_LAN1 20
  29. #define SMART_300_GPIO_LED_SYSTEM 15
  30. #define SMART_300_GPIO_LED_POWER 14
  31. #define SMART_300_GPIO_BTN_RESET 17
  32. #define SMART_300_GPIO_SW_RFKILL 16
  33. #define SMART_300_KEYS_POLL_INTERVAL 20 /* msecs */
  34. #define SMART_300_KEYS_DEBOUNCE_INTERVAL (3 * SMART_300_KEYS_POLL_INTERVAL)
  35. #define SMART_300_GPIO_MASK 0x007fffff
  36. static const char *smart_300_part_probes[] = {
  37. "tp-link",
  38. NULL,
  39. };
  40. static struct flash_platform_data smart_300_flash_data = {
  41. .part_probes = smart_300_part_probes,
  42. };
  43. static struct gpio_led smart_300_leds_gpio[] __initdata = {
  44. {
  45. .name = "nc-link:green:lan1",
  46. .gpio = SMART_300_GPIO_LED_LAN1,
  47. .active_low = 1,
  48. }, {
  49. .name = "nc-link:green:lan2",
  50. .gpio = SMART_300_GPIO_LED_LAN2,
  51. .active_low = 1,
  52. }, {
  53. .name = "nc-link:green:lan3",
  54. .gpio = SMART_300_GPIO_LED_LAN3,
  55. .active_low = 1,
  56. }, {
  57. .name = "nc-link:green:lan4",
  58. .gpio = SMART_300_GPIO_LED_LAN4,
  59. .active_low = 1,
  60. }, {
  61. .name = "nc-link:green:system",
  62. .gpio = SMART_300_GPIO_LED_SYSTEM,
  63. .active_low = 1,
  64. }, {
  65. .name = "nc-link:green:wan",
  66. .gpio = SMART_300_GPIO_LED_WAN,
  67. .active_low = 1,
  68. }, {
  69. .name = "nc-link:green:wlan",
  70. .gpio = SMART_300_GPIO_LED_WLAN,
  71. .active_low = 1,
  72. },
  73. };
  74. static struct gpio_keys_button smart_300_gpio_keys[] __initdata = {
  75. {
  76. .desc = "reset",
  77. .type = EV_KEY,
  78. .code = KEY_RESTART,
  79. .debounce_interval = SMART_300_KEYS_DEBOUNCE_INTERVAL,
  80. .gpio = SMART_300_GPIO_BTN_RESET,
  81. .active_low = 1,
  82. }
  83. };
  84. static void __init smart_300_setup(void)
  85. {
  86. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  87. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  88. ath79_register_leds_gpio(-1, ARRAY_SIZE(smart_300_leds_gpio),
  89. smart_300_leds_gpio);
  90. ath79_register_gpio_keys_polled(1, SMART_300_KEYS_POLL_INTERVAL,
  91. ARRAY_SIZE(smart_300_gpio_keys),
  92. smart_300_gpio_keys);
  93. ath79_register_m25p80(&smart_300_flash_data);
  94. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  95. ath79_register_mdio(1, 0x0);
  96. ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  97. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  98. /* GMAC0 is connected to the PHY0 of the internal switch */
  99. ath79_switch_data.phy4_mii_en = 1;
  100. ath79_switch_data.phy_poll_mask = BIT(4);
  101. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  102. ath79_eth0_data.phy_mask = BIT(4);
  103. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  104. ath79_register_eth(0);
  105. /* GMAC1 is connected to the internal switch */
  106. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  107. ath79_register_eth(1);
  108. ath79_register_wmac(ee, mac);
  109. gpio_request(SMART_300_GPIO_LED_POWER, "power");
  110. gpio_direction_output(SMART_300_GPIO_LED_POWER, GPIOF_OUT_INIT_LOW);
  111. }
  112. MIPS_MACHINE(ATH79_MACH_SMART_300, "SMART-300", "NC-LINK SMART-300",
  113. smart_300_setup);