board-pcontrol-g20.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*
  2. * Copyright (C) 2010 Christian Glindkamp <christian.glindkamp@taskit.de>
  3. * taskit GmbH
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. /*
  20. * copied and adjusted from board-stamp9g20.c
  21. * by Peter Gsellmann <pgsellmann@portner-elektronik.at>
  22. */
  23. #include <linux/mm.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/gpio.h>
  26. #include <linux/w1-gpio.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <mach/board.h>
  30. #include <mach/at91sam9_smc.h>
  31. #include "sam9_smc.h"
  32. #include "generic.h"
  33. static void __init pcontrol_g20_map_io(void)
  34. {
  35. /* Initialize processor: 18.432 MHz crystal */
  36. at91sam9260_initialize(18432000);
  37. /* DGBU on ttyS0. (Rx, Tx) only TTL -> JTAG connector X7 17,19 ) */
  38. at91_register_uart(0, 0, 0);
  39. /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */
  40. at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS
  41. | ATMEL_UART_RTS);
  42. /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485 X5 */
  43. at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS
  44. | ATMEL_UART_RTS);
  45. /* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */
  46. at91_register_uart(AT91SAM9260_ID_US4, 3, 0);
  47. /* set serial console to ttyS0 (ie, DBGU) */
  48. at91_set_serial_console(0);
  49. }
  50. static void __init init_irq(void)
  51. {
  52. at91sam9260_init_interrupts(NULL);
  53. }
  54. /*
  55. * NAND flash 512MiB 1,8V 8-bit, sector size 128 KiB
  56. */
  57. static struct atmel_nand_data __initdata nand_data = {
  58. .ale = 21,
  59. .cle = 22,
  60. .rdy_pin = AT91_PIN_PC13,
  61. .enable_pin = AT91_PIN_PC14,
  62. };
  63. /*
  64. * Bus timings; unit = 7.57ns
  65. */
  66. static struct sam9_smc_config __initdata nand_smc_config = {
  67. .ncs_read_setup = 0,
  68. .nrd_setup = 2,
  69. .ncs_write_setup = 0,
  70. .nwe_setup = 2,
  71. .ncs_read_pulse = 4,
  72. .nrd_pulse = 4,
  73. .ncs_write_pulse = 4,
  74. .nwe_pulse = 4,
  75. .read_cycle = 7,
  76. .write_cycle = 7,
  77. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  78. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
  79. .tdf_cycles = 3,
  80. };
  81. static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {
  82. .ncs_read_setup = 16,
  83. .nrd_setup = 18,
  84. .ncs_write_setup = 16,
  85. .nwe_setup = 18,
  86. .ncs_read_pulse = 63,
  87. .nrd_pulse = 55,
  88. .ncs_write_pulse = 63,
  89. .nwe_pulse = 55,
  90. .read_cycle = 127,
  91. .write_cycle = 127,
  92. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  93. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT
  94. | AT91_SMC_DBW_8 | AT91_SMC_PS_4
  95. | AT91_SMC_TDFMODE,
  96. .tdf_cycles = 3,
  97. }, {
  98. .ncs_read_setup = 0,
  99. .nrd_setup = 0,
  100. .ncs_write_setup = 0,
  101. .nwe_setup = 1,
  102. .ncs_read_pulse = 8,
  103. .nrd_pulse = 8,
  104. .ncs_write_pulse = 5,
  105. .nwe_pulse = 4,
  106. .read_cycle = 8,
  107. .write_cycle = 7,
  108. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
  109. | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT
  110. | AT91_SMC_DBW_16 | AT91_SMC_PS_8
  111. | AT91_SMC_TDFMODE,
  112. .tdf_cycles = 1,
  113. } };
  114. static void __init add_device_nand(void)
  115. {
  116. /* configure chip-select 3 (NAND) */
  117. sam9_smc_configure(3, &nand_smc_config);
  118. at91_add_device_nand(&nand_data);
  119. }
  120. static void __init add_device_pcontrol(void)
  121. {
  122. /* configure chip-select 4 (IO compatible to 8051 X4 ) */
  123. sam9_smc_configure(4, &pcontrol_smc_config[0]);
  124. /* configure chip-select 7 (FerroRAM 256KiBx16bit MR2A16A D4 ) */
  125. sam9_smc_configure(7, &pcontrol_smc_config[1]);
  126. }
  127. /*
  128. * MCI (SD/MMC)
  129. * det_pin, wp_pin and vcc_pin are not connected
  130. */
  131. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  132. static struct mci_platform_data __initdata mmc_data = {
  133. .slot[0] = {
  134. .bus_width = 4,
  135. },
  136. };
  137. #else
  138. static struct at91_mmc_data __initdata mmc_data = {
  139. .wire4 = 1,
  140. };
  141. #endif
  142. /*
  143. * USB Host port
  144. */
  145. static struct at91_usbh_data __initdata usbh_data = {
  146. .ports = 2,
  147. };
  148. /*
  149. * USB Device port
  150. */
  151. static struct at91_udc_data __initdata pcontrol_g20_udc_data = {
  152. .vbus_pin = AT91_PIN_PA22, /* Detect +5V bus voltage */
  153. .pullup_pin = AT91_PIN_PA4, /* K-state, active low */
  154. };
  155. /*
  156. * MACB Ethernet device
  157. */
  158. static struct at91_eth_data __initdata macb_data = {
  159. .phy_irq_pin = AT91_PIN_PA28,
  160. .is_rmii = 1,
  161. };
  162. /*
  163. * I2C devices: eeprom and phy/switch
  164. */
  165. static struct i2c_board_info __initdata pcontrol_g20_i2c_devices[] = {
  166. { /* D7 address width=2, 8KiB */
  167. I2C_BOARD_INFO("24c64", 0x50)
  168. }, { /* D8 address width=1, 1 byte has 32 bits! */
  169. I2C_BOARD_INFO("lan9303", 0x0a)
  170. }, };
  171. /*
  172. * LEDs
  173. */
  174. static struct gpio_led pcontrol_g20_leds[] = {
  175. {
  176. .name = "LED1", /* red H5 */
  177. .gpio = AT91_PIN_PB18,
  178. .active_low = 1,
  179. .default_trigger = "none", /* supervisor */
  180. }, {
  181. .name = "LED2", /* yellow H7 */
  182. .gpio = AT91_PIN_PB19,
  183. .active_low = 1,
  184. .default_trigger = "mmc0", /* SD-card activity */
  185. }, {
  186. .name = "LED3", /* green H2 */
  187. .gpio = AT91_PIN_PB20,
  188. .active_low = 1,
  189. .default_trigger = "heartbeat", /* blinky */
  190. }, {
  191. .name = "LED4", /* red H3 */
  192. .gpio = AT91_PIN_PC6,
  193. .active_low = 1,
  194. .default_trigger = "none", /* connection lost */
  195. }, {
  196. .name = "LED5", /* yellow H6 */
  197. .gpio = AT91_PIN_PC7,
  198. .active_low = 1,
  199. .default_trigger = "none", /* unsent data */
  200. }, {
  201. .name = "LED6", /* green H1 */
  202. .gpio = AT91_PIN_PC9,
  203. .active_low = 1,
  204. .default_trigger = "none", /* snafu */
  205. }
  206. };
  207. /*
  208. * SPI devices
  209. */
  210. static struct spi_board_info pcontrol_g20_spi_devices[] = {
  211. {
  212. .modalias = "spidev", /* HMI port X4 */
  213. .chip_select = 1,
  214. .max_speed_hz = 50 * 1000 * 1000,
  215. .bus_num = 0,
  216. }, {
  217. .modalias = "spidev", /* piggyback A2 */
  218. .chip_select = 0,
  219. .max_speed_hz = 50 * 1000 * 1000,
  220. .bus_num = 1,
  221. },
  222. };
  223. /*
  224. * Dallas 1-Wire DS2431
  225. */
  226. static struct w1_gpio_platform_data w1_gpio_pdata = {
  227. .pin = AT91_PIN_PA29,
  228. .is_open_drain = 1,
  229. };
  230. static struct platform_device w1_device = {
  231. .name = "w1-gpio",
  232. .id = -1,
  233. .dev.platform_data = &w1_gpio_pdata,
  234. };
  235. static void add_wire1(void)
  236. {
  237. at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
  238. at91_set_multi_drive(w1_gpio_pdata.pin, 1);
  239. platform_device_register(&w1_device);
  240. }
  241. static void __init pcontrol_g20_board_init(void)
  242. {
  243. at91_add_device_serial();
  244. add_device_nand();
  245. #if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
  246. at91_add_device_mci(0, &mmc_data);
  247. #else
  248. at91_add_device_mmc(0, &mmc_data);
  249. #endif
  250. at91_add_device_usbh(&usbh_data);
  251. at91_add_device_eth(&macb_data);
  252. at91_add_device_i2c(pcontrol_g20_i2c_devices,
  253. ARRAY_SIZE(pcontrol_g20_i2c_devices));
  254. add_wire1();
  255. add_device_pcontrol();
  256. at91_add_device_spi(pcontrol_g20_spi_devices,
  257. ARRAY_SIZE(pcontrol_g20_spi_devices));
  258. at91_add_device_udc(&pcontrol_g20_udc_data);
  259. at91_gpio_leds(pcontrol_g20_leds,
  260. ARRAY_SIZE(pcontrol_g20_leds));
  261. /* piggyback A2 */
  262. at91_set_gpio_output(AT91_PIN_PB31, 1);
  263. }
  264. MACHINE_START(PCONTROL_G20, "PControl G20")
  265. /* Maintainer: pgsellmann@portner-elektronik.at */
  266. .boot_params = AT91_SDRAM_BASE + 0x100,
  267. .timer = &at91sam926x_timer,
  268. .map_io = pcontrol_g20_map_io,
  269. .init_irq = init_irq,
  270. .init_machine = pcontrol_g20_board_init,
  271. MACHINE_END