mach-mr16.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Cisco Meraki MR16 board support
  3. *
  4. * Copyright (C) 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 MR16_GPIO_LED_W4_GREEN 3
  26. #define MR16_GPIO_LED_W3_GREEN 2
  27. #define MR16_GPIO_LED_W2_GREEN 1
  28. #define MR16_GPIO_LED_W1_GREEN 0
  29. #define MR16_GPIO_LED_WAN 4
  30. #define MR16_GPIO_LED_POWER_ORANGE 5
  31. #define MR16_GPIO_LED_POWER_GREEN 6
  32. #define MR16_GPIO_BTN_RESET 7
  33. #define MR16_KEYS_POLL_INTERVAL 20 /* msecs */
  34. #define MR16_KEYS_DEBOUNCE_INTERVAL (3 * MR16_KEYS_POLL_INTERVAL)
  35. #define MR16_WAN_PHYMASK BIT(0)
  36. #define MR16_WMAC0_MAC_OFFSET 0x120c
  37. #define MR16_WMAC1_MAC_OFFSET 0x520c
  38. #define MR16_CALDATA0_OFFSET 0x1000
  39. #define MR16_CALDATA1_OFFSET 0x5000
  40. static struct gpio_led MR16_leds_gpio[] __initdata = {
  41. {
  42. .name = "mr16:green:wan",
  43. .gpio = MR16_GPIO_LED_WAN,
  44. .active_low = 1,
  45. }, {
  46. .name = "mr16:orange:power",
  47. .gpio = MR16_GPIO_LED_POWER_ORANGE,
  48. .active_low = 1,
  49. }, {
  50. .name = "mr16:green:power",
  51. .gpio = MR16_GPIO_LED_POWER_GREEN,
  52. .active_low = 1,
  53. }, {
  54. .name = "mr16:green:wifi4",
  55. .gpio = MR16_GPIO_LED_W4_GREEN,
  56. .active_low = 1,
  57. }, {
  58. .name = "mr16:green:wifi3",
  59. .gpio = MR16_GPIO_LED_W3_GREEN,
  60. .active_low = 1,
  61. }, {
  62. .name = "mr16:green:wifi2",
  63. .gpio = MR16_GPIO_LED_W2_GREEN,
  64. .active_low = 1,
  65. }, {
  66. .name = "mr16:green:wifi1",
  67. .gpio = MR16_GPIO_LED_W1_GREEN,
  68. .active_low = 1,
  69. }
  70. };
  71. static struct gpio_keys_button MR16_gpio_keys[] __initdata = {
  72. {
  73. .desc = "reset",
  74. .type = EV_KEY,
  75. .code = KEY_RESTART,
  76. .debounce_interval = MR16_KEYS_DEBOUNCE_INTERVAL,
  77. .gpio = MR16_GPIO_BTN_RESET,
  78. .active_low = 1,
  79. }
  80. };
  81. static void __init MR16_setup(void)
  82. {
  83. u8 *mac = (u8 *) KSEG1ADDR(0xbfff0000);
  84. ath79_register_mdio(0,0x0);
  85. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  86. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  87. ath79_eth0_data.phy_mask = MR16_WAN_PHYMASK;
  88. ath79_register_eth(0);
  89. ath79_register_m25p80(NULL);
  90. ath79_register_leds_gpio(-1, ARRAY_SIZE(MR16_leds_gpio),
  91. MR16_leds_gpio);
  92. ath79_register_gpio_keys_polled(-1, MR16_KEYS_POLL_INTERVAL,
  93. ARRAY_SIZE(MR16_gpio_keys),
  94. MR16_gpio_keys);
  95. ap94_pci_init(mac + MR16_CALDATA0_OFFSET,
  96. mac + MR16_WMAC0_MAC_OFFSET,
  97. mac + MR16_CALDATA1_OFFSET,
  98. mac + MR16_WMAC1_MAC_OFFSET);
  99. }
  100. MIPS_MACHINE(ATH79_MACH_MR16, "MR16", "Meraki MR16", MR16_setup);