mach-ap81.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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-wmac.h"
  13. #include "dev-gpio-buttons.h"
  14. #include "dev-leds-gpio.h"
  15. #include "dev-spi.h"
  16. #include "dev-usb.h"
  17. #define AP81_GPIO_LED_STATUS 1
  18. #define AP81_GPIO_LED_AOSS 3
  19. #define AP81_GPIO_LED_WLAN 6
  20. #define AP81_GPIO_LED_POWER 14
  21. #define AP81_GPIO_BTN_SW4 12
  22. #define AP81_GPIO_BTN_SW1 21
  23. #define AP81_KEYS_POLL_INTERVAL 20 /* msecs */
  24. #define AP81_KEYS_DEBOUNCE_INTERVAL (3 * AP81_KEYS_POLL_INTERVAL)
  25. #define AP81_CAL_DATA_ADDR 0x1fff1000
  26. static struct gpio_led ap81_leds_gpio[] __initdata = {
  27. {
  28. .name = "ap81:green:status",
  29. .gpio = AP81_GPIO_LED_STATUS,
  30. .active_low = 1,
  31. }, {
  32. .name = "ap81:amber:aoss",
  33. .gpio = AP81_GPIO_LED_AOSS,
  34. .active_low = 1,
  35. }, {
  36. .name = "ap81:green:wlan",
  37. .gpio = AP81_GPIO_LED_WLAN,
  38. .active_low = 1,
  39. }, {
  40. .name = "ap81:green:power",
  41. .gpio = AP81_GPIO_LED_POWER,
  42. .active_low = 1,
  43. }
  44. };
  45. static struct gpio_keys_button ap81_gpio_keys[] __initdata = {
  46. {
  47. .desc = "sw1",
  48. .type = EV_KEY,
  49. .code = BTN_0,
  50. .debounce_interval = AP81_KEYS_DEBOUNCE_INTERVAL,
  51. .gpio = AP81_GPIO_BTN_SW1,
  52. .active_low = 1,
  53. } , {
  54. .desc = "sw4",
  55. .type = EV_KEY,
  56. .code = BTN_1,
  57. .debounce_interval = AP81_KEYS_DEBOUNCE_INTERVAL,
  58. .gpio = AP81_GPIO_BTN_SW4,
  59. .active_low = 1,
  60. }
  61. };
  62. static struct spi_board_info ap81_spi_info[] = {
  63. {
  64. .bus_num = 0,
  65. .chip_select = 0,
  66. .max_speed_hz = 25000000,
  67. .modalias = "m25p64",
  68. }
  69. };
  70. static struct ath79_spi_platform_data ap81_spi_data = {
  71. .bus_num = 0,
  72. .num_chipselect = 1,
  73. };
  74. static void __init ap81_setup(void)
  75. {
  76. u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR);
  77. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
  78. ap81_leds_gpio);
  79. ath79_register_gpio_keys_polled(-1, AP81_KEYS_POLL_INTERVAL,
  80. ARRAY_SIZE(ap81_gpio_keys),
  81. ap81_gpio_keys);
  82. ath79_register_spi(&ap81_spi_data, ap81_spi_info,
  83. ARRAY_SIZE(ap81_spi_info));
  84. ath79_register_wmac(cal_data);
  85. ath79_register_usb();
  86. }
  87. MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
  88. ap81_setup);