1
0

mach-omy-g1.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * OMYlink OMY-G1 board support
  3. *
  4. * Copyright (C) 2016 L. D. Pinney <ldpinney@gmail.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 <linux/gpio.h>
  11. #include <linux/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-usb.h"
  20. #include "dev-wmac.h"
  21. #include "machtypes.h"
  22. #define OMY_G1_GPIO_LED_WLAN 13
  23. #define OMY_G1_GPIO_LED_WAN 18
  24. #define OMY_G1_GPIO_LED_LAN 19
  25. #define OMY_G1_GPIO_USB_POWER 4
  26. #define OMY_G1_GPIO_BTN_RESET 17
  27. #define OMY_G1_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define OMY_G1_KEYS_DEBOUNCE_INTERVAL (3 * OMY_G1_KEYS_POLL_INTERVAL)
  29. static const char *omy_g1_part_probes[] = {
  30. "tp-link",
  31. NULL,
  32. };
  33. static struct flash_platform_data omy_g1_flash_data = {
  34. .part_probes = omy_g1_part_probes,
  35. };
  36. static struct gpio_led omy_g1_leds_gpio[] __initdata = {
  37. {
  38. .name = "omy:green:wlan",
  39. .gpio = OMY_G1_GPIO_LED_WLAN,
  40. .active_low = 1,
  41. },{
  42. .name = "omy:green:wan",
  43. .gpio = OMY_G1_GPIO_LED_WAN,
  44. .active_low = 1,
  45. }, {
  46. .name = "omy:green:lan",
  47. .gpio = OMY_G1_GPIO_LED_LAN,
  48. .active_low = 1,
  49. },
  50. };
  51. static struct gpio_keys_button omy_g1_gpio_keys[] __initdata = {
  52. {
  53. .desc = "Reset button",
  54. .type = EV_KEY,
  55. .code = KEY_RESTART,
  56. .debounce_interval = OMY_G1_KEYS_DEBOUNCE_INTERVAL,
  57. .gpio = OMY_G1_GPIO_BTN_RESET,
  58. .active_low = 1,
  59. }
  60. };
  61. static void __init omy_g1_setup(void)
  62. {
  63. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  64. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  65. ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  66. AR934X_GPIO_FUNC_CLK_OBS4_EN);
  67. ath79_register_m25p80(&omy_g1_flash_data);
  68. ath79_register_leds_gpio(-1, ARRAY_SIZE(omy_g1_leds_gpio),
  69. omy_g1_leds_gpio);
  70. ath79_register_gpio_keys_polled(1, OMY_G1_KEYS_POLL_INTERVAL,
  71. ARRAY_SIZE(omy_g1_gpio_keys),
  72. omy_g1_gpio_keys);
  73. ath79_gpio_output_select(OMY_G1_GPIO_USB_POWER,
  74. AR934X_GPIO_OUT_GPIO);
  75. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP);
  76. ath79_register_mdio(1, 0x0);
  77. ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
  78. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  79. ath79_switch_data.phy4_mii_en = 1;
  80. ath79_switch_data.phy_poll_mask = BIT(0);
  81. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  82. ath79_eth0_data.phy_mask = BIT(0);
  83. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  84. ath79_register_eth(0);
  85. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  86. ath79_register_eth(1);
  87. ath79_register_wmac(ee, mac);
  88. ath79_gpio_output_select(OMY_G1_GPIO_USB_POWER,
  89. AR934X_GPIO_OUT_GPIO);
  90. gpio_request_one(OMY_G1_GPIO_USB_POWER,
  91. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  92. "USB power");
  93. ath79_register_usb();
  94. }
  95. MIPS_MACHINE(ATH79_MACH_OMY_G1, "OMY-G1", "OMYlink OMY-G1",
  96. omy_g1_setup);