mach-ubnt-xm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #ifdef CONFIG_PCI
  15. #include <linux/ath9k_platform.h>
  16. #include <asm/mach-ath79/pci-ath724x.h>
  17. #endif /* CONFIG_PCI */
  18. #include "machtypes.h"
  19. #include "dev-gpio-buttons.h"
  20. #include "dev-leds-gpio.h"
  21. #include "dev-spi.h"
  22. #define UBNT_XM_GPIO_LED_L1 0
  23. #define UBNT_XM_GPIO_LED_L2 1
  24. #define UBNT_XM_GPIO_LED_L3 11
  25. #define UBNT_XM_GPIO_LED_L4 7
  26. #define UBNT_XM_GPIO_BTN_RESET 12
  27. #define UBNT_XM_KEYS_POLL_INTERVAL 20
  28. #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
  29. #define UBNT_XM_PCI_IRQ 48
  30. #define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000)
  31. static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
  32. {
  33. .name = "ubnt-xm:red:link1",
  34. .gpio = UBNT_XM_GPIO_LED_L1,
  35. .active_low = 0,
  36. }, {
  37. .name = "ubnt-xm:orange:link2",
  38. .gpio = UBNT_XM_GPIO_LED_L2,
  39. .active_low = 0,
  40. }, {
  41. .name = "ubnt-xm:green:link3",
  42. .gpio = UBNT_XM_GPIO_LED_L3,
  43. .active_low = 0,
  44. }, {
  45. .name = "ubnt-xm:green:link4",
  46. .gpio = UBNT_XM_GPIO_LED_L4,
  47. .active_low = 0,
  48. },
  49. };
  50. static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
  51. {
  52. .desc = "reset",
  53. .type = EV_KEY,
  54. .code = KEY_RESTART,
  55. .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
  56. .gpio = UBNT_XM_GPIO_BTN_RESET,
  57. .active_low = 1,
  58. }
  59. };
  60. static struct spi_board_info ubnt_xm_spi_info[] = {
  61. {
  62. .bus_num = 0,
  63. .chip_select = 0,
  64. .max_speed_hz = 25000000,
  65. .modalias = "mx25l6405d",
  66. }
  67. };
  68. static struct ath79_spi_platform_data ubnt_xm_spi_data = {
  69. .bus_num = 0,
  70. .num_chipselect = 1,
  71. };
  72. #ifdef CONFIG_PCI
  73. static struct ath9k_platform_data ubnt_xm_eeprom_data;
  74. static struct ath724x_pci_data ubnt_xm_pci_data[] = {
  75. {
  76. .irq = UBNT_XM_PCI_IRQ,
  77. .pdata = &ubnt_xm_eeprom_data,
  78. },
  79. };
  80. #endif /* CONFIG_PCI */
  81. static void __init ubnt_xm_init(void)
  82. {
  83. ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
  84. ubnt_xm_leds_gpio);
  85. ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
  86. ARRAY_SIZE(ubnt_xm_gpio_keys),
  87. ubnt_xm_gpio_keys);
  88. ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
  89. ARRAY_SIZE(ubnt_xm_spi_info));
  90. #ifdef CONFIG_PCI
  91. memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
  92. sizeof(ubnt_xm_eeprom_data.eeprom_data));
  93. ath724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
  94. #endif /* CONFIG_PCI */
  95. }
  96. MIPS_MACHINE(ATH79_MACH_UBNT_XM,
  97. "UBNT-XM",
  98. "Ubiquiti Networks XM (rev 1.0) board",
  99. ubnt_xm_init);