board-omap3evm.c 7.6 KB

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