mach-gl-ar300.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Domino board support
  3. *
  4. * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  5. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (C) 2013 alzhao <alzhao@gmail.com>
  7. * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. */
  13. #include <linux/gpio.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/ath9k_platform.h>
  16. #include <asm/mach-ath79/ar71xx_regs.h>
  17. #include <asm/mach-ath79/ath79.h>
  18. #include "common.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-usb.h"
  24. #include "dev-wmac.h"
  25. #include "machtypes.h"
  26. #define GL_AR300_GPIO_LED_WLAN 13
  27. #define GL_AR300_GPIO_LED_WAN 14
  28. #define GL_AR300_GPIO_BTN_RESET 16
  29. #define GL_AR300_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define GL_AR300_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR300_KEYS_POLL_INTERVAL)
  31. #define GL_AR300_MAC0_OFFSET 0x0000
  32. #define GL_AR300_MAC1_OFFSET 0x0000
  33. #define GL_AR300_CALDATA_OFFSET 0x1000
  34. #define GL_AR300_WMAC_MAC_OFFSET 0x0000
  35. static struct gpio_led gl_ar300_leds_gpio[] __initdata = {
  36. {
  37. .name = "gl-ar300:wlan",
  38. .gpio = GL_AR300_GPIO_LED_WLAN,
  39. .active_low = 1,
  40. },
  41. {
  42. .name = "gl-ar300:wan",
  43. .gpio = GL_AR300_GPIO_LED_WAN,
  44. .active_low = 1,
  45. },
  46. };
  47. static struct gpio_keys_button gl_ar300_gpio_keys[] __initdata = {
  48. {
  49. .desc = "reset",
  50. .type = EV_KEY,
  51. .code = KEY_RESTART,
  52. .debounce_interval = GL_AR300_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = GL_AR300_GPIO_BTN_RESET,
  54. .active_low = 1,
  55. },
  56. };
  57. static void __init gl_ar300_setup(void)
  58. {
  59. /* ART base address */
  60. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  61. /* register flash. */
  62. ath79_register_m25p80(NULL);
  63. /* register gpio LEDs and keys */
  64. ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300_leds_gpio),
  65. gl_ar300_leds_gpio);
  66. ath79_register_gpio_keys_polled(-1, GL_AR300_KEYS_POLL_INTERVAL,
  67. ARRAY_SIZE(gl_ar300_gpio_keys),
  68. gl_ar300_gpio_keys);
  69. /* enable usb */
  70. ath79_register_usb();
  71. ath79_register_mdio(1, 0x0);
  72. /* register eth0 as WAN, eth1 as LAN */
  73. ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR300_MAC0_OFFSET, 0);
  74. ath79_switch_data.phy4_mii_en = 1;
  75. ath79_switch_data.phy_poll_mask = BIT(4);
  76. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  77. ath79_eth0_data.phy_mask = BIT(4);
  78. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  79. ath79_register_eth(0);
  80. ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR300_MAC1_OFFSET, 0);
  81. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  82. ath79_register_eth(1);
  83. /* register wireless mac with cal data */
  84. ath79_register_wmac(art + GL_AR300_CALDATA_OFFSET, art + GL_AR300_WMAC_MAC_OFFSET);
  85. }
  86. MIPS_MACHINE(ATH79_MACH_GL_AR300, "GL-AR300", "GL AR300",gl_ar300_setup);