mach-om2p.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * OpenMesh OM2P support
  3. *
  4. * Copyright (C) 2011 Marek Lindner <[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/gpio.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <linux/platform_device.h>
  14. #include <asm/mach-ath79/ar71xx_regs.h>
  15. #include <asm/mach-ath79/ath79.h>
  16. #include "common.h"
  17. #include "dev-ap9x-pci.h"
  18. #include "dev-eth.h"
  19. #include "dev-gpio-buttons.h"
  20. #include "dev-leds-gpio.h"
  21. #include "dev-m25p80.h"
  22. #include "machtypes.h"
  23. #define OM2P_GPIO_LED_POWER 0
  24. #define OM2P_GPIO_LED_GREEN 13
  25. #define OM2P_GPIO_LED_RED 14
  26. #define OM2P_GPIO_LED_YELLOW 15
  27. #define OM2P_GPIO_LED_LAN 16
  28. #define OM2P_GPIO_LED_WAN 17
  29. #define OM2P_GPIO_BTN_RESET 11
  30. #define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
  31. #define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
  32. #define OM2P_WAN_PHYMASK BIT(4)
  33. static struct flash_platform_data om2p_flash_data = {
  34. .type = "s25sl12800",
  35. .name = "ar7240-nor0",
  36. };
  37. static struct gpio_led om2p_leds_gpio[] __initdata = {
  38. {
  39. .name = "om2p:blue:power",
  40. .gpio = OM2P_GPIO_LED_POWER,
  41. .active_low = 1,
  42. }, {
  43. .name = "om2p:red:wifi",
  44. .gpio = OM2P_GPIO_LED_RED,
  45. .active_low = 1,
  46. }, {
  47. .name = "om2p:yellow:wifi",
  48. .gpio = OM2P_GPIO_LED_YELLOW,
  49. .active_low = 1,
  50. }, {
  51. .name = "om2p:green:wifi",
  52. .gpio = OM2P_GPIO_LED_GREEN,
  53. .active_low = 1,
  54. }, {
  55. .name = "om2p:blue:lan",
  56. .gpio = OM2P_GPIO_LED_LAN,
  57. .active_low = 1,
  58. }, {
  59. .name = "om2p:blue:wan",
  60. .gpio = OM2P_GPIO_LED_WAN,
  61. .active_low = 1,
  62. }
  63. };
  64. static struct gpio_keys_button om2p_gpio_keys[] __initdata = {
  65. {
  66. .desc = "reset",
  67. .type = EV_KEY,
  68. .code = KEY_RESTART,
  69. .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
  70. .gpio = OM2P_GPIO_BTN_RESET,
  71. .active_low = 1,
  72. }
  73. };
  74. static void __init om2p_setup(void)
  75. {
  76. u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
  77. u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
  78. u8 *ee = (u8 *)KSEG1ADDR(0x1ffc1000);
  79. ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  80. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  81. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  82. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  83. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  84. ath79_register_m25p80(&om2p_flash_data);
  85. ath79_register_mdio(0, ~OM2P_WAN_PHYMASK);
  86. ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
  87. ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
  88. ath79_register_eth(0);
  89. ath79_register_eth(1);
  90. ap91_pci_init(ee, NULL);
  91. ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
  92. om2p_leds_gpio);
  93. ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
  94. ARRAY_SIZE(om2p_gpio_keys),
  95. om2p_gpio_keys);
  96. }
  97. MIPS_MACHINE(ATH79_MACH_OM2P, "OM2P", "OpenMesh OM2P", om2p_setup);