1
0

mach-gl-inet.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * GL-CONNECT iNet 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 <asm/mach-ath79/ath79.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 GL_INET_GPIO_LED_WLAN 0
  23. #define GL_INET_GPIO_LED_LAN 13
  24. #define GL_INET_GPIO_BTN_RESET 11
  25. #define GL_INET_KEYS_POLL_INTERVAL 20 /* msecs */
  26. #define GL_INET_KEYS_DEBOUNCE_INTERVAL (3 * GL_INET_KEYS_POLL_INTERVAL)
  27. static const char * gl_inet_part_probes[] = {
  28. "tp-link", /* dont change, this will use tplink parser */
  29. NULL ,
  30. };
  31. static struct flash_platform_data gl_inet_flash_data = {
  32. .part_probes = gl_inet_part_probes,
  33. };
  34. static struct gpio_led gl_inet_leds_gpio[] __initdata = {
  35. {
  36. .name = "gl-inet:red:wlan",
  37. .gpio = GL_INET_GPIO_LED_WLAN,
  38. .active_low = 0,
  39. },
  40. {
  41. .name = "gl-inet:green:lan",
  42. .gpio = GL_INET_GPIO_LED_LAN,
  43. .active_low = 0,
  44. .default_state = 1,
  45. },
  46. };
  47. static struct gpio_keys_button gl_inet_gpio_keys[] __initdata = {
  48. {
  49. .desc = "reset",
  50. .type = EV_KEY,
  51. .code = KEY_RESTART,
  52. .debounce_interval = GL_INET_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = GL_INET_GPIO_BTN_RESET,
  54. .active_low = 0,
  55. }
  56. };
  57. static void __init gl_inet_setup(void)
  58. {
  59. /* get the mac address which is stored in the 1st 64k uboot MTD */
  60. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  61. /* get the art address, which is the last 64K. By using
  62. 0x1fff1000, it doesn't matter it is 4M, 8M or 16M flash */
  63. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  64. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  65. ath79_setup_ar933x_phy4_switch(false, false);
  66. /* register flash. MTD will use tp-link parser to parser MTD */
  67. ath79_register_m25p80(&gl_inet_flash_data);
  68. /* register gpio LEDs and keys */
  69. ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_inet_leds_gpio),
  70. gl_inet_leds_gpio);
  71. ath79_register_gpio_keys_polled(-1, GL_INET_KEYS_POLL_INTERVAL,
  72. ARRAY_SIZE(gl_inet_gpio_keys),
  73. gl_inet_gpio_keys);
  74. /* enable usb */
  75. ath79_register_usb();
  76. /* register eth0 as WAN, eth1 as LAN */
  77. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  78. ath79_register_mdio(0, 0x0);
  79. ath79_register_eth(0);
  80. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  81. ath79_register_eth(1);
  82. /* register wireless mac with cal data */
  83. ath79_register_wmac(ee, mac);
  84. }
  85. MIPS_MACHINE(ATH79_MACH_GL_INET, "GL-INET", "GL-CONNECT INET v1",
  86. gl_inet_setup);