mach-z1.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Cisco Meraki Z1 board support
  3. *
  4. * Copyright (C) 2016 Chris Blake <chrisrblake93@gmail.com>
  5. * Copyright (C) 2016 Christian Lamparter <chunkeey@googlemail.com>
  6. *
  7. * Based on Cisco Meraki GPL Release r23-20150601 Z1 Device Config
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/ath9k_platform.h>
  15. #include <linux/ar8216_platform.h>
  16. #include <linux/platform/ar934x_nfc.h>
  17. #include <asm/mach-ath79/ath79.h>
  18. #include <asm/mach-ath79/ar71xx_regs.h>
  19. #include <linux/leds-nu801.h>
  20. #include <linux/firmware.h>
  21. #include <linux/pci.h>
  22. #include "common.h"
  23. #include "dev-eth.h"
  24. #include "dev-gpio-buttons.h"
  25. #include "dev-leds-gpio.h"
  26. #include "dev-nfc.h"
  27. #include "dev-usb.h"
  28. #include "dev-wmac.h"
  29. #include "dev-ap9x-pci.h"
  30. #include "machtypes.h"
  31. #define Z1_GPIO_LED_POWER_ORANGE 17
  32. #define Z1_GPIO_NU801_CKI 14
  33. #define Z1_GPIO_NU801_SDI 15
  34. #define Z1_GPIO_XLNA0 18
  35. #define Z1_GPIO_XLNA1 19
  36. #define Z1_GPIO_BTN_RESET 12
  37. #define Z1_KEYS_POLL_INTERVAL 20 /* msecs */
  38. #define Z1_KEYS_DEBOUNCE_INTERVAL (3 * Z1_KEYS_POLL_INTERVAL)
  39. #define Z1_ETH_SWITCH_PHY 0
  40. static struct gpio_led Z1_leds_gpio[] __initdata = {
  41. {
  42. .name = "z1:orange:power",
  43. .gpio = Z1_GPIO_LED_POWER_ORANGE,
  44. .active_low = 1,
  45. },
  46. };
  47. static struct gpio_keys_button Z1_gpio_keys[] __initdata = {
  48. {
  49. .desc = "reset",
  50. .type = EV_KEY,
  51. .code = KEY_RESTART,
  52. .debounce_interval = Z1_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = Z1_GPIO_BTN_RESET,
  54. .active_low = 1,
  55. },
  56. };
  57. static struct led_nu801_template tricolor_led_template = {
  58. .device_name = "z1",
  59. .name = "tricolor",
  60. .num_leds = 1,
  61. .cki = Z1_GPIO_NU801_CKI,
  62. .sdi = Z1_GPIO_NU801_SDI,
  63. .lei = -1,
  64. .ndelay = 500,
  65. .init_brightness = {
  66. LED_OFF,
  67. LED_OFF,
  68. LED_OFF,
  69. },
  70. .default_trigger = "none",
  71. };
  72. static struct led_nu801_platform_data tricolor_led_data = {
  73. .num_controllers = 1,
  74. .template = &tricolor_led_template,
  75. };
  76. static struct platform_device tricolor_leds = {
  77. .name = "leds-nu801",
  78. .id = -1,
  79. .dev.platform_data = &tricolor_led_data,
  80. };
  81. static struct ar8327_pad_cfg z1_ar8327_pad0_cfg = {
  82. .mode = AR8327_PAD_MAC_RGMII,
  83. .txclk_delay_en = true,
  84. .rxclk_delay_en = true,
  85. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  86. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  87. };
  88. static struct ar8327_platform_data z1_ar8327_data = {
  89. .pad0_cfg = &z1_ar8327_pad0_cfg,
  90. .port0_cfg = {
  91. .force_link = 1,
  92. .speed = AR8327_PORT_SPEED_1000,
  93. .duplex = 1,
  94. .txpause = 1,
  95. .rxpause = 1,
  96. },
  97. };
  98. static struct mdio_board_info z1_mdio0_info[] = {
  99. {
  100. .bus_id = "ag71xx-mdio.0",
  101. .phy_addr = Z1_ETH_SWITCH_PHY,
  102. .platform_data = &z1_ar8327_data,
  103. },
  104. };
  105. static void __init z1_setup(void)
  106. {
  107. /* NAND */
  108. ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_SOFT_BCH);
  109. ath79_register_nfc();
  110. /* Eth Config */
  111. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  112. AR934X_ETH_CFG_SW_ONLY_MODE);
  113. /* MDIO Interface */
  114. ath79_register_mdio(1, 0x0);
  115. ath79_register_mdio(0, 0x0);
  116. mdiobus_register_board_info(z1_mdio0_info,
  117. ARRAY_SIZE(z1_mdio0_info));
  118. /* GMAC0 is connected to an AR8327 switch */
  119. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  120. ath79_eth0_data.phy_mask = BIT(Z1_ETH_SWITCH_PHY);
  121. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  122. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  123. ath79_register_eth(0);
  124. /* XLNA */
  125. ath79_wmac_set_ext_lna_gpio(0, Z1_GPIO_XLNA0);
  126. ath79_wmac_set_ext_lna_gpio(1, Z1_GPIO_XLNA1);
  127. /* LEDs and Buttons */
  128. platform_device_register(&tricolor_leds);
  129. ath79_register_leds_gpio(-1, ARRAY_SIZE(Z1_leds_gpio),
  130. Z1_leds_gpio);
  131. ath79_register_gpio_keys_polled(-1, Z1_KEYS_POLL_INTERVAL,
  132. ARRAY_SIZE(Z1_gpio_keys),
  133. Z1_gpio_keys);
  134. /* USB */
  135. ath79_register_usb();
  136. /* Wireless */
  137. ath79_register_wmac_simple();
  138. ap91_pci_init_simple();
  139. }
  140. MIPS_MACHINE(ATH79_MACH_Z1, "Z1", "Meraki Z1", z1_setup);