mach-ap113.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Atheros AP113 board support
  3. *
  4. * Copyright (C) 2011 Florian Fainelli <[email protected]>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/mtd/mtd.h>
  11. #include <linux/mtd/partitions.h>
  12. #include <linux/spi/flash.h>
  13. #include "dev-eth.h"
  14. #include "dev-gpio-buttons.h"
  15. #include "dev-leds-gpio.h"
  16. #include "dev-m25p80.h"
  17. #include "pci.h"
  18. #include "dev-usb.h"
  19. #include "machtypes.h"
  20. #define AP113_GPIO_LED_USB 0
  21. #define AP113_GPIO_LED_STATUS 1
  22. #define AP113_GPIO_LED_ST 11
  23. #define AP113_GPIO_BTN_JUMPSTART 12
  24. #define AP113_KEYS_POLL_INTERVAL 20 /* msecs */
  25. #define AP113_KEYS_DEBOUNCE_INTERVAL (3 * AP113_KEYS_POLL_INTERVAL)
  26. static struct mtd_partition ap113_parts[] = {
  27. {
  28. .name = "u-boot",
  29. .offset = 0,
  30. .size = 0x010000,
  31. .mask_flags = MTD_WRITEABLE,
  32. },
  33. {
  34. .name = "rootfs",
  35. .offset = 0x010000,
  36. .size = 0x300000,
  37. },
  38. {
  39. .name = "uImage",
  40. .offset = 0x300000,
  41. .size = 0x3e0000,
  42. },
  43. {
  44. .name = "NVRAM",
  45. .offset = 0x3e0000,
  46. .size = 0x010000,
  47. },
  48. {
  49. .name = "ART",
  50. .offset = 0x3f0000,
  51. .size = 0x010000,
  52. .mask_flags = MTD_WRITEABLE,
  53. },
  54. };
  55. #define ap113_nr_parts ARRAY_SIZE(ap113_parts)
  56. static struct flash_platform_data ap113_flash_data = {
  57. .parts = ap113_parts,
  58. .nr_parts = ap113_nr_parts,
  59. };
  60. static struct gpio_led ap113_leds_gpio[] __initdata = {
  61. {
  62. .name = "ap113:green:usb",
  63. .gpio = AP113_GPIO_LED_USB,
  64. .active_low = 1,
  65. },
  66. {
  67. .name = "ap113:green:status",
  68. .gpio = AP113_GPIO_LED_STATUS,
  69. .active_low = 1,
  70. },
  71. {
  72. .name = "ap113:green:st",
  73. .gpio = AP113_GPIO_LED_ST,
  74. .active_low = 1,
  75. }
  76. };
  77. static struct gpio_keys_button ap113_gpio_keys[] __initdata = {
  78. {
  79. .desc = "jumpstart button",
  80. .type = EV_KEY,
  81. .code = KEY_WPS_BUTTON,
  82. .debounce_interval = AP113_KEYS_DEBOUNCE_INTERVAL,
  83. .gpio = AP113_GPIO_BTN_JUMPSTART,
  84. .active_low = 1,
  85. },
  86. };
  87. static void __init ap113_setup(void)
  88. {
  89. u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
  90. ath79_register_m25p80(&ap113_flash_data);
  91. ath79_register_mdio(0, ~BIT(0));
  92. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  93. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  94. ath79_eth0_data.speed = SPEED_1000;
  95. ath79_eth0_data.duplex = DUPLEX_FULL;
  96. ath79_eth0_data.phy_mask = BIT(0);
  97. ath79_register_eth(0);
  98. ath79_register_gpio_keys_polled(-1, AP113_KEYS_POLL_INTERVAL,
  99. ARRAY_SIZE(ap113_gpio_keys),
  100. ap113_gpio_keys);
  101. ath79_register_leds_gpio(-1, ARRAY_SIZE(ap113_leds_gpio),
  102. ap113_leds_gpio);
  103. ath79_register_pci();
  104. ath79_register_usb();
  105. }
  106. MIPS_MACHINE(ATH79_MACH_AP113, "AP113", "Atheros AP113",
  107. ap113_setup);