mach-antrouter-r1.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Bitmain Antrouter R1 board support
  3. *
  4. * Copyright (C) 2015 L. D. Pinney <ldpinney@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 <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 "machtypes.h"
  20. #include "dev-usb.h"
  21. #define ANTROUTER_R1_GPIO_BTN_RESET 11
  22. #define ANTROUTER_R1_GPIO_LED_WLAN 0
  23. #define ANTROUTER_R1_GPIO_LED_BTC 22
  24. #define ANTROUTER_R1_GPIO_USB_POWER 18
  25. #define ANTROUTER_R1_KEYSPOLL_INTERVAL 44 /* msecs */
  26. #define ANTROUTER_R1_KEYSDEBOUNCE_INTERVAL (4 * ANTROUTER_R1_KEYSPOLL_INTERVAL)
  27. static const char *ANTROUTER_R1_part_probes[] = {
  28. "tp-link",
  29. NULL,
  30. };
  31. static struct flash_platform_data ANTROUTER_R1_flash_data = {
  32. .part_probes = ANTROUTER_R1_part_probes,
  33. };
  34. static struct gpio_led ANTROUTER_R1_leds_gpio[] __initdata = {
  35. {
  36. .name = "antrouter-r1:green:wlan",
  37. .gpio = ANTROUTER_R1_GPIO_LED_WLAN,
  38. .active_low = 0,
  39. },{
  40. .name = "antrouter-r1:green:system",
  41. .gpio = ANTROUTER_R1_GPIO_LED_BTC,
  42. .active_low = 0,
  43. },
  44. };
  45. static struct gpio_keys_button ANTROUTER_R1_GPIO_keys[] __initdata = {
  46. {
  47. .desc = "reset",
  48. .type = EV_KEY,
  49. .code = KEY_RESTART,
  50. .debounce_interval = ANTROUTER_R1_KEYSDEBOUNCE_INTERVAL,
  51. .gpio = ANTROUTER_R1_GPIO_BTN_RESET,
  52. .active_low = 0,
  53. },
  54. };
  55. static void __init antrouter_r1_setup(void)
  56. {
  57. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  58. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  59. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  60. ath79_setup_ar933x_phy4_switch(false, false);
  61. ath79_register_leds_gpio(-1, ARRAY_SIZE(ANTROUTER_R1_leds_gpio),
  62. ANTROUTER_R1_leds_gpio);
  63. ath79_register_gpio_keys_polled(-1, ANTROUTER_R1_KEYSPOLL_INTERVAL,
  64. ARRAY_SIZE(ANTROUTER_R1_GPIO_keys),
  65. ANTROUTER_R1_GPIO_keys);
  66. gpio_request_one(ANTROUTER_R1_GPIO_USB_POWER,
  67. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  68. "USB power");
  69. ath79_register_usb();
  70. ath79_register_m25p80(&ANTROUTER_R1_flash_data);
  71. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  72. ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  73. ath79_register_mdio(0, 0x0);
  74. ath79_register_eth(0);
  75. ath79_register_eth(1);
  76. ath79_register_wmac(ee, mac);
  77. }
  78. MIPS_MACHINE(ATH79_MACH_ANTROUTER_R1, "ANTROUTER-R1",
  79. "Antrouter-R1", antrouter_r1_setup);