mach-ap81.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Atheros AP81 board support
  3. *
  4. * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2009 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include "machtypes.h"
  12. #include "dev-ar913x-wmac.h"
  13. #include "dev-gpio-buttons.h"
  14. #include "dev-leds-gpio.h"
  15. #include "dev-spi.h"
  16. #define AP81_GPIO_LED_STATUS 1
  17. #define AP81_GPIO_LED_AOSS 3
  18. #define AP81_GPIO_LED_WLAN 6
  19. #define AP81_GPIO_LED_POWER 14
  20. #define AP81_GPIO_BTN_SW4 12
  21. #define AP81_GPIO_BTN_SW1 21
  22. #define AP81_KEYS_POLL_INTERVAL 20 /* msecs */
  23. #define AP81_KEYS_DEBOUNCE_INTERVAL (3 * AP81_KEYS_POLL_INTERVAL)
  24. #define AP81_CAL_DATA_ADDR 0x1fff1000
  25. static struct gpio_led ap81_leds_gpio[] __initdata = {
  26. {
  27. .name = "ap81:green:status",
  28. .gpio = AP81_GPIO_LED_STATUS,
  29. .active_low = 1,
  30. }, {
  31. .name = "ap81:amber:aoss",
  32. .gpio = AP81_GPIO_LED_AOSS,
  33. .active_low = 1,
  34. }, {
  35. .name = "ap81:green:wlan",
  36. .gpio = AP81_GPIO_LED_WLAN,
  37. .active_low = 1,
  38. }, {
  39. .name = "ap81:green:power",
  40. .gpio = AP81_GPIO_LED_POWER,
  41. .active_low = 1,
  42. }
  43. };
  44. static struct gpio_keys_button ap81_gpio_keys[] __initdata = {
  45. {
  46. .desc = "sw1",
  47. .type = EV_KEY,
  48. .code = BTN_0,
  49. .debounce_interval = AP81_KEYS_DEBOUNCE_INTERVAL,
  50. .gpio = AP81_GPIO_BTN_SW1,
  51. .active_low = 1,
  52. } , {
  53. .desc = "sw4",
  54. .type = EV_KEY,
  55. .code = BTN_1,
  56. .debounce_interval = AP81_KEYS_DEBOUNCE_INTERVAL,
  57. .gpio = AP81_GPIO_BTN_SW4,
  58. .active_low = 1,
  59. }
  60. };
  61. static struct spi_board_info ap81_spi_info[] = {
  62. {
  63. .bus_num = 0,
  64. .chip_select = 0,
  65. .max_speed_hz = 25000000,
  66. .modalias = "m25p64",
  67. }
  68. };
  69. static struct ath79_spi_platform_data ap81_spi_data = {
  70. .bus_num = 0,
  71. .num_chipselect = 1,
  72. };
  73. static void __init ap81_setup(void)
  74. {
  75. u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR);
  76. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
  77. ap81_leds_gpio);
  78. ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL,
  79. ARRAY_SIZE(ap81_gpio_keys),
  80. ap81_gpio_keys);
  81. ath79_register_spi(&ap81_spi_data, ap81_spi_info,
  82. ARRAY_SIZE(ap81_spi_info));
  83. ath79_register_ar913x_wmac(cal_data);
  84. }
  85. MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
  86. ap81_setup);