mach-mr12.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Cisco Meraki MR12 board support
  3. *
  4. * Copyright (C) 2014-2015 Chris Blake <chrisrblake93@gmail.com>
  5. *
  6. * Based on Atheros AP96 board support configuration
  7. *
  8. * Copyright (C) 2009 Marco Porsch
  9. * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
  10. * Copyright (C) 2010 Atheros Communications
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License version 2 as published
  14. * by the Free Software Foundation.
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <asm/mach-ath79/ath79.h>
  19. #include "dev-ap9x-pci.h"
  20. #include "dev-eth.h"
  21. #include "dev-gpio-buttons.h"
  22. #include "dev-leds-gpio.h"
  23. #include "dev-m25p80.h"
  24. #include "machtypes.h"
  25. #define MR12_GPIO_LED_W4_GREEN 14
  26. #define MR12_GPIO_LED_W3_GREEN 13
  27. #define MR12_GPIO_LED_W2_GREEN 12
  28. #define MR12_GPIO_LED_W1_GREEN 11
  29. #define MR12_GPIO_LED_WAN 15
  30. #define MR12_GPIO_LED_POWER_ORANGE 16
  31. #define MR12_GPIO_LED_POWER_GREEN 17
  32. #define MR12_GPIO_BTN_RESET 8
  33. #define MR12_KEYS_POLL_INTERVAL 20 /* msecs */
  34. #define MR12_KEYS_DEBOUNCE_INTERVAL (3 * MR12_KEYS_POLL_INTERVAL)
  35. #define MR12_WAN_PHYMASK BIT(4)
  36. #define MR12_CALDATA0_OFFSET 0x21000
  37. static struct gpio_led MR12_leds_gpio[] __initdata = {
  38. {
  39. .name = "mr12:green:wan",
  40. .gpio = MR12_GPIO_LED_WAN,
  41. .active_low = 1,
  42. }, {
  43. .name = "mr12:orange:power",
  44. .gpio = MR12_GPIO_LED_POWER_ORANGE,
  45. .active_low = 1,
  46. }, {
  47. .name = "mr12:green:power",
  48. .gpio = MR12_GPIO_LED_POWER_GREEN,
  49. .active_low = 1,
  50. }, {
  51. .name = "mr12:green:wifi4",
  52. .gpio = MR12_GPIO_LED_W4_GREEN,
  53. .active_low = 1,
  54. }, {
  55. .name = "mr12:green:wifi3",
  56. .gpio = MR12_GPIO_LED_W3_GREEN,
  57. .active_low = 1,
  58. }, {
  59. .name = "mr12:green:wifi2",
  60. .gpio = MR12_GPIO_LED_W2_GREEN,
  61. .active_low = 1,
  62. }, {
  63. .name = "mr12:green:wifi1",
  64. .gpio = MR12_GPIO_LED_W1_GREEN,
  65. .active_low = 1,
  66. }
  67. };
  68. static struct gpio_keys_button MR12_gpio_keys[] __initdata = {
  69. {
  70. .desc = "reset",
  71. .type = EV_KEY,
  72. .code = KEY_RESTART,
  73. .debounce_interval = MR12_KEYS_DEBOUNCE_INTERVAL,
  74. .gpio = MR12_GPIO_BTN_RESET,
  75. .active_low = 1,
  76. }
  77. };
  78. static void __init MR12_setup(void)
  79. {
  80. u8 *mac = (u8 *) KSEG1ADDR(0xbffd0000);
  81. u8 wlan_mac[ETH_ALEN];
  82. ath79_register_mdio(0,0x0);
  83. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  84. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  85. ath79_eth0_data.phy_mask = MR12_WAN_PHYMASK;
  86. ath79_register_eth(0);
  87. ath79_register_m25p80(NULL);
  88. ath79_register_leds_gpio(-1, ARRAY_SIZE(MR12_leds_gpio),
  89. MR12_leds_gpio);
  90. ath79_register_gpio_keys_polled(-1, MR12_KEYS_POLL_INTERVAL,
  91. ARRAY_SIZE(MR12_gpio_keys),
  92. MR12_gpio_keys);
  93. ath79_init_mac(wlan_mac, mac, 1);
  94. ap91_pci_init(mac + MR12_CALDATA0_OFFSET, wlan_mac);
  95. }
  96. MIPS_MACHINE(ATH79_MACH_MR12, "MR12", "Meraki MR12", MR12_setup);