board-omap3evm.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * linux/arch/arm/mach-omap2/board-omap3evm.c
  3. *
  4. * Copyright (C) 2008 Texas Instruments
  5. *
  6. * Modified from mach-omap2/board-3430sdp.c
  7. *
  8. * Initial code: Syed Mohammed Khasim
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/err.h>
  19. #include <linux/clk.h>
  20. #include <linux/gpio.h>
  21. #include <linux/input.h>
  22. #include <linux/leds.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/ads7846.h>
  25. #include <linux/i2c/twl4030.h>
  26. #include <mach/hardware.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <mach/board.h>
  31. #include <mach/mux.h>
  32. #include <mach/usb.h>
  33. #include <mach/common.h>
  34. #include <mach/mcspi.h>
  35. #include <mach/keypad.h>
  36. #include "sdram-micron-mt46h32m32lf-6.h"
  37. #include "mmc-twl4030.h"
  38. #define OMAP3_EVM_TS_GPIO 175
  39. #define OMAP3EVM_ETHR_START 0x2c000000
  40. #define OMAP3EVM_ETHR_SIZE 1024
  41. #define OMAP3EVM_ETHR_GPIO_IRQ 176
  42. #define OMAP3EVM_SMC911X_CS 5
  43. static struct resource omap3evm_smc911x_resources[] = {
  44. [0] = {
  45. .start = OMAP3EVM_ETHR_START,
  46. .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
  47. .flags = IORESOURCE_MEM,
  48. },
  49. [1] = {
  50. .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  51. .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  52. .flags = IORESOURCE_IRQ,
  53. },
  54. };
  55. static struct platform_device omap3evm_smc911x_device = {
  56. .name = "smc911x",
  57. .id = -1,
  58. .num_resources = ARRAY_SIZE(omap3evm_smc911x_resources),
  59. .resource = &omap3evm_smc911x_resources[0],
  60. };
  61. static inline void __init omap3evm_init_smc911x(void)
  62. {
  63. int eth_cs;
  64. struct clk *l3ck;
  65. unsigned int rate;
  66. eth_cs = OMAP3EVM_SMC911X_CS;
  67. l3ck = clk_get(NULL, "l3_ck");
  68. if (IS_ERR(l3ck))
  69. rate = 100000000;
  70. else
  71. rate = clk_get_rate(l3ck);
  72. if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMC911x irq") < 0) {
  73. printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
  74. OMAP3EVM_ETHR_GPIO_IRQ);
  75. return;
  76. }
  77. gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
  78. }
  79. static struct omap_uart_config omap3_evm_uart_config __initdata = {
  80. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  81. };
  82. static struct twl4030_hsmmc_info mmc[] = {
  83. {
  84. .mmc = 1,
  85. .wires = 4,
  86. .gpio_cd = -EINVAL,
  87. .gpio_wp = 63,
  88. },
  89. {} /* Terminator */
  90. };
  91. static struct gpio_led gpio_leds[] = {
  92. {
  93. .name = "omap3evm::ledb",
  94. /* normally not visible (board underside) */
  95. .default_trigger = "default-on",
  96. .gpio = -EINVAL, /* gets replaced */
  97. .active_low = true,
  98. },
  99. };
  100. static struct gpio_led_platform_data gpio_led_info = {
  101. .leds = gpio_leds,
  102. .num_leds = ARRAY_SIZE(gpio_leds),
  103. };
  104. static struct platform_device leds_gpio = {
  105. .name = "leds-gpio",
  106. .id = -1,
  107. .dev = {
  108. .platform_data = &gpio_led_info,
  109. },
  110. };
  111. static int omap3evm_twl_gpio_setup(struct device *dev,
  112. unsigned gpio, unsigned ngpio)
  113. {
  114. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  115. omap_cfg_reg(L8_34XX_GPIO63);
  116. mmc[0].gpio_cd = gpio + 0;
  117. twl4030_mmc_init(mmc);
  118. /*
  119. * Most GPIOs are for USB OTG. Some are mostly sent to
  120. * the P2 connector; notably LEDA for the LCD backlight.
  121. */
  122. /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
  123. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  124. platform_device_register(&leds_gpio);
  125. return 0;
  126. }
  127. static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
  128. .gpio_base = OMAP_MAX_GPIO_LINES,
  129. .irq_base = TWL4030_GPIO_IRQ_BASE,
  130. .irq_end = TWL4030_GPIO_IRQ_END,
  131. .use_leds = true,
  132. .setup = omap3evm_twl_gpio_setup,
  133. };
  134. static struct twl4030_usb_data omap3evm_usb_data = {
  135. .usb_mode = T2_USB_MODE_ULPI,
  136. };
  137. static int omap3evm_keymap[] = {
  138. KEY(0, 0, KEY_LEFT),
  139. KEY(0, 1, KEY_RIGHT),
  140. KEY(0, 2, KEY_A),
  141. KEY(0, 3, KEY_B),
  142. KEY(1, 0, KEY_DOWN),
  143. KEY(1, 1, KEY_UP),
  144. KEY(1, 2, KEY_E),
  145. KEY(1, 3, KEY_F),
  146. KEY(2, 0, KEY_ENTER),
  147. KEY(2, 1, KEY_I),
  148. KEY(2, 2, KEY_J),
  149. KEY(2, 3, KEY_K),
  150. KEY(3, 0, KEY_M),
  151. KEY(3, 1, KEY_N),
  152. KEY(3, 2, KEY_O),
  153. KEY(3, 3, KEY_P)
  154. };
  155. static struct twl4030_keypad_data omap3evm_kp_data = {
  156. .rows = 4,
  157. .cols = 4,
  158. .keymap = omap3evm_keymap,
  159. .keymapsize = ARRAY_SIZE(omap3evm_keymap),
  160. .rep = 1,
  161. };
  162. static struct twl4030_madc_platform_data omap3evm_madc_data = {
  163. .irq_line = 1,
  164. };
  165. static struct twl4030_platform_data omap3evm_twldata = {
  166. .irq_base = TWL4030_IRQ_BASE,
  167. .irq_end = TWL4030_IRQ_END,
  168. /* platform_data for children goes here */
  169. .keypad = &omap3evm_kp_data,
  170. .madc = &omap3evm_madc_data,
  171. .usb = &omap3evm_usb_data,
  172. .gpio = &omap3evm_gpio_data,
  173. };
  174. static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
  175. {
  176. I2C_BOARD_INFO("twl4030", 0x48),
  177. .flags = I2C_CLIENT_WAKE,
  178. .irq = INT_34XX_SYS_NIRQ,
  179. .platform_data = &omap3evm_twldata,
  180. },
  181. };
  182. static int __init omap3_evm_i2c_init(void)
  183. {
  184. omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
  185. ARRAY_SIZE(omap3evm_i2c_boardinfo));
  186. omap_register_i2c_bus(2, 400, NULL, 0);
  187. omap_register_i2c_bus(3, 400, NULL, 0);
  188. return 0;
  189. }
  190. static struct platform_device omap3_evm_lcd_device = {
  191. .name = "omap3evm_lcd",
  192. .id = -1,
  193. };
  194. static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
  195. .ctrl_name = "internal",
  196. };
  197. static void ads7846_dev_init(void)
  198. {
  199. if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
  200. printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
  201. gpio_direction_input(OMAP3_EVM_TS_GPIO);
  202. omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
  203. omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
  204. }
  205. static int ads7846_get_pendown_state(void)
  206. {
  207. return !gpio_get_value(OMAP3_EVM_TS_GPIO);
  208. }
  209. struct ads7846_platform_data ads7846_config = {
  210. .x_max = 0x0fff,
  211. .y_max = 0x0fff,
  212. .x_plate_ohms = 180,
  213. .pressure_max = 255,
  214. .debounce_max = 10,
  215. .debounce_tol = 3,
  216. .debounce_rep = 1,
  217. .get_pendown_state = ads7846_get_pendown_state,
  218. .keep_vref_on = 1,
  219. .settle_delay_usecs = 150,
  220. };
  221. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  222. .turbo_mode = 0,
  223. .single_channel = 1, /* 0: slave, 1: master */
  224. };
  225. struct spi_board_info omap3evm_spi_board_info[] = {
  226. [0] = {
  227. .modalias = "ads7846",
  228. .bus_num = 1,
  229. .chip_select = 0,
  230. .max_speed_hz = 1500000,
  231. .controller_data = &ads7846_mcspi_config,
  232. .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
  233. .platform_data = &ads7846_config,
  234. },
  235. };
  236. static void __init omap3_evm_init_irq(void)
  237. {
  238. omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
  239. omap_init_irq();
  240. omap_gpio_init();
  241. omap3evm_init_smc911x();
  242. }
  243. static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
  244. { OMAP_TAG_UART, &omap3_evm_uart_config },
  245. { OMAP_TAG_LCD, &omap3_evm_lcd_config },
  246. };
  247. static struct platform_device *omap3_evm_devices[] __initdata = {
  248. &omap3_evm_lcd_device,
  249. &omap3evm_smc911x_device,
  250. };
  251. static void __init omap3_evm_init(void)
  252. {
  253. omap3_evm_i2c_init();
  254. platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
  255. omap_board_config = omap3_evm_config;
  256. omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
  257. spi_register_board_info(omap3evm_spi_board_info,
  258. ARRAY_SIZE(omap3evm_spi_board_info));
  259. omap_serial_init();
  260. usb_musb_init();
  261. ads7846_dev_init();
  262. }
  263. static void __init omap3_evm_map_io(void)
  264. {
  265. omap2_set_globals_343x();
  266. omap2_map_common_io();
  267. }
  268. MACHINE_START(OMAP3EVM, "OMAP3 EVM")
  269. /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
  270. .phys_io = 0x48000000,
  271. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  272. .boot_params = 0x80000100,
  273. .map_io = omap3_evm_map_io,
  274. .init_irq = omap3_evm_init_irq,
  275. .init_machine = omap3_evm_init,
  276. .timer = &omap_timer,
  277. MACHINE_END