board-omap3evm.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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/interrupt.h>
  25. #include <linux/spi/spi.h>
  26. #include <linux/spi/ads7846.h>
  27. #include <linux/i2c/twl.h>
  28. #include <linux/usb/otg.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/regulator/machine.h>
  31. #include <mach/hardware.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <plat/board.h>
  36. #include <plat/usb.h>
  37. #include <plat/common.h>
  38. #include <plat/mcspi.h>
  39. #include <plat/display.h>
  40. #include "mux.h"
  41. #include "sdram-micron-mt46h32m32lf-6.h"
  42. #include "hsmmc.h"
  43. #define OMAP3_EVM_TS_GPIO 175
  44. #define OMAP3_EVM_EHCI_VBUS 22
  45. #define OMAP3_EVM_EHCI_SELECT 61
  46. #define OMAP3EVM_ETHR_START 0x2c000000
  47. #define OMAP3EVM_ETHR_SIZE 1024
  48. #define OMAP3EVM_ETHR_ID_REV 0x50
  49. #define OMAP3EVM_ETHR_GPIO_IRQ 176
  50. #define OMAP3EVM_SMSC911X_CS 5
  51. static u8 omap3_evm_version;
  52. u8 get_omap3_evm_rev(void)
  53. {
  54. return omap3_evm_version;
  55. }
  56. EXPORT_SYMBOL(get_omap3_evm_rev);
  57. static void __init omap3_evm_get_revision(void)
  58. {
  59. void __iomem *ioaddr;
  60. unsigned int smsc_id;
  61. /* Ethernet PHY ID is stored at ID_REV register */
  62. ioaddr = ioremap_nocache(OMAP3EVM_ETHR_START, SZ_1K);
  63. if (!ioaddr)
  64. return;
  65. smsc_id = readl(ioaddr + OMAP3EVM_ETHR_ID_REV) & 0xFFFF0000;
  66. iounmap(ioaddr);
  67. switch (smsc_id) {
  68. /*SMSC9115 chipset*/
  69. case 0x01150000:
  70. omap3_evm_version = OMAP3EVM_BOARD_GEN_1;
  71. break;
  72. /*SMSC 9220 chipset*/
  73. case 0x92200000:
  74. default:
  75. omap3_evm_version = OMAP3EVM_BOARD_GEN_2;
  76. }
  77. }
  78. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  79. static struct resource omap3evm_smsc911x_resources[] = {
  80. [0] = {
  81. .start = OMAP3EVM_ETHR_START,
  82. .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
  83. .flags = IORESOURCE_MEM,
  84. },
  85. [1] = {
  86. .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  87. .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
  88. .flags = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW),
  89. },
  90. };
  91. static struct smsc911x_platform_config smsc911x_config = {
  92. .phy_interface = PHY_INTERFACE_MODE_MII,
  93. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  94. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  95. .flags = (SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS),
  96. };
  97. static struct platform_device omap3evm_smsc911x_device = {
  98. .name = "smsc911x",
  99. .id = -1,
  100. .num_resources = ARRAY_SIZE(omap3evm_smsc911x_resources),
  101. .resource = &omap3evm_smsc911x_resources[0],
  102. .dev = {
  103. .platform_data = &smsc911x_config,
  104. },
  105. };
  106. static inline void __init omap3evm_init_smsc911x(void)
  107. {
  108. int eth_cs;
  109. struct clk *l3ck;
  110. unsigned int rate;
  111. eth_cs = OMAP3EVM_SMSC911X_CS;
  112. l3ck = clk_get(NULL, "l3_ck");
  113. if (IS_ERR(l3ck))
  114. rate = 100000000;
  115. else
  116. rate = clk_get_rate(l3ck);
  117. if (gpio_request(OMAP3EVM_ETHR_GPIO_IRQ, "SMSC911x irq") < 0) {
  118. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  119. OMAP3EVM_ETHR_GPIO_IRQ);
  120. return;
  121. }
  122. gpio_direction_input(OMAP3EVM_ETHR_GPIO_IRQ);
  123. platform_device_register(&omap3evm_smsc911x_device);
  124. }
  125. #else
  126. static inline void __init omap3evm_init_smsc911x(void) { return; }
  127. #endif
  128. /*
  129. * OMAP3EVM LCD Panel control signals
  130. */
  131. #define OMAP3EVM_LCD_PANEL_LR 2
  132. #define OMAP3EVM_LCD_PANEL_UD 3
  133. #define OMAP3EVM_LCD_PANEL_INI 152
  134. #define OMAP3EVM_LCD_PANEL_ENVDD 153
  135. #define OMAP3EVM_LCD_PANEL_QVGA 154
  136. #define OMAP3EVM_LCD_PANEL_RESB 155
  137. #define OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO 210
  138. #define OMAP3EVM_DVI_PANEL_EN_GPIO 199
  139. static int lcd_enabled;
  140. static int dvi_enabled;
  141. static void __init omap3_evm_display_init(void)
  142. {
  143. int r;
  144. r = gpio_request(OMAP3EVM_LCD_PANEL_RESB, "lcd_panel_resb");
  145. if (r) {
  146. printk(KERN_ERR "failed to get lcd_panel_resb\n");
  147. return;
  148. }
  149. gpio_direction_output(OMAP3EVM_LCD_PANEL_RESB, 1);
  150. r = gpio_request(OMAP3EVM_LCD_PANEL_INI, "lcd_panel_ini");
  151. if (r) {
  152. printk(KERN_ERR "failed to get lcd_panel_ini\n");
  153. goto err_1;
  154. }
  155. gpio_direction_output(OMAP3EVM_LCD_PANEL_INI, 1);
  156. r = gpio_request(OMAP3EVM_LCD_PANEL_QVGA, "lcd_panel_qvga");
  157. if (r) {
  158. printk(KERN_ERR "failed to get lcd_panel_qvga\n");
  159. goto err_2;
  160. }
  161. gpio_direction_output(OMAP3EVM_LCD_PANEL_QVGA, 0);
  162. r = gpio_request(OMAP3EVM_LCD_PANEL_LR, "lcd_panel_lr");
  163. if (r) {
  164. printk(KERN_ERR "failed to get lcd_panel_lr\n");
  165. goto err_3;
  166. }
  167. gpio_direction_output(OMAP3EVM_LCD_PANEL_LR, 1);
  168. r = gpio_request(OMAP3EVM_LCD_PANEL_UD, "lcd_panel_ud");
  169. if (r) {
  170. printk(KERN_ERR "failed to get lcd_panel_ud\n");
  171. goto err_4;
  172. }
  173. gpio_direction_output(OMAP3EVM_LCD_PANEL_UD, 1);
  174. r = gpio_request(OMAP3EVM_LCD_PANEL_ENVDD, "lcd_panel_envdd");
  175. if (r) {
  176. printk(KERN_ERR "failed to get lcd_panel_envdd\n");
  177. goto err_5;
  178. }
  179. gpio_direction_output(OMAP3EVM_LCD_PANEL_ENVDD, 0);
  180. return;
  181. err_5:
  182. gpio_free(OMAP3EVM_LCD_PANEL_UD);
  183. err_4:
  184. gpio_free(OMAP3EVM_LCD_PANEL_LR);
  185. err_3:
  186. gpio_free(OMAP3EVM_LCD_PANEL_QVGA);
  187. err_2:
  188. gpio_free(OMAP3EVM_LCD_PANEL_INI);
  189. err_1:
  190. gpio_free(OMAP3EVM_LCD_PANEL_RESB);
  191. }
  192. static int omap3_evm_enable_lcd(struct omap_dss_device *dssdev)
  193. {
  194. if (dvi_enabled) {
  195. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  196. return -EINVAL;
  197. }
  198. gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD, 0);
  199. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
  200. gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 0);
  201. else
  202. gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 1);
  203. lcd_enabled = 1;
  204. return 0;
  205. }
  206. static void omap3_evm_disable_lcd(struct omap_dss_device *dssdev)
  207. {
  208. gpio_set_value(OMAP3EVM_LCD_PANEL_ENVDD, 1);
  209. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2)
  210. gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 1);
  211. else
  212. gpio_set_value(OMAP3EVM_LCD_PANEL_BKLIGHT_GPIO, 0);
  213. lcd_enabled = 0;
  214. }
  215. static struct omap_dss_device omap3_evm_lcd_device = {
  216. .name = "lcd",
  217. .driver_name = "sharp_ls_panel",
  218. .type = OMAP_DISPLAY_TYPE_DPI,
  219. .phy.dpi.data_lines = 18,
  220. .platform_enable = omap3_evm_enable_lcd,
  221. .platform_disable = omap3_evm_disable_lcd,
  222. };
  223. static int omap3_evm_enable_tv(struct omap_dss_device *dssdev)
  224. {
  225. return 0;
  226. }
  227. static void omap3_evm_disable_tv(struct omap_dss_device *dssdev)
  228. {
  229. }
  230. static struct omap_dss_device omap3_evm_tv_device = {
  231. .name = "tv",
  232. .driver_name = "venc",
  233. .type = OMAP_DISPLAY_TYPE_VENC,
  234. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  235. .platform_enable = omap3_evm_enable_tv,
  236. .platform_disable = omap3_evm_disable_tv,
  237. };
  238. static int omap3_evm_enable_dvi(struct omap_dss_device *dssdev)
  239. {
  240. if (lcd_enabled) {
  241. printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
  242. return -EINVAL;
  243. }
  244. gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO, 1);
  245. dvi_enabled = 1;
  246. return 0;
  247. }
  248. static void omap3_evm_disable_dvi(struct omap_dss_device *dssdev)
  249. {
  250. gpio_set_value(OMAP3EVM_DVI_PANEL_EN_GPIO, 0);
  251. dvi_enabled = 0;
  252. }
  253. static struct omap_dss_device omap3_evm_dvi_device = {
  254. .name = "dvi",
  255. .driver_name = "generic_panel",
  256. .type = OMAP_DISPLAY_TYPE_DPI,
  257. .phy.dpi.data_lines = 24,
  258. .platform_enable = omap3_evm_enable_dvi,
  259. .platform_disable = omap3_evm_disable_dvi,
  260. };
  261. static struct omap_dss_device *omap3_evm_dss_devices[] = {
  262. &omap3_evm_lcd_device,
  263. &omap3_evm_tv_device,
  264. &omap3_evm_dvi_device,
  265. };
  266. static struct omap_dss_board_info omap3_evm_dss_data = {
  267. .num_devices = ARRAY_SIZE(omap3_evm_dss_devices),
  268. .devices = omap3_evm_dss_devices,
  269. .default_device = &omap3_evm_lcd_device,
  270. };
  271. static struct platform_device omap3_evm_dss_device = {
  272. .name = "omapdss",
  273. .id = -1,
  274. .dev = {
  275. .platform_data = &omap3_evm_dss_data,
  276. },
  277. };
  278. static struct regulator_consumer_supply omap3evm_vmmc1_supply = {
  279. .supply = "vmmc",
  280. };
  281. static struct regulator_consumer_supply omap3evm_vsim_supply = {
  282. .supply = "vmmc_aux",
  283. };
  284. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  285. static struct regulator_init_data omap3evm_vmmc1 = {
  286. .constraints = {
  287. .min_uV = 1850000,
  288. .max_uV = 3150000,
  289. .valid_modes_mask = REGULATOR_MODE_NORMAL
  290. | REGULATOR_MODE_STANDBY,
  291. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  292. | REGULATOR_CHANGE_MODE
  293. | REGULATOR_CHANGE_STATUS,
  294. },
  295. .num_consumer_supplies = 1,
  296. .consumer_supplies = &omap3evm_vmmc1_supply,
  297. };
  298. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  299. static struct regulator_init_data omap3evm_vsim = {
  300. .constraints = {
  301. .min_uV = 1800000,
  302. .max_uV = 3000000,
  303. .valid_modes_mask = REGULATOR_MODE_NORMAL
  304. | REGULATOR_MODE_STANDBY,
  305. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  306. | REGULATOR_CHANGE_MODE
  307. | REGULATOR_CHANGE_STATUS,
  308. },
  309. .num_consumer_supplies = 1,
  310. .consumer_supplies = &omap3evm_vsim_supply,
  311. };
  312. static struct omap2_hsmmc_info mmc[] = {
  313. {
  314. .mmc = 1,
  315. .wires = 4,
  316. .gpio_cd = -EINVAL,
  317. .gpio_wp = 63,
  318. },
  319. {} /* Terminator */
  320. };
  321. static struct gpio_led gpio_leds[] = {
  322. {
  323. .name = "omap3evm::ledb",
  324. /* normally not visible (board underside) */
  325. .default_trigger = "default-on",
  326. .gpio = -EINVAL, /* gets replaced */
  327. .active_low = true,
  328. },
  329. };
  330. static struct gpio_led_platform_data gpio_led_info = {
  331. .leds = gpio_leds,
  332. .num_leds = ARRAY_SIZE(gpio_leds),
  333. };
  334. static struct platform_device leds_gpio = {
  335. .name = "leds-gpio",
  336. .id = -1,
  337. .dev = {
  338. .platform_data = &gpio_led_info,
  339. },
  340. };
  341. static int omap3evm_twl_gpio_setup(struct device *dev,
  342. unsigned gpio, unsigned ngpio)
  343. {
  344. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  345. omap_mux_init_gpio(63, OMAP_PIN_INPUT);
  346. mmc[0].gpio_cd = gpio + 0;
  347. omap2_hsmmc_init(mmc);
  348. /* link regulators to MMC adapters */
  349. omap3evm_vmmc1_supply.dev = mmc[0].dev;
  350. omap3evm_vsim_supply.dev = mmc[0].dev;
  351. /*
  352. * Most GPIOs are for USB OTG. Some are mostly sent to
  353. * the P2 connector; notably LEDA for the LCD backlight.
  354. */
  355. /* TWL4030_GPIO_MAX + 0 == ledA, LCD Backlight control */
  356. gpio_request(gpio + TWL4030_GPIO_MAX, "EN_LCD_BKL");
  357. gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
  358. /* gpio + 7 == DVI Enable */
  359. gpio_request(gpio + 7, "EN_DVI");
  360. gpio_direction_output(gpio + 7, 0);
  361. /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
  362. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  363. platform_device_register(&leds_gpio);
  364. return 0;
  365. }
  366. static struct twl4030_gpio_platform_data omap3evm_gpio_data = {
  367. .gpio_base = OMAP_MAX_GPIO_LINES,
  368. .irq_base = TWL4030_GPIO_IRQ_BASE,
  369. .irq_end = TWL4030_GPIO_IRQ_END,
  370. .use_leds = true,
  371. .setup = omap3evm_twl_gpio_setup,
  372. };
  373. static struct twl4030_usb_data omap3evm_usb_data = {
  374. .usb_mode = T2_USB_MODE_ULPI,
  375. };
  376. static int board_keymap[] = {
  377. KEY(0, 0, KEY_LEFT),
  378. KEY(0, 1, KEY_DOWN),
  379. KEY(0, 2, KEY_ENTER),
  380. KEY(0, 3, KEY_M),
  381. KEY(1, 0, KEY_RIGHT),
  382. KEY(1, 1, KEY_UP),
  383. KEY(1, 2, KEY_I),
  384. KEY(1, 3, KEY_N),
  385. KEY(2, 0, KEY_A),
  386. KEY(2, 1, KEY_E),
  387. KEY(2, 2, KEY_J),
  388. KEY(2, 3, KEY_O),
  389. KEY(3, 0, KEY_B),
  390. KEY(3, 1, KEY_F),
  391. KEY(3, 2, KEY_K),
  392. KEY(3, 3, KEY_P)
  393. };
  394. static struct matrix_keymap_data board_map_data = {
  395. .keymap = board_keymap,
  396. .keymap_size = ARRAY_SIZE(board_keymap),
  397. };
  398. static struct twl4030_keypad_data omap3evm_kp_data = {
  399. .keymap_data = &board_map_data,
  400. .rows = 4,
  401. .cols = 4,
  402. .rep = 1,
  403. };
  404. static struct twl4030_madc_platform_data omap3evm_madc_data = {
  405. .irq_line = 1,
  406. };
  407. static struct twl4030_codec_audio_data omap3evm_audio_data = {
  408. .audio_mclk = 26000000,
  409. };
  410. static struct twl4030_codec_data omap3evm_codec_data = {
  411. .audio_mclk = 26000000,
  412. .audio = &omap3evm_audio_data,
  413. };
  414. static struct regulator_consumer_supply omap3_evm_vdda_dac_supply = {
  415. .supply = "vdda_dac",
  416. .dev = &omap3_evm_dss_device.dev,
  417. };
  418. /* VDAC for DSS driving S-Video */
  419. static struct regulator_init_data omap3_evm_vdac = {
  420. .constraints = {
  421. .min_uV = 1800000,
  422. .max_uV = 1800000,
  423. .apply_uV = true,
  424. .valid_modes_mask = REGULATOR_MODE_NORMAL
  425. | REGULATOR_MODE_STANDBY,
  426. .valid_ops_mask = REGULATOR_CHANGE_MODE
  427. | REGULATOR_CHANGE_STATUS,
  428. },
  429. .num_consumer_supplies = 1,
  430. .consumer_supplies = &omap3_evm_vdda_dac_supply,
  431. };
  432. /* VPLL2 for digital video outputs */
  433. static struct regulator_consumer_supply omap3_evm_vpll2_supply =
  434. REGULATOR_SUPPLY("vdds_dsi", "omapdss");
  435. static struct regulator_init_data omap3_evm_vpll2 = {
  436. .constraints = {
  437. .min_uV = 1800000,
  438. .max_uV = 1800000,
  439. .apply_uV = true,
  440. .valid_modes_mask = REGULATOR_MODE_NORMAL
  441. | REGULATOR_MODE_STANDBY,
  442. .valid_ops_mask = REGULATOR_CHANGE_MODE
  443. | REGULATOR_CHANGE_STATUS,
  444. },
  445. .num_consumer_supplies = 1,
  446. .consumer_supplies = &omap3_evm_vpll2_supply,
  447. };
  448. static struct twl4030_platform_data omap3evm_twldata = {
  449. .irq_base = TWL4030_IRQ_BASE,
  450. .irq_end = TWL4030_IRQ_END,
  451. /* platform_data for children goes here */
  452. .keypad = &omap3evm_kp_data,
  453. .madc = &omap3evm_madc_data,
  454. .usb = &omap3evm_usb_data,
  455. .gpio = &omap3evm_gpio_data,
  456. .codec = &omap3evm_codec_data,
  457. .vdac = &omap3_evm_vdac,
  458. .vpll2 = &omap3_evm_vpll2,
  459. };
  460. static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
  461. {
  462. I2C_BOARD_INFO("twl4030", 0x48),
  463. .flags = I2C_CLIENT_WAKE,
  464. .irq = INT_34XX_SYS_NIRQ,
  465. .platform_data = &omap3evm_twldata,
  466. },
  467. };
  468. static int __init omap3_evm_i2c_init(void)
  469. {
  470. /*
  471. * REVISIT: These entries can be set in omap3evm_twl_data
  472. * after a merge with MFD tree
  473. */
  474. omap3evm_twldata.vmmc1 = &omap3evm_vmmc1;
  475. omap3evm_twldata.vsim = &omap3evm_vsim;
  476. omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
  477. ARRAY_SIZE(omap3evm_i2c_boardinfo));
  478. omap_register_i2c_bus(2, 400, NULL, 0);
  479. omap_register_i2c_bus(3, 400, NULL, 0);
  480. return 0;
  481. }
  482. static void ads7846_dev_init(void)
  483. {
  484. if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
  485. printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
  486. gpio_direction_input(OMAP3_EVM_TS_GPIO);
  487. gpio_set_debounce(OMAP3_EVM_TS_GPIO, 310);
  488. }
  489. static int ads7846_get_pendown_state(void)
  490. {
  491. return !gpio_get_value(OMAP3_EVM_TS_GPIO);
  492. }
  493. struct ads7846_platform_data ads7846_config = {
  494. .x_max = 0x0fff,
  495. .y_max = 0x0fff,
  496. .x_plate_ohms = 180,
  497. .pressure_max = 255,
  498. .debounce_max = 10,
  499. .debounce_tol = 3,
  500. .debounce_rep = 1,
  501. .get_pendown_state = ads7846_get_pendown_state,
  502. .keep_vref_on = 1,
  503. .settle_delay_usecs = 150,
  504. .wakeup = true,
  505. };
  506. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  507. .turbo_mode = 0,
  508. .single_channel = 1, /* 0: slave, 1: master */
  509. };
  510. struct spi_board_info omap3evm_spi_board_info[] = {
  511. [0] = {
  512. .modalias = "ads7846",
  513. .bus_num = 1,
  514. .chip_select = 0,
  515. .max_speed_hz = 1500000,
  516. .controller_data = &ads7846_mcspi_config,
  517. .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
  518. .platform_data = &ads7846_config,
  519. },
  520. };
  521. static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
  522. };
  523. static void __init omap3_evm_init_irq(void)
  524. {
  525. omap_board_config = omap3_evm_config;
  526. omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
  527. omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
  528. omap_init_irq();
  529. omap_gpio_init();
  530. }
  531. static struct platform_device *omap3_evm_devices[] __initdata = {
  532. &omap3_evm_dss_device,
  533. };
  534. static struct ehci_hcd_omap_platform_data ehci_pdata __initdata = {
  535. .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  536. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  537. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  538. .phy_reset = true,
  539. /* PHY reset GPIO will be runtime programmed based on EVM version */
  540. .reset_gpio_port[0] = -EINVAL,
  541. .reset_gpio_port[1] = -EINVAL,
  542. .reset_gpio_port[2] = -EINVAL
  543. };
  544. #ifdef CONFIG_OMAP_MUX
  545. static struct omap_board_mux board_mux[] __initdata = {
  546. OMAP3_MUX(SYS_NIRQ, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLUP |
  547. OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW |
  548. OMAP_PIN_OFF_WAKEUPENABLE),
  549. OMAP3_MUX(MCSPI1_CS1, OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP |
  550. OMAP_PIN_OFF_INPUT_PULLUP | OMAP_PIN_OFF_OUTPUT_LOW),
  551. { .reg_offset = OMAP_MUX_TERMINATOR },
  552. };
  553. #else
  554. #define board_mux NULL
  555. #endif
  556. static struct omap_musb_board_data musb_board_data = {
  557. .interface_type = MUSB_INTERFACE_ULPI,
  558. .mode = MUSB_OTG,
  559. .power = 100,
  560. };
  561. static void __init omap3_evm_init(void)
  562. {
  563. omap3_evm_get_revision();
  564. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  565. omap3_evm_i2c_init();
  566. platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
  567. spi_register_board_info(omap3evm_spi_board_info,
  568. ARRAY_SIZE(omap3evm_spi_board_info));
  569. omap_serial_init();
  570. /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
  571. usb_nop_xceiv_register();
  572. if (get_omap3_evm_rev() >= OMAP3EVM_BOARD_GEN_2) {
  573. /* enable EHCI VBUS using GPIO22 */
  574. omap_mux_init_gpio(22, OMAP_PIN_INPUT_PULLUP);
  575. gpio_request(OMAP3_EVM_EHCI_VBUS, "enable EHCI VBUS");
  576. gpio_direction_output(OMAP3_EVM_EHCI_VBUS, 0);
  577. gpio_set_value(OMAP3_EVM_EHCI_VBUS, 1);
  578. /* Select EHCI port on main board */
  579. omap_mux_init_gpio(61, OMAP_PIN_INPUT_PULLUP);
  580. gpio_request(OMAP3_EVM_EHCI_SELECT, "select EHCI port");
  581. gpio_direction_output(OMAP3_EVM_EHCI_SELECT, 0);
  582. gpio_set_value(OMAP3_EVM_EHCI_SELECT, 0);
  583. /* setup EHCI phy reset config */
  584. omap_mux_init_gpio(21, OMAP_PIN_INPUT_PULLUP);
  585. ehci_pdata.reset_gpio_port[1] = 21;
  586. /* EVM REV >= E can supply 500mA with EXTVBUS programming */
  587. musb_board_data.power = 500;
  588. musb_board_data.extvbus = 1;
  589. } else {
  590. /* setup EHCI phy reset on MDC */
  591. omap_mux_init_gpio(135, OMAP_PIN_OUTPUT);
  592. ehci_pdata.reset_gpio_port[1] = 135;
  593. }
  594. usb_musb_init(&musb_board_data);
  595. usb_ehci_init(&ehci_pdata);
  596. ads7846_dev_init();
  597. omap3evm_init_smsc911x();
  598. omap3_evm_display_init();
  599. }
  600. MACHINE_START(OMAP3EVM, "OMAP3 EVM")
  601. /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
  602. .phys_io = 0x48000000,
  603. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  604. .boot_params = 0x80000100,
  605. .map_io = omap3_map_io,
  606. .reserve = omap_reserve,
  607. .init_irq = omap3_evm_init_irq,
  608. .init_machine = omap3_evm_init,
  609. .timer = &omap_timer,
  610. MACHINE_END