1
0

mach-carambola2.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * 8devices Carambola2 board support
  3. *
  4. * Copyright (C) 2013 Darius Augulis <darius@8devices.com>
  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 <asm/mach-ath79/ath79.h>
  11. #include <asm/mach-ath79/ar71xx_regs.h>
  12. #include "common.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 "dev-spi.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define CARAMBOLA2_GPIO_LED_WLAN 0
  22. #define CARAMBOLA2_GPIO_LED_ETH0 14
  23. #define CARAMBOLA2_GPIO_LED_ETH1 13
  24. #define CARAMBOLA2_GPIO_BTN_JUMPSTART 11
  25. #define CARAMBOLA2_KEYS_POLL_INTERVAL 20 /* msecs */
  26. #define CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL (3 * CARAMBOLA2_KEYS_POLL_INTERVAL)
  27. #define CARAMBOLA2_MAC0_OFFSET 0x0000
  28. #define CARAMBOLA2_MAC1_OFFSET 0x0006
  29. #define CARAMBOLA2_CALDATA_OFFSET 0x1000
  30. #define CARAMBOLA2_WMAC_MAC_OFFSET 0x1002
  31. static struct gpio_led carambola2_leds_gpio[] __initdata = {
  32. {
  33. .name = "carambola2:green:wlan",
  34. .gpio = CARAMBOLA2_GPIO_LED_WLAN,
  35. .active_low = 1,
  36. }, {
  37. .name = "carambola2:orange:eth0",
  38. .gpio = CARAMBOLA2_GPIO_LED_ETH0,
  39. .active_low = 0,
  40. }, {
  41. .name = "carambola2:orange:eth1",
  42. .gpio = CARAMBOLA2_GPIO_LED_ETH1,
  43. .active_low = 0,
  44. }
  45. };
  46. static struct gpio_keys_button carambola2_gpio_keys[] __initdata = {
  47. {
  48. .desc = "jumpstart button",
  49. .type = EV_KEY,
  50. .code = KEY_WPS_BUTTON,
  51. .debounce_interval = CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL,
  52. .gpio = CARAMBOLA2_GPIO_BTN_JUMPSTART,
  53. .active_low = 1,
  54. },
  55. };
  56. static void __init carambola2_common_setup(void)
  57. {
  58. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  59. ath79_register_m25p80(NULL);
  60. ath79_register_wmac(art + CARAMBOLA2_CALDATA_OFFSET,
  61. art + CARAMBOLA2_WMAC_MAC_OFFSET);
  62. ath79_setup_ar933x_phy4_switch(true, true);
  63. ath79_init_mac(ath79_eth0_data.mac_addr, art + CARAMBOLA2_MAC0_OFFSET, 0);
  64. ath79_init_mac(ath79_eth1_data.mac_addr, art + CARAMBOLA2_MAC1_OFFSET, 0);
  65. ath79_register_mdio(0, 0x0);
  66. /* LAN ports */
  67. ath79_register_eth(1);
  68. /* WAN port */
  69. ath79_register_eth(0);
  70. }
  71. static void __init carambola2_setup(void)
  72. {
  73. carambola2_common_setup();
  74. ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  75. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  76. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  77. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  78. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  79. ath79_register_leds_gpio(-1, ARRAY_SIZE(carambola2_leds_gpio),
  80. carambola2_leds_gpio);
  81. ath79_register_gpio_keys_polled(-1, CARAMBOLA2_KEYS_POLL_INTERVAL,
  82. ARRAY_SIZE(carambola2_gpio_keys),
  83. carambola2_gpio_keys);
  84. ath79_register_usb();
  85. }
  86. MIPS_MACHINE(ATH79_MACH_CARAMBOLA2, "CARAMBOLA2", "8devices Carambola2 board",
  87. carambola2_setup);