mach-onion-omega.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Onion Omega board support
  3. *
  4. * Copyright (C) 2015 Boken Lin <bl@onion.io>
  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 <asm/mach-ath79/ath79.h>
  12. #include "dev-eth.h"
  13. #include "dev-gpio-buttons.h"
  14. #include "dev-leds-gpio.h"
  15. #include "dev-m25p80.h"
  16. #include "dev-usb.h"
  17. #include "dev-wmac.h"
  18. #include "machtypes.h"
  19. #define OMEGA_GPIO_LED_SYSTEM 27
  20. #define OMEGA_GPIO_BTN_RESET 11
  21. #define OMEGA_GPIO_USB_POWER 8
  22. #define OMEGA_KEYS_POLL_INTERVAL 20 /* msecs */
  23. #define OMEGA_KEYS_DEBOUNCE_INTERVAL (3 * OMEGA_KEYS_POLL_INTERVAL)
  24. static const char *omega_part_probes[] = {
  25. "tp-link",
  26. NULL,
  27. };
  28. static struct flash_platform_data omega_flash_data = {
  29. .part_probes = omega_part_probes,
  30. };
  31. static struct gpio_led omega_leds_gpio[] __initdata = {
  32. {
  33. .name = "onion:amber:system",
  34. .gpio = OMEGA_GPIO_LED_SYSTEM,
  35. .active_low = 1,
  36. },
  37. };
  38. static struct gpio_keys_button omega_gpio_keys[] __initdata = {
  39. {
  40. .desc = "reset",
  41. .type = EV_KEY,
  42. .code = KEY_RESTART,
  43. .debounce_interval = OMEGA_KEYS_DEBOUNCE_INTERVAL,
  44. .gpio = OMEGA_GPIO_BTN_RESET,
  45. .active_low = 0,
  46. }
  47. };
  48. static void __init onion_omega_setup(void)
  49. {
  50. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  51. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  52. ath79_register_m25p80(&omega_flash_data);
  53. ath79_register_leds_gpio(-1, ARRAY_SIZE(omega_leds_gpio),
  54. omega_leds_gpio);
  55. ath79_register_gpio_keys_polled(-1, OMEGA_KEYS_POLL_INTERVAL,
  56. ARRAY_SIZE(omega_gpio_keys),
  57. omega_gpio_keys);
  58. gpio_request_one(OMEGA_GPIO_USB_POWER,
  59. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  60. "USB power");
  61. ath79_register_usb();
  62. ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  63. ath79_register_mdio(0, 0x0);
  64. ath79_register_eth(0);
  65. ath79_register_wmac(ee, mac);
  66. }
  67. MIPS_MACHINE(ATH79_MACH_ONION_OMEGA, "ONION-OMEGA", "Onion Omega", onion_omega_setup);