board-3430sdp.c 13 KB

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