board-3430sdp.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. /*
  2. * linux/arch/arm/mach-omap2/board-3430sdp.c
  3. *
  4. * Copyright (C) 2007 Texas Instruments
  5. *
  6. * Modified from mach-omap2/board-generic.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/input.h>
  19. #include <linux/spi/spi.h>
  20. #include <linux/spi/ads7846.h>
  21. #include <linux/i2c/twl4030.h>
  22. #include <linux/regulator/machine.h>
  23. #include <linux/io.h>
  24. #include <linux/gpio.h>
  25. #include <mach/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <mach/mcspi.h>
  30. #include <mach/mux.h>
  31. #include <mach/board.h>
  32. #include <mach/usb.h>
  33. #include <mach/common.h>
  34. #include <mach/dma.h>
  35. #include <mach/gpmc.h>
  36. #include <mach/control.h>
  37. #include <mach/keypad.h>
  38. #include <mach/gpmc-smc91x.h>
  39. #include "sdram-qimonda-hyb18m512160af-6.h"
  40. #include "mmc-twl4030.h"
  41. #define CONFIG_DISABLE_HFCLK 1
  42. #define SDP3430_TS_GPIO_IRQ_SDPV1 3
  43. #define SDP3430_TS_GPIO_IRQ_SDPV2 2
  44. #define ENABLE_VAUX3_DEDICATED 0x03
  45. #define ENABLE_VAUX3_DEV_GRP 0x20
  46. #define TWL4030_MSECURE_GPIO 22
  47. static int sdp3430_keymap[] = {
  48. KEY(0, 0, KEY_LEFT),
  49. KEY(0, 1, KEY_RIGHT),
  50. KEY(0, 2, KEY_A),
  51. KEY(0, 3, KEY_B),
  52. KEY(0, 4, KEY_C),
  53. KEY(1, 0, KEY_DOWN),
  54. KEY(1, 1, KEY_UP),
  55. KEY(1, 2, KEY_E),
  56. KEY(1, 3, KEY_F),
  57. KEY(1, 4, KEY_G),
  58. KEY(2, 0, KEY_ENTER),
  59. KEY(2, 1, KEY_I),
  60. KEY(2, 2, KEY_J),
  61. KEY(2, 3, KEY_K),
  62. KEY(2, 4, KEY_3),
  63. KEY(3, 0, KEY_M),
  64. KEY(3, 1, KEY_N),
  65. KEY(3, 2, KEY_O),
  66. KEY(3, 3, KEY_P),
  67. KEY(3, 4, KEY_Q),
  68. KEY(4, 0, KEY_R),
  69. KEY(4, 1, KEY_4),
  70. KEY(4, 2, KEY_T),
  71. KEY(4, 3, KEY_U),
  72. KEY(4, 4, KEY_D),
  73. KEY(5, 0, KEY_V),
  74. KEY(5, 1, KEY_W),
  75. KEY(5, 2, KEY_L),
  76. KEY(5, 3, KEY_S),
  77. KEY(5, 4, KEY_H),
  78. 0
  79. };
  80. static struct twl4030_keypad_data sdp3430_kp_data = {
  81. .rows = 5,
  82. .cols = 6,
  83. .keymap = sdp3430_keymap,
  84. .keymapsize = ARRAY_SIZE(sdp3430_keymap),
  85. .rep = 1,
  86. };
  87. static int ts_gpio; /* Needed for ads7846_get_pendown_state */
  88. /**
  89. * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
  90. *
  91. * @return - void. If request gpio fails then Flag KERN_ERR.
  92. */
  93. static void ads7846_dev_init(void)
  94. {
  95. if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
  96. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  97. return;
  98. }
  99. gpio_direction_input(ts_gpio);
  100. omap_set_gpio_debounce(ts_gpio, 1);
  101. omap_set_gpio_debounce_time(ts_gpio, 0xa);
  102. }
  103. static int ads7846_get_pendown_state(void)
  104. {
  105. return !gpio_get_value(ts_gpio);
  106. }
  107. static struct ads7846_platform_data tsc2046_config __initdata = {
  108. .get_pendown_state = ads7846_get_pendown_state,
  109. .keep_vref_on = 1,
  110. };
  111. static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
  112. .turbo_mode = 0,
  113. .single_channel = 1, /* 0: slave, 1: master */
  114. };
  115. static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
  116. [0] = {
  117. /*
  118. * TSC2046 operates at a max freqency of 2MHz, so
  119. * operate slightly below at 1.5MHz
  120. */
  121. .modalias = "ads7846",
  122. .bus_num = 1,
  123. .chip_select = 0,
  124. .max_speed_hz = 1500000,
  125. .controller_data = &tsc2046_mcspi_config,
  126. .irq = 0,
  127. .platform_data = &tsc2046_config,
  128. },
  129. };
  130. static struct platform_device sdp3430_lcd_device = {
  131. .name = "sdp2430_lcd",
  132. .id = -1,
  133. };
  134. static struct regulator_consumer_supply sdp3430_vdac_supply = {
  135. .supply = "vdac",
  136. .dev = &sdp3430_lcd_device.dev,
  137. };
  138. static struct regulator_consumer_supply sdp3430_vdvi_supply = {
  139. .supply = "vdvi",
  140. .dev = &sdp3430_lcd_device.dev,
  141. };
  142. static struct platform_device *sdp3430_devices[] __initdata = {
  143. &sdp3430_lcd_device,
  144. };
  145. static void __init omap_3430sdp_init_irq(void)
  146. {
  147. omap2_init_common_hw(hyb18m512160af6_sdrc_params);
  148. omap_init_irq();
  149. omap_gpio_init();
  150. }
  151. static struct omap_uart_config sdp3430_uart_config __initdata = {
  152. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  153. };
  154. static struct omap_lcd_config sdp3430_lcd_config __initdata = {
  155. .ctrl_name = "internal",
  156. };
  157. static struct omap_board_config_kernel sdp3430_config[] __initdata = {
  158. { OMAP_TAG_UART, &sdp3430_uart_config },
  159. { OMAP_TAG_LCD, &sdp3430_lcd_config },
  160. };
  161. static int sdp3430_batt_table[] = {
  162. /* 0 C*/
  163. 30800, 29500, 28300, 27100,
  164. 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
  165. 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
  166. 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
  167. 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
  168. 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
  169. 4040, 3910, 3790, 3670, 3550
  170. };
  171. static struct twl4030_bci_platform_data sdp3430_bci_data = {
  172. .battery_tmp_tbl = sdp3430_batt_table,
  173. .tblsize = ARRAY_SIZE(sdp3430_batt_table),
  174. };
  175. static struct twl4030_hsmmc_info mmc[] = {
  176. {
  177. .mmc = 1,
  178. /* 8 bits (default) requires S6.3 == ON,
  179. * so the SIM card isn't used; else 4 bits.
  180. */
  181. .wires = 8,
  182. .gpio_wp = 4,
  183. },
  184. {
  185. .mmc = 2,
  186. .wires = 8,
  187. .gpio_wp = 7,
  188. },
  189. {} /* Terminator */
  190. };
  191. static struct regulator_consumer_supply sdp3430_vmmc1_supply = {
  192. .supply = "vmmc",
  193. };
  194. static struct regulator_consumer_supply sdp3430_vsim_supply = {
  195. .supply = "vmmc_aux",
  196. };
  197. static struct regulator_consumer_supply sdp3430_vmmc2_supply = {
  198. .supply = "vmmc",
  199. };
  200. static int sdp3430_twl_gpio_setup(struct device *dev,
  201. unsigned gpio, unsigned ngpio)
  202. {
  203. /* gpio + 0 is "mmc0_cd" (input/IRQ),
  204. * gpio + 1 is "mmc1_cd" (input/IRQ)
  205. */
  206. mmc[0].gpio_cd = gpio + 0;
  207. mmc[1].gpio_cd = gpio + 1;
  208. twl4030_mmc_init(mmc);
  209. /* link regulators to MMC adapters ... we "know" the
  210. * regulators will be set up only *after* we return.
  211. */
  212. sdp3430_vmmc1_supply.dev = mmc[0].dev;
  213. sdp3430_vsim_supply.dev = mmc[0].dev;
  214. sdp3430_vmmc2_supply.dev = mmc[1].dev;
  215. /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
  216. gpio_request(gpio + 7, "sub_lcd_en_bkl");
  217. gpio_direction_output(gpio + 7, 0);
  218. /* gpio + 15 is "sub_lcd_nRST" (output) */
  219. gpio_request(gpio + 15, "sub_lcd_nRST");
  220. gpio_direction_output(gpio + 15, 0);
  221. return 0;
  222. }
  223. static struct twl4030_gpio_platform_data sdp3430_gpio_data = {
  224. .gpio_base = OMAP_MAX_GPIO_LINES,
  225. .irq_base = TWL4030_GPIO_IRQ_BASE,
  226. .irq_end = TWL4030_GPIO_IRQ_END,
  227. .pulldowns = BIT(2) | BIT(6) | BIT(8) | BIT(13)
  228. | BIT(16) | BIT(17),
  229. .setup = sdp3430_twl_gpio_setup,
  230. };
  231. static struct twl4030_usb_data sdp3430_usb_data = {
  232. .usb_mode = T2_USB_MODE_ULPI,
  233. };
  234. static struct twl4030_madc_platform_data sdp3430_madc_data = {
  235. .irq_line = 1,
  236. };
  237. /*
  238. * Apply all the fixed voltages since most versions of U-Boot
  239. * don't bother with that initialization.
  240. */
  241. /* VAUX1 for mainboard (irda and sub-lcd) */
  242. static struct regulator_init_data sdp3430_vaux1 = {
  243. .constraints = {
  244. .min_uV = 2800000,
  245. .max_uV = 2800000,
  246. .apply_uV = true,
  247. .valid_modes_mask = REGULATOR_MODE_NORMAL
  248. | REGULATOR_MODE_STANDBY,
  249. .valid_ops_mask = REGULATOR_CHANGE_MODE
  250. | REGULATOR_CHANGE_STATUS,
  251. },
  252. };
  253. /* VAUX2 for camera module */
  254. static struct regulator_init_data sdp3430_vaux2 = {
  255. .constraints = {
  256. .min_uV = 2800000,
  257. .max_uV = 2800000,
  258. .apply_uV = true,
  259. .valid_modes_mask = REGULATOR_MODE_NORMAL
  260. | REGULATOR_MODE_STANDBY,
  261. .valid_ops_mask = REGULATOR_CHANGE_MODE
  262. | REGULATOR_CHANGE_STATUS,
  263. },
  264. };
  265. /* VAUX3 for LCD board */
  266. static struct regulator_init_data sdp3430_vaux3 = {
  267. .constraints = {
  268. .min_uV = 2800000,
  269. .max_uV = 2800000,
  270. .apply_uV = true,
  271. .valid_modes_mask = REGULATOR_MODE_NORMAL
  272. | REGULATOR_MODE_STANDBY,
  273. .valid_ops_mask = REGULATOR_CHANGE_MODE
  274. | REGULATOR_CHANGE_STATUS,
  275. },
  276. };
  277. /* VAUX4 for OMAP VDD_CSI2 (camera) */
  278. static struct regulator_init_data sdp3430_vaux4 = {
  279. .constraints = {
  280. .min_uV = 1800000,
  281. .max_uV = 1800000,
  282. .apply_uV = true,
  283. .valid_modes_mask = REGULATOR_MODE_NORMAL
  284. | REGULATOR_MODE_STANDBY,
  285. .valid_ops_mask = REGULATOR_CHANGE_MODE
  286. | REGULATOR_CHANGE_STATUS,
  287. },
  288. };
  289. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  290. static struct regulator_init_data sdp3430_vmmc1 = {
  291. .constraints = {
  292. .min_uV = 1850000,
  293. .max_uV = 3150000,
  294. .valid_modes_mask = REGULATOR_MODE_NORMAL
  295. | REGULATOR_MODE_STANDBY,
  296. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  297. | REGULATOR_CHANGE_MODE
  298. | REGULATOR_CHANGE_STATUS,
  299. },
  300. .num_consumer_supplies = 1,
  301. .consumer_supplies = &sdp3430_vmmc1_supply,
  302. };
  303. /* VMMC2 for MMC2 card */
  304. static struct regulator_init_data sdp3430_vmmc2 = {
  305. .constraints = {
  306. .min_uV = 1850000,
  307. .max_uV = 1850000,
  308. .apply_uV = true,
  309. .valid_modes_mask = REGULATOR_MODE_NORMAL
  310. | REGULATOR_MODE_STANDBY,
  311. .valid_ops_mask = REGULATOR_CHANGE_MODE
  312. | REGULATOR_CHANGE_STATUS,
  313. },
  314. .num_consumer_supplies = 1,
  315. .consumer_supplies = &sdp3430_vmmc2_supply,
  316. };
  317. /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
  318. static struct regulator_init_data sdp3430_vsim = {
  319. .constraints = {
  320. .min_uV = 1800000,
  321. .max_uV = 3000000,
  322. .valid_modes_mask = REGULATOR_MODE_NORMAL
  323. | REGULATOR_MODE_STANDBY,
  324. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  325. | REGULATOR_CHANGE_MODE
  326. | REGULATOR_CHANGE_STATUS,
  327. },
  328. .num_consumer_supplies = 1,
  329. .consumer_supplies = &sdp3430_vsim_supply,
  330. };
  331. /* VDAC for DSS driving S-Video */
  332. static struct regulator_init_data sdp3430_vdac = {
  333. .constraints = {
  334. .min_uV = 1800000,
  335. .max_uV = 1800000,
  336. .apply_uV = true,
  337. .valid_modes_mask = REGULATOR_MODE_NORMAL
  338. | REGULATOR_MODE_STANDBY,
  339. .valid_ops_mask = REGULATOR_CHANGE_MODE
  340. | REGULATOR_CHANGE_STATUS,
  341. },
  342. .num_consumer_supplies = 1,
  343. .consumer_supplies = &sdp3430_vdac_supply,
  344. };
  345. /* VPLL2 for digital video outputs */
  346. static struct regulator_init_data sdp3430_vpll2 = {
  347. .constraints = {
  348. .name = "VDVI",
  349. .min_uV = 1800000,
  350. .max_uV = 1800000,
  351. .valid_modes_mask = REGULATOR_MODE_NORMAL
  352. | REGULATOR_MODE_STANDBY,
  353. .valid_ops_mask = REGULATOR_CHANGE_MODE
  354. | REGULATOR_CHANGE_STATUS,
  355. },
  356. .num_consumer_supplies = 1,
  357. .consumer_supplies = &sdp3430_vdvi_supply,
  358. };
  359. static struct twl4030_platform_data sdp3430_twldata = {
  360. .irq_base = TWL4030_IRQ_BASE,
  361. .irq_end = TWL4030_IRQ_END,
  362. /* platform_data for children goes here */
  363. .bci = &sdp3430_bci_data,
  364. .gpio = &sdp3430_gpio_data,
  365. .madc = &sdp3430_madc_data,
  366. .keypad = &sdp3430_kp_data,
  367. .usb = &sdp3430_usb_data,
  368. .vaux1 = &sdp3430_vaux1,
  369. .vaux2 = &sdp3430_vaux2,
  370. .vaux3 = &sdp3430_vaux3,
  371. .vaux4 = &sdp3430_vaux4,
  372. .vmmc1 = &sdp3430_vmmc1,
  373. .vmmc2 = &sdp3430_vmmc2,
  374. .vsim = &sdp3430_vsim,
  375. .vdac = &sdp3430_vdac,
  376. .vpll2 = &sdp3430_vpll2,
  377. };
  378. static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
  379. {
  380. I2C_BOARD_INFO("twl4030", 0x48),
  381. .flags = I2C_CLIENT_WAKE,
  382. .irq = INT_34XX_SYS_NIRQ,
  383. .platform_data = &sdp3430_twldata,
  384. },
  385. };
  386. static int __init omap3430_i2c_init(void)
  387. {
  388. /* i2c1 for PMIC only */
  389. omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
  390. ARRAY_SIZE(sdp3430_i2c_boardinfo));
  391. /* i2c2 on camera connector (for sensor control) and optional isp1301 */
  392. omap_register_i2c_bus(2, 400, NULL, 0);
  393. /* i2c3 on display connector (for DVI, tfp410) */
  394. omap_register_i2c_bus(3, 400, NULL, 0);
  395. return 0;
  396. }
  397. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  398. static struct omap_smc91x_platform_data board_smc91x_data = {
  399. .cs = 3,
  400. .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
  401. IORESOURCE_IRQ_LOWLEVEL,
  402. };
  403. static void __init board_smc91x_init(void)
  404. {
  405. if (omap_rev() > OMAP3430_REV_ES1_0)
  406. board_smc91x_data.gpio_irq = 6;
  407. else
  408. board_smc91x_data.gpio_irq = 29;
  409. gpmc_smc91x_init(&board_smc91x_data);
  410. }
  411. #else
  412. static inline void board_smc91x_init(void)
  413. {
  414. }
  415. #endif
  416. static void __init omap_3430sdp_init(void)
  417. {
  418. omap3430_i2c_init();
  419. platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
  420. omap_board_config = sdp3430_config;
  421. omap_board_config_size = ARRAY_SIZE(sdp3430_config);
  422. if (omap_rev() > OMAP3430_REV_ES1_0)
  423. ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
  424. else
  425. ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
  426. sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
  427. spi_register_board_info(sdp3430_spi_board_info,
  428. ARRAY_SIZE(sdp3430_spi_board_info));
  429. ads7846_dev_init();
  430. omap_serial_init();
  431. usb_musb_init();
  432. board_smc91x_init();
  433. }
  434. static void __init omap_3430sdp_map_io(void)
  435. {
  436. omap2_set_globals_343x();
  437. omap2_map_common_io();
  438. }
  439. MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
  440. /* Maintainer: Syed Khasim - Texas Instruments Inc */
  441. .phys_io = 0x48000000,
  442. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  443. .boot_params = 0x80000100,
  444. .map_io = omap_3430sdp_map_io,
  445. .init_irq = omap_3430sdp_init_irq,
  446. .init_machine = omap_3430sdp_init,
  447. .timer = &omap_timer,
  448. MACHINE_END