mach-c55.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * AirTight Networks C-55 board support
  3. *
  4. * Copyright (C) 2014-2015 Chris Blake <chrisrblake93@gmail.com>
  5. *
  6. * Based on Senao CAP4200AG board support
  7. *
  8. * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include <linux/pci.h>
  15. #include <linux/phy.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/ath9k_platform.h>
  21. #include <asm/mach-ath79/ar71xx_regs.h>
  22. #include "common.h"
  23. #include "pci.h"
  24. #include "dev-ap9x-pci.h"
  25. #include "dev-eth.h"
  26. #include "dev-gpio-buttons.h"
  27. #include "dev-leds-gpio.h"
  28. #include "dev-m25p80.h"
  29. #include "dev-spi.h"
  30. #include "dev-wmac.h"
  31. #include "machtypes.h"
  32. #define C55_GPIO_LED_PWR_GREEN 12
  33. #define C55_GPIO_LED_PWR_AMBER 13
  34. #define C55_GPIO_LED_LAN_GREEN 14
  35. #define C55_GPIO_LED_LAN_AMBER 15
  36. #define C55_GPIO_LED_WLAN_GREEN 18
  37. #define C55_GPIO_LED_WLAN_AMBER 19
  38. #define C55_GPIO_BTN_RESET 17
  39. #define C55_KEYS_POLL_INTERVAL 20 /* msecs */
  40. #define C55_KEYS_DEBOUNCE_INTERVAL (3 * C55_KEYS_POLL_INTERVAL)
  41. #define C55_MAC_OFFSET 0
  42. #define C55_WMAC_CALDATA_OFFSET 0x1000
  43. #define C55_PCIE_CALDATA_OFFSET 0x5000
  44. static struct gpio_led c55_leds_gpio[] __initdata = {
  45. {
  46. .name = "c-55:green:pwr",
  47. .gpio = C55_GPIO_LED_PWR_GREEN,
  48. .active_low = 1,
  49. },
  50. {
  51. .name = "c-55:amber:pwr",
  52. .gpio = C55_GPIO_LED_PWR_AMBER,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "c-55:green:lan",
  57. .gpio = C55_GPIO_LED_LAN_GREEN,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "c-55:amber:lan",
  62. .gpio = C55_GPIO_LED_LAN_AMBER,
  63. .active_low = 1,
  64. },
  65. {
  66. .name = "c-55:green:wlan",
  67. .gpio = C55_GPIO_LED_WLAN_GREEN,
  68. .active_low = 1,
  69. },
  70. {
  71. .name = "c-55:amber:wlan",
  72. .gpio = C55_GPIO_LED_WLAN_AMBER,
  73. .active_low = 1,
  74. },
  75. };
  76. static struct gpio_keys_button c55_gpio_keys[] __initdata = {
  77. {
  78. .desc = "Reset button",
  79. .type = EV_KEY,
  80. .code = KEY_RESTART,
  81. .debounce_interval = C55_KEYS_DEBOUNCE_INTERVAL,
  82. .gpio = C55_GPIO_BTN_RESET,
  83. .active_low = 1,
  84. },
  85. };
  86. static void __init c55_setup(void)
  87. {
  88. /* SPI Storage*/
  89. ath79_register_m25p80(NULL);
  90. /* MDIO Interface */
  91. ath79_register_mdio(0, 0x0);
  92. /* AR8035-A Ethernet */
  93. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  94. AR934X_ETH_CFG_SW_ONLY_MODE);
  95. ath79_init_mac(ath79_eth0_data.mac_addr, NULL, 0);
  96. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  97. ath79_eth0_data.phy_mask = BIT(0);
  98. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  99. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  100. ath79_register_eth(0);
  101. /* LEDs & GPIO */
  102. ath79_gpio_output_select(C55_GPIO_LED_LAN_GREEN,
  103. AR934X_GPIO_OUT_GPIO);
  104. ath79_gpio_output_select(C55_GPIO_LED_LAN_AMBER,
  105. AR934X_GPIO_OUT_GPIO);
  106. ath79_register_leds_gpio(-1, ARRAY_SIZE(c55_leds_gpio),
  107. c55_leds_gpio);
  108. ath79_register_gpio_keys_polled(-1, C55_KEYS_POLL_INTERVAL,
  109. ARRAY_SIZE(c55_gpio_keys),
  110. c55_gpio_keys);
  111. /* WiFi */
  112. ath79_wmac_disable_2ghz();
  113. ath79_register_wmac_simple();
  114. ap91_pci_init_simple();
  115. }
  116. MIPS_MACHINE(ATH79_MACH_C55, "C-55", "AirTight Networks C-55",
  117. c55_setup);