board-3430sdp.c 13 KB

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