board-foxg20.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * Copyright (C) 2005 SAN People
  3. * Copyright (C) 2008 Atmel
  4. * Copyright (C) 2010 Lee McLoughlin - lee@lmmrtech.com
  5. * Copyright (C) 2010 Sergio Tanzilli - tanzilli@acmesystems.it
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/types.h>
  22. #include <linux/init.h>
  23. #include <linux/mm.h>
  24. #include <linux/module.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/spi/at73c213.h>
  28. #include <linux/gpio.h>
  29. #include <linux/gpio_keys.h>
  30. #include <linux/input.h>
  31. #include <linux/clk.h>
  32. #include <linux/w1-gpio.h>
  33. #include <mach/hardware.h>
  34. #include <asm/setup.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/irq.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/mach/irq.h>
  40. #include <mach/at91sam9_smc.h>
  41. #include "at91_aic.h"
  42. #include "board.h"
  43. #include "sam9_smc.h"
  44. #include "generic.h"
  45. #include "gpio.h"
  46. /*
  47. * The FOX Board G20 hardware comes as the "Netus G20" board with
  48. * just the cpu, ram, dataflash and two header connectors.
  49. * This is plugged into the FOX Board which provides the ethernet,
  50. * usb, rtc, leds, switch, ...
  51. *
  52. * For more info visit: http://www.acmesystems.it/foxg20
  53. */
  54. static void __init foxg20_init_early(void)
  55. {
  56. /* Initialize processor: 18.432 MHz crystal */
  57. at91_initialize(18432000);
  58. }
  59. /*
  60. * USB Host port
  61. */
  62. static struct at91_usbh_data __initdata foxg20_usbh_data = {
  63. .ports = 2,
  64. .vbus_pin = {-EINVAL, -EINVAL},
  65. .overcurrent_pin= {-EINVAL, -EINVAL},
  66. };
  67. /*
  68. * USB Device port
  69. */
  70. static struct at91_udc_data __initdata foxg20_udc_data = {
  71. .vbus_pin = AT91_PIN_PC6,
  72. .pullup_pin = -EINVAL, /* pull-up driven by UDC */
  73. };
  74. /*
  75. * SPI devices.
  76. */
  77. static struct spi_board_info foxg20_spi_devices[] = {
  78. #if !IS_ENABLED(CONFIG_MMC_ATMELMCI)
  79. {
  80. .modalias = "mtd_dataflash",
  81. .chip_select = 1,
  82. .max_speed_hz = 15 * 1000 * 1000,
  83. .bus_num = 0,
  84. },
  85. #endif
  86. };
  87. /*
  88. * MACB Ethernet device
  89. */
  90. static struct macb_platform_data __initdata foxg20_macb_data = {
  91. .phy_irq_pin = AT91_PIN_PA7,
  92. .is_rmii = 1,
  93. };
  94. /*
  95. * MCI (SD/MMC)
  96. * det_pin, wp_pin and vcc_pin are not connected
  97. */
  98. static struct mci_platform_data __initdata foxg20_mci0_data = {
  99. .slot[1] = {
  100. .bus_width = 4,
  101. .detect_pin = -EINVAL,
  102. .wp_pin = -EINVAL,
  103. },
  104. };
  105. /*
  106. * LEDs
  107. */
  108. static struct gpio_led foxg20_leds[] = {
  109. { /* user led, red */
  110. .name = "user_led",
  111. .gpio = AT91_PIN_PC7,
  112. .active_low = 0,
  113. .default_trigger = "heartbeat",
  114. },
  115. };
  116. /*
  117. * GPIO Buttons
  118. */
  119. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  120. static struct gpio_keys_button foxg20_buttons[] = {
  121. {
  122. .gpio = AT91_PIN_PC4,
  123. .code = BTN_1,
  124. .desc = "Button 1",
  125. .active_low = 1,
  126. .wakeup = 1,
  127. },
  128. };
  129. static struct gpio_keys_platform_data foxg20_button_data = {
  130. .buttons = foxg20_buttons,
  131. .nbuttons = ARRAY_SIZE(foxg20_buttons),
  132. };
  133. static struct platform_device foxg20_button_device = {
  134. .name = "gpio-keys",
  135. .id = -1,
  136. .num_resources = 0,
  137. .dev = {
  138. .platform_data = &foxg20_button_data,
  139. }
  140. };
  141. static void __init foxg20_add_device_buttons(void)
  142. {
  143. at91_set_gpio_input(AT91_PIN_PC4, 1); /* btn1 */
  144. at91_set_deglitch(AT91_PIN_PC4, 1);
  145. platform_device_register(&foxg20_button_device);
  146. }
  147. #else
  148. static void __init foxg20_add_device_buttons(void) {}
  149. #endif
  150. #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
  151. static struct w1_gpio_platform_data w1_gpio_pdata = {
  152. /* If you choose to use a pin other than PB16 it needs to be 3.3V */
  153. .pin = AT91_PIN_PB16,
  154. .is_open_drain = 1,
  155. .ext_pullup_enable_pin = -EINVAL,
  156. };
  157. static struct platform_device w1_device = {
  158. .name = "w1-gpio",
  159. .id = -1,
  160. .dev.platform_data = &w1_gpio_pdata,
  161. };
  162. static void __init at91_add_device_w1(void)
  163. {
  164. at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
  165. at91_set_multi_drive(w1_gpio_pdata.pin, 1);
  166. platform_device_register(&w1_device);
  167. }
  168. #endif
  169. static struct i2c_board_info __initdata foxg20_i2c_devices[] = {
  170. {
  171. I2C_BOARD_INFO("24c512", 0x50),
  172. },
  173. };
  174. static void __init foxg20_board_init(void)
  175. {
  176. /* Serial */
  177. /* DBGU on ttyS0. (Rx & Tx only) */
  178. at91_register_uart(0, 0, 0);
  179. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
  180. at91_register_uart(AT91SAM9260_ID_US0, 1,
  181. ATMEL_UART_CTS
  182. | ATMEL_UART_RTS
  183. | ATMEL_UART_DTR
  184. | ATMEL_UART_DSR
  185. | ATMEL_UART_DCD
  186. | ATMEL_UART_RI);
  187. /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
  188. at91_register_uart(AT91SAM9260_ID_US1, 2,
  189. ATMEL_UART_CTS
  190. | ATMEL_UART_RTS);
  191. /* USART2 on ttyS3. (Rx & Tx only) */
  192. at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
  193. /* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */
  194. at91_register_uart(AT91SAM9260_ID_US3, 4,
  195. ATMEL_UART_CTS
  196. | ATMEL_UART_RTS);
  197. /* USART4 on ttyS5. (Rx & Tx only) */
  198. at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
  199. /* USART5 on ttyS6. (Rx & Tx only) */
  200. at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
  201. /* Set the internal pull-up resistor on DRXD */
  202. at91_set_A_periph(AT91_PIN_PB14, 1);
  203. at91_add_device_serial();
  204. /* USB Host */
  205. at91_add_device_usbh(&foxg20_usbh_data);
  206. /* USB Device */
  207. at91_add_device_udc(&foxg20_udc_data);
  208. /* SPI */
  209. at91_add_device_spi(foxg20_spi_devices, ARRAY_SIZE(foxg20_spi_devices));
  210. /* Ethernet */
  211. at91_add_device_eth(&foxg20_macb_data);
  212. /* MMC */
  213. at91_add_device_mci(0, &foxg20_mci0_data);
  214. /* I2C */
  215. at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices));
  216. /* LEDs */
  217. at91_gpio_leds(foxg20_leds, ARRAY_SIZE(foxg20_leds));
  218. /* Push Buttons */
  219. foxg20_add_device_buttons();
  220. #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
  221. at91_add_device_w1();
  222. #endif
  223. }
  224. MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20")
  225. /* Maintainer: Sergio Tanzilli */
  226. .init_time = at91sam926x_pit_init,
  227. .map_io = at91_map_io,
  228. .handle_irq = at91_aic_handle_irq,
  229. .init_early = foxg20_init_early,
  230. .init_irq = at91_init_irq_default,
  231. .init_machine = foxg20_board_init,
  232. MACHINE_END