mach-db120.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Atheros DB120 reference board support
  3. *
  4. * Copyright (c) 2011 Qualcomm Atheros
  5. * Copyright (c) 2011 Gabor Juhos <juhosg@openwrt.org>
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. */
  20. #include <linux/pci.h>
  21. #include <linux/ath9k_platform.h>
  22. #include "machtypes.h"
  23. #include "dev-gpio-buttons.h"
  24. #include "dev-leds-gpio.h"
  25. #include "dev-spi.h"
  26. #include "dev-usb.h"
  27. #include "dev-wmac.h"
  28. #include "pci.h"
  29. #define DB120_GPIO_LED_WLAN_5G 12
  30. #define DB120_GPIO_LED_WLAN_2G 13
  31. #define DB120_GPIO_LED_STATUS 14
  32. #define DB120_GPIO_LED_WPS 15
  33. #define DB120_GPIO_BTN_WPS 16
  34. #define DB120_KEYS_POLL_INTERVAL 20 /* msecs */
  35. #define DB120_KEYS_DEBOUNCE_INTERVAL (3 * DB120_KEYS_POLL_INTERVAL)
  36. #define DB120_WMAC_CALDATA_OFFSET 0x1000
  37. #define DB120_PCIE_CALDATA_OFFSET 0x5000
  38. static struct gpio_led db120_leds_gpio[] __initdata = {
  39. {
  40. .name = "db120:green:status",
  41. .gpio = DB120_GPIO_LED_STATUS,
  42. .active_low = 1,
  43. },
  44. {
  45. .name = "db120:green:wps",
  46. .gpio = DB120_GPIO_LED_WPS,
  47. .active_low = 1,
  48. },
  49. {
  50. .name = "db120:green:wlan-5g",
  51. .gpio = DB120_GPIO_LED_WLAN_5G,
  52. .active_low = 1,
  53. },
  54. {
  55. .name = "db120:green:wlan-2g",
  56. .gpio = DB120_GPIO_LED_WLAN_2G,
  57. .active_low = 1,
  58. },
  59. };
  60. static struct gpio_keys_button db120_gpio_keys[] __initdata = {
  61. {
  62. .desc = "WPS button",
  63. .type = EV_KEY,
  64. .code = KEY_WPS_BUTTON,
  65. .debounce_interval = DB120_KEYS_DEBOUNCE_INTERVAL,
  66. .gpio = DB120_GPIO_BTN_WPS,
  67. .active_low = 1,
  68. },
  69. };
  70. static struct spi_board_info db120_spi_info[] = {
  71. {
  72. .bus_num = 0,
  73. .chip_select = 0,
  74. .max_speed_hz = 25000000,
  75. .modalias = "s25sl064a",
  76. }
  77. };
  78. static struct ath79_spi_platform_data db120_spi_data = {
  79. .bus_num = 0,
  80. .num_chipselect = 1,
  81. };
  82. #ifdef CONFIG_PCI
  83. static struct ath9k_platform_data db120_ath9k_data;
  84. static int db120_pci_plat_dev_init(struct pci_dev *dev)
  85. {
  86. switch (PCI_SLOT(dev->devfn)) {
  87. case 0:
  88. dev->dev.platform_data = &db120_ath9k_data;
  89. break;
  90. }
  91. return 0;
  92. }
  93. static void __init db120_pci_init(u8 *eeprom)
  94. {
  95. memcpy(db120_ath9k_data.eeprom_data, eeprom,
  96. sizeof(db120_ath9k_data.eeprom_data));
  97. ath79_pci_set_plat_dev_init(db120_pci_plat_dev_init);
  98. ath79_register_pci();
  99. }
  100. #else
  101. static inline void db120_pci_init(u8 *eeprom) {}
  102. #endif /* CONFIG_PCI */
  103. static void __init db120_setup(void)
  104. {
  105. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  106. ath79_register_leds_gpio(-1, ARRAY_SIZE(db120_leds_gpio),
  107. db120_leds_gpio);
  108. ath79_register_gpio_keys_polled(-1, DB120_KEYS_POLL_INTERVAL,
  109. ARRAY_SIZE(db120_gpio_keys),
  110. db120_gpio_keys);
  111. ath79_register_spi(&db120_spi_data, db120_spi_info,
  112. ARRAY_SIZE(db120_spi_info));
  113. ath79_register_usb();
  114. ath79_register_wmac(art + DB120_WMAC_CALDATA_OFFSET);
  115. db120_pci_init(art + DB120_PCIE_CALDATA_OFFSET);
  116. }
  117. MIPS_MACHINE(ATH79_MACH_DB120, "DB120", "Atheros DB120 reference board",
  118. db120_setup);