mach-dir-505-a1.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * DLink DIR-505 A1 board support
  3. *
  4. * Copyright (C) 2013 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/gpio.h>
  11. #include <asm/mach-ath79/ath79.h>
  12. #include <asm/mach-ath79/ar71xx_regs.h>
  13. #include "common.h"
  14. #include "dev-eth.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "dev-wmac.h"
  19. #include "dev-usb.h"
  20. #include "machtypes.h"
  21. #define DIR_505A1_GPIO_BTN_WPS 11 /* verify */
  22. #define DIR_505A1_GPIO_BTN_RESET 12 /* verify */
  23. #define DIR_505A1_GPIO_LED_RED 26 /* unused, fyi */
  24. #define DIR_505A1_GPIO_LED_GREEN 27
  25. #define DIR_505A1_GPIO_WAN_LED_ENABLE 1
  26. #define DIR_505A1_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define DIR_505A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_505A1_KEYS_POLL_INTERVAL)
  28. #define DIR_505A1_ART_ADDRESS 0x1f010000
  29. #define DIR_505A1_CALDATA_OFFSET 0x1000
  30. #define DIR_505A1_MAC_PART_ADDRESS 0x1f020000
  31. #define DIR_505A1_LAN_MAC_OFFSET 0x04
  32. #define DIR_505A1_WAN_MAC_OFFSET 0x16
  33. static struct gpio_led dir_505_a1_leds_gpio[] __initdata = {
  34. {
  35. .name = "d-link:green:power",
  36. .gpio = DIR_505A1_GPIO_LED_GREEN,
  37. .active_low = 1,
  38. }, {
  39. .name = "d-link:red:status",
  40. .gpio = DIR_505A1_GPIO_LED_RED,
  41. .active_low = 1,
  42. },
  43. };
  44. static struct gpio_keys_button dir_505_a1_gpio_keys[] __initdata = {
  45. {
  46. .desc = "Reset button",
  47. .type = EV_KEY,
  48. .code = KEY_RESTART,
  49. .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
  50. .gpio = DIR_505A1_GPIO_BTN_RESET,
  51. .active_low = 0,
  52. }, {
  53. .desc = "WPS button",
  54. .type = EV_KEY,
  55. .code = KEY_WPS_BUTTON,
  56. .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
  57. .gpio = DIR_505A1_GPIO_BTN_WPS,
  58. .active_low = 1,
  59. }
  60. };
  61. static void __init dir_505_a1_setup(void)
  62. {
  63. u8 *art = (u8 *) KSEG1ADDR(DIR_505A1_ART_ADDRESS);
  64. u8 *mac = (u8 *) KSEG1ADDR(DIR_505A1_MAC_PART_ADDRESS);
  65. u8 lan_mac[ETH_ALEN];
  66. u8 wan_mac[ETH_ALEN];
  67. ath79_setup_ar933x_phy4_switch(false, false);
  68. ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  69. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  70. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  71. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  72. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  73. gpio_request_one(DIR_505A1_GPIO_WAN_LED_ENABLE,
  74. GPIOF_OUT_INIT_LOW, "WAN LED enable");
  75. ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_505_a1_leds_gpio),
  76. dir_505_a1_leds_gpio);
  77. ath79_register_gpio_keys_polled(1, DIR_505A1_KEYS_POLL_INTERVAL,
  78. ARRAY_SIZE(dir_505_a1_gpio_keys),
  79. dir_505_a1_gpio_keys);
  80. ath79_register_m25p80(NULL);
  81. ath79_register_usb();
  82. ath79_parse_ascii_mac(mac + DIR_505A1_LAN_MAC_OFFSET, lan_mac);
  83. ath79_parse_ascii_mac(mac + DIR_505A1_WAN_MAC_OFFSET, wan_mac);
  84. ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
  85. ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
  86. ath79_register_mdio(0, 0x0);
  87. ath79_register_eth(1);
  88. ath79_register_eth(0);
  89. ath79_register_wmac(art + DIR_505A1_CALDATA_OFFSET, lan_mac);
  90. }
  91. MIPS_MACHINE(ATH79_MACH_DIR_505_A1, "DIR-505-A1",
  92. "D-Link DIR-505 rev. A1", dir_505_a1_setup);