mach-wam250.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Samsung WAM250 board support
  3. *
  4. * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
  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/gpio.h>
  11. #include <linux/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-usb.h"
  20. #include "dev-wmac.h"
  21. #include "machtypes.h"
  22. #define WAM250_GPIO_LED_LAN 13
  23. #define WAM250_GPIO_LED_POWER 15
  24. #define WAM250_GPIO_LED_REPEATER 14
  25. #define WAM250_GPIO_LED_WLAN 12
  26. #define WAM250_GPIO_BTN_RESET 17
  27. #define WAM250_GPIO_BTN_SPKADD 1
  28. #define WAM250_GPIO_EXT_LNA 19
  29. #define WAM250_MAC_OFFSET 2
  30. #define WAM250_KEYS_POLL_INTERVAL 20
  31. #define WAM250_KEYS_DEBOUNCE_INTERVAL (3 * WAM250_KEYS_POLL_INTERVAL)
  32. static struct gpio_led wam250_leds_gpio[] __initdata = {
  33. {
  34. .name = "wam250:white:lan",
  35. .gpio = WAM250_GPIO_LED_LAN,
  36. .active_low = 1,
  37. }, {
  38. .name = "wam250:white:power",
  39. .gpio = WAM250_GPIO_LED_POWER,
  40. .default_state = LEDS_GPIO_DEFSTATE_KEEP,
  41. .active_low = 1,
  42. }, {
  43. .name = "wam250:white:repeater",
  44. .gpio = WAM250_GPIO_LED_REPEATER,
  45. .active_low = 1,
  46. }, {
  47. .name = "wam250:white:wlan",
  48. .gpio = WAM250_GPIO_LED_WLAN,
  49. .active_low = 1,
  50. },
  51. };
  52. static struct gpio_keys_button wam250_gpio_keys[] __initdata = {
  53. {
  54. .desc = "reset",
  55. .type = EV_KEY,
  56. .code = KEY_RESTART,
  57. .debounce_interval = WAM250_KEYS_DEBOUNCE_INTERVAL,
  58. .gpio = WAM250_GPIO_BTN_RESET,
  59. .active_low = 1,
  60. }, {
  61. .desc = "wps",
  62. .type = EV_KEY,
  63. .code = KEY_WPS_BUTTON,
  64. .debounce_interval = WAM250_KEYS_DEBOUNCE_INTERVAL,
  65. .gpio = WAM250_GPIO_BTN_SPKADD,
  66. .active_low = 1,
  67. },
  68. };
  69. static void __init wam250_setup(void)
  70. {
  71. u8 *art = (u8 *) KSEG1ADDR(0x1fff1000);
  72. ath79_register_m25p80(NULL);
  73. ath79_register_mdio(1, 0x0);
  74. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  75. ath79_switch_data.phy4_mii_en = 1;
  76. ath79_switch_data.phy_poll_mask = 0xfd;
  77. /* LAN */
  78. ath79_eth1_data.duplex = DUPLEX_FULL;
  79. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  80. ath79_eth1_data.phy_mask = BIT(1);
  81. ath79_init_mac(ath79_eth1_data.mac_addr, art + WAM250_MAC_OFFSET, 0);
  82. ath79_register_eth(1);
  83. /* WAN */
  84. ath79_eth0_data.duplex = DUPLEX_FULL;
  85. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  86. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  87. ath79_eth0_data.phy_mask = BIT(0);
  88. ath79_eth0_data.speed = SPEED_100;
  89. ath79_init_mac(ath79_eth0_data.mac_addr, art + WAM250_MAC_OFFSET, 1);
  90. ath79_register_eth(0);
  91. ath79_register_leds_gpio(-1, ARRAY_SIZE(wam250_leds_gpio),
  92. wam250_leds_gpio);
  93. ath79_register_gpio_keys_polled(-1, WAM250_KEYS_POLL_INTERVAL,
  94. ARRAY_SIZE(wam250_gpio_keys),
  95. wam250_gpio_keys);
  96. ath79_wmac_set_ext_lna_gpio(0, WAM250_GPIO_EXT_LNA);
  97. ath79_register_usb();
  98. ath79_register_wmac(art, NULL);
  99. }
  100. MIPS_MACHINE(ATH79_MACH_WAM250, "WAM250", "Samsung WAM250", wam250_setup);