mach-ubnt-xm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Ubiquiti Networks XM (rev 1.0) board support
  3. *
  4. * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
  5. *
  6. * Derived from: mach-pb44.c
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/pci.h>
  14. #include <linux/ath9k_platform.h>
  15. #include <asm/mach-ath79/irq.h>
  16. #include "machtypes.h"
  17. #include "dev-gpio-buttons.h"
  18. #include "dev-leds-gpio.h"
  19. #include "dev-spi.h"
  20. #include "pci.h"
  21. #define UBNT_XM_GPIO_LED_L1 0
  22. #define UBNT_XM_GPIO_LED_L2 1
  23. #define UBNT_XM_GPIO_LED_L3 11
  24. #define UBNT_XM_GPIO_LED_L4 7
  25. #define UBNT_XM_GPIO_BTN_RESET 12
  26. #define UBNT_XM_KEYS_POLL_INTERVAL 20
  27. #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
  28. #define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000)
  29. static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
  30. {
  31. .name = "ubnt-xm:red:link1",
  32. .gpio = UBNT_XM_GPIO_LED_L1,
  33. .active_low = 0,
  34. }, {
  35. .name = "ubnt-xm:orange:link2",
  36. .gpio = UBNT_XM_GPIO_LED_L2,
  37. .active_low = 0,
  38. }, {
  39. .name = "ubnt-xm:green:link3",
  40. .gpio = UBNT_XM_GPIO_LED_L3,
  41. .active_low = 0,
  42. }, {
  43. .name = "ubnt-xm:green:link4",
  44. .gpio = UBNT_XM_GPIO_LED_L4,
  45. .active_low = 0,
  46. },
  47. };
  48. static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
  49. {
  50. .desc = "reset",
  51. .type = EV_KEY,
  52. .code = KEY_RESTART,
  53. .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  54. .gpio = UBNT_XM_GPIO_BTN_RESET,
  55. .active_low = 1,
  56. }
  57. };
  58. static struct spi_board_info ubnt_xm_spi_info[] = {
  59. {
  60. .bus_num = 0,
  61. .chip_select = 0,
  62. .max_speed_hz = 25000000,
  63. .modalias = "mx25l6405d",
  64. }
  65. };
  66. static struct ath79_spi_platform_data ubnt_xm_spi_data = {
  67. .bus_num = 0,
  68. .num_chipselect = 1,
  69. };
  70. #ifdef CONFIG_PCI
  71. static struct ath9k_platform_data ubnt_xm_eeprom_data;
  72. static int ubnt_xm_pci_plat_dev_init(struct pci_dev *dev)
  73. {
  74. switch (PCI_SLOT(dev->devfn)) {
  75. case 0:
  76. dev->dev.platform_data = &ubnt_xm_eeprom_data;
  77. break;
  78. }
  79. return 0;
  80. }
  81. static void __init ubnt_xm_pci_init(void)
  82. {
  83. memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
  84. sizeof(ubnt_xm_eeprom_data.eeprom_data));
  85. ath79_pci_set_plat_dev_init(ubnt_xm_pci_plat_dev_init);
  86. ath79_register_pci();
  87. }
  88. #else
  89. static inline void ubnt_xm_pci_init(void) {}
  90. #endif /* CONFIG_PCI */
  91. static void __init ubnt_xm_init(void)
  92. {
  93. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
  94. ubnt_xm_leds_gpio);
  95. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  96. ARRAY_SIZE(ubnt_xm_gpio_keys),
  97. ubnt_xm_gpio_keys);
  98. ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
  99. ARRAY_SIZE(ubnt_xm_spi_info));
  100. ubnt_xm_pci_init();
  101. }
  102. MIPS_MACHINE(ATH79_MACH_UBNT_XM,
  103. "UBNT-XM",
  104. "Ubiquiti Networks XM (rev 1.0) board",
  105. ubnt_xm_init);