1
0

mach-weio.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /**
  2. * WEIO Web Of Things Platform
  3. *
  4. * Copyright (C) 2013 Drasko DRASKOVIC and Uros PETREVSKI
  5. *
  6. * ## ## ######## #### #######
  7. * ## ## ## ## ## ## ##
  8. * ## ## ## ## ## ## ##
  9. * ## ## ## ###### ## ## ##
  10. * ## ## ## ## ## ## ##
  11. * ## ## ## ## ## ## ##
  12. * ### ### ######## #### #######
  13. *
  14. * Web Of Things Platform
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License
  18. * as published by the Free Software Foundation; either version 2
  19. * of the License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. *
  30. * Authors :
  31. * Drasko DRASKOVIC <drasko.draskovic@gmail.com>
  32. * Uros PETREVSKI <uros@nodesign.net>
  33. */
  34. #include <asm/mach-ath79/ath79.h>
  35. #include <asm/mach-ath79/ar71xx_regs.h>
  36. #include <linux/i2c-gpio.h>
  37. #include <linux/platform_device.h>
  38. #include "common.h"
  39. #include "dev-eth.h"
  40. #include "dev-gpio-buttons.h"
  41. #include "dev-leds-gpio.h"
  42. #include "dev-m25p80.h"
  43. #include "dev-spi.h"
  44. #include "dev-usb.h"
  45. #include "dev-wmac.h"
  46. #include "machtypes.h"
  47. #define WEIO_GPIO_LED_STA 1
  48. #define WEIO_GPIO_LED_AP 16
  49. #define WEIO_GPIO_BTN_AP 20
  50. #define WEIO_GPIO_BTN_RESET 23
  51. #define WEIO_KEYS_POLL_INTERVAL 20 /* msecs */
  52. #define WEIO_KEYS_DEBOUNCE_INTERVAL (3 * WEIO_KEYS_POLL_INTERVAL)
  53. #define WEIO_MAC0_OFFSET 0x0000
  54. #define WEIO_MAC1_OFFSET 0x0006
  55. #define WEIO_CALDATA_OFFSET 0x1000
  56. #define WEIO_WMAC_MAC_OFFSET 0x1002
  57. static struct gpio_led weio_leds_gpio[] __initdata = {
  58. {
  59. .name = "weio:green:sta",
  60. .gpio = WEIO_GPIO_LED_STA,
  61. .active_low = 1,
  62. .default_state = LEDS_GPIO_DEFSTATE_ON,
  63. },
  64. {
  65. .name = "weio:green:ap",
  66. .gpio = WEIO_GPIO_LED_AP,
  67. .active_low = 1,
  68. .default_state = LEDS_GPIO_DEFSTATE_ON,
  69. }
  70. };
  71. static struct gpio_keys_button weio_gpio_keys[] __initdata = {
  72. {
  73. .desc = "ap button",
  74. .type = EV_KEY,
  75. .code = BTN_0,
  76. .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
  77. .gpio = WEIO_GPIO_BTN_AP,
  78. .active_low = 1,
  79. },
  80. {
  81. .desc = "soft-reset button",
  82. .type = EV_KEY,
  83. .code = BTN_1,
  84. .debounce_interval = WEIO_KEYS_DEBOUNCE_INTERVAL,
  85. .gpio = WEIO_GPIO_BTN_RESET,
  86. .active_low = 1,
  87. }
  88. };
  89. static struct i2c_gpio_platform_data weio_i2c_gpio_data = {
  90. .sda_pin = 18,
  91. .scl_pin = 19,
  92. };
  93. static struct platform_device weio_i2c_gpio = {
  94. .name = "i2c-gpio",
  95. .id = 0,
  96. .dev = {
  97. .platform_data = &weio_i2c_gpio_data,
  98. },
  99. };
  100. static void __init weio_common_setup(void)
  101. {
  102. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  103. ath79_register_m25p80(NULL);
  104. ath79_register_wmac(art + WEIO_CALDATA_OFFSET, art + WEIO_WMAC_MAC_OFFSET);
  105. }
  106. static void __init weio_setup(void)
  107. {
  108. weio_common_setup();
  109. ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  110. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  111. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  112. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  113. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  114. platform_device_register(&weio_i2c_gpio);
  115. ath79_register_leds_gpio(-1, ARRAY_SIZE(weio_leds_gpio),
  116. weio_leds_gpio);
  117. ath79_register_gpio_keys_polled(-1, WEIO_KEYS_POLL_INTERVAL,
  118. ARRAY_SIZE(weio_gpio_keys),
  119. weio_gpio_keys);
  120. ath79_register_usb();
  121. }
  122. MIPS_MACHINE(ATH79_MACH_WEIO, "WEIO", "WeIO board", weio_setup);