board-ldp.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /*
  2. * linux/arch/arm/mach-omap2/board-ldp.c
  3. *
  4. * Copyright (C) 2008 Texas Instruments Inc.
  5. * Nishant Kamat <nskamat@ti.com>
  6. *
  7. * Modified from mach-omap2/board-3430sdp.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/delay.h>
  17. #include <linux/input.h>
  18. #include <linux/input/matrix_keypad.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/workqueue.h>
  21. #include <linux/err.h>
  22. #include <linux/clk.h>
  23. #include <linux/spi/spi.h>
  24. #include <linux/spi/ads7846.h>
  25. #include <linux/regulator/machine.h>
  26. #include <linux/i2c/twl.h>
  27. #include <linux/io.h>
  28. #include <linux/smsc911x.h>
  29. #include <linux/mmc/host.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <plat/mcspi.h>
  35. #include <mach/gpio.h>
  36. #include <plat/board.h>
  37. #include <plat/common.h>
  38. #include <plat/gpmc.h>
  39. #include <mach/board-zoom.h>
  40. #include <asm/delay.h>
  41. #include <plat/usb.h>
  42. #include "board-flash.h"
  43. #include "mux.h"
  44. #include "hsmmc.h"
  45. #include "control.h"
  46. #define LDP_SMSC911X_CS 1
  47. #define LDP_SMSC911X_GPIO 152
  48. #define DEBUG_BASE 0x08000000
  49. #define LDP_ETHR_START DEBUG_BASE
  50. static struct resource ldp_smsc911x_resources[] = {
  51. [0] = {
  52. .start = LDP_ETHR_START,
  53. .end = LDP_ETHR_START + SZ_4K,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = 0,
  58. .end = 0,
  59. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  60. },
  61. };
  62. static struct smsc911x_platform_config ldp_smsc911x_config = {
  63. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  64. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  65. .flags = SMSC911X_USE_32BIT,
  66. .phy_interface = PHY_INTERFACE_MODE_MII,
  67. };
  68. static struct platform_device ldp_smsc911x_device = {
  69. .name = "smsc911x",
  70. .id = -1,
  71. .num_resources = ARRAY_SIZE(ldp_smsc911x_resources),
  72. .resource = ldp_smsc911x_resources,
  73. .dev = {
  74. .platform_data = &ldp_smsc911x_config,
  75. },
  76. };
  77. static uint32_t board_keymap[] = {
  78. KEY(0, 0, KEY_1),
  79. KEY(1, 0, KEY_2),
  80. KEY(2, 0, KEY_3),
  81. KEY(0, 1, KEY_4),
  82. KEY(1, 1, KEY_5),
  83. KEY(2, 1, KEY_6),
  84. KEY(3, 1, KEY_F5),
  85. KEY(0, 2, KEY_7),
  86. KEY(1, 2, KEY_8),
  87. KEY(2, 2, KEY_9),
  88. KEY(3, 2, KEY_F6),
  89. KEY(0, 3, KEY_F7),
  90. KEY(1, 3, KEY_0),
  91. KEY(2, 3, KEY_F8),
  92. PERSISTENT_KEY(4, 5),
  93. KEY(4, 4, KEY_VOLUMEUP),
  94. KEY(5, 5, KEY_VOLUMEDOWN),
  95. 0
  96. };
  97. static struct matrix_keymap_data board_map_data = {
  98. .keymap = board_keymap,
  99. .keymap_size = ARRAY_SIZE(board_keymap),
  100. };
  101. static struct twl4030_keypad_data ldp_kp_twl4030_data = {
  102. .keymap_data = &board_map_data,
  103. .rows = 6,
  104. .cols = 6,
  105. .rep = 1,
  106. };
  107. static struct gpio_keys_button ldp_gpio_keys_buttons[] = {
  108. [0] = {
  109. .code = KEY_ENTER,
  110. .gpio = 101,
  111. .desc = "enter sw",
  112. .active_low = 1,
  113. .debounce_interval = 30,
  114. },
  115. [1] = {
  116. .code = KEY_F1,
  117. .gpio = 102,
  118. .desc = "func 1",
  119. .active_low = 1,
  120. .debounce_interval = 30,
  121. },
  122. [2] = {
  123. .code = KEY_F2,
  124. .gpio = 103,
  125. .desc = "func 2",
  126. .active_low = 1,
  127. .debounce_interval = 30,
  128. },
  129. [3] = {
  130. .code = KEY_F3,
  131. .gpio = 104,
  132. .desc = "func 3",
  133. .active_low = 1,
  134. .debounce_interval = 30,
  135. },
  136. [4] = {
  137. .code = KEY_F4,
  138. .gpio = 105,
  139. .desc = "func 4",
  140. .active_low = 1,
  141. .debounce_interval = 30,
  142. },
  143. [5] = {
  144. .code = KEY_LEFT,
  145. .gpio = 106,
  146. .desc = "left sw",
  147. .active_low = 1,
  148. .debounce_interval = 30,
  149. },
  150. [6] = {
  151. .code = KEY_RIGHT,
  152. .gpio = 107,
  153. .desc = "right sw",
  154. .active_low = 1,
  155. .debounce_interval = 30,
  156. },
  157. [7] = {
  158. .code = KEY_UP,
  159. .gpio = 108,
  160. .desc = "up sw",
  161. .active_low = 1,
  162. .debounce_interval = 30,
  163. },
  164. [8] = {
  165. .code = KEY_DOWN,
  166. .gpio = 109,
  167. .desc = "down sw",
  168. .active_low = 1,
  169. .debounce_interval = 30,
  170. },
  171. };
  172. static struct gpio_keys_platform_data ldp_gpio_keys = {
  173. .buttons = ldp_gpio_keys_buttons,
  174. .nbuttons = ARRAY_SIZE(ldp_gpio_keys_buttons),
  175. .rep = 1,
  176. };
  177. static struct platform_device ldp_gpio_keys_device = {
  178. .name = "gpio-keys",
  179. .id = -1,
  180. .dev = {
  181. .platform_data = &ldp_gpio_keys,
  182. },
  183. };
  184. static int ts_gpio;
  185. /**
  186. * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
  187. *
  188. * @return - void. If request gpio fails then Flag KERN_ERR.
  189. */
  190. static void ads7846_dev_init(void)
  191. {
  192. if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
  193. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  194. return;
  195. }
  196. gpio_direction_input(ts_gpio);
  197. gpio_set_debounce(ts_gpio, 310);
  198. }
  199. static int ads7846_get_pendown_state(void)
  200. {
  201. return !gpio_get_value(ts_gpio);
  202. }
  203. static struct ads7846_platform_data tsc2046_config __initdata = {
  204. .get_pendown_state = ads7846_get_pendown_state,
  205. .keep_vref_on = 1,
  206. };
  207. static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
  208. .turbo_mode = 0,
  209. .single_channel = 1, /* 0: slave, 1: master */
  210. };
  211. static struct spi_board_info ldp_spi_board_info[] __initdata = {
  212. [0] = {
  213. /*
  214. * TSC2046 operates at a max freqency of 2MHz, so
  215. * operate slightly below at 1.5MHz
  216. */
  217. .modalias = "ads7846",
  218. .bus_num = 1,
  219. .chip_select = 0,
  220. .max_speed_hz = 1500000,
  221. .controller_data = &tsc2046_mcspi_config,
  222. .irq = 0,
  223. .platform_data = &tsc2046_config,
  224. },
  225. };
  226. static inline void __init ldp_init_smsc911x(void)
  227. {
  228. int eth_cs;
  229. unsigned long cs_mem_base;
  230. int eth_gpio = 0;
  231. eth_cs = LDP_SMSC911X_CS;
  232. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  233. printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
  234. return;
  235. }
  236. ldp_smsc911x_resources[0].start = cs_mem_base + 0x0;
  237. ldp_smsc911x_resources[0].end = cs_mem_base + 0xff;
  238. udelay(100);
  239. eth_gpio = LDP_SMSC911X_GPIO;
  240. ldp_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
  241. if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
  242. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  243. eth_gpio);
  244. return;
  245. }
  246. gpio_direction_input(eth_gpio);
  247. }
  248. static struct platform_device ldp_lcd_device = {
  249. .name = "ldp_lcd",
  250. .id = -1,
  251. };
  252. static struct omap_lcd_config ldp_lcd_config __initdata = {
  253. .ctrl_name = "internal",
  254. };
  255. static struct omap_board_config_kernel ldp_config[] __initdata = {
  256. { OMAP_TAG_LCD, &ldp_lcd_config },
  257. };
  258. static void __init omap_ldp_init_early(void)
  259. {
  260. omap2_init_common_infrastructure();
  261. omap2_init_common_devices(NULL, NULL);
  262. }
  263. static struct twl4030_usb_data ldp_usb_data = {
  264. .usb_mode = T2_USB_MODE_ULPI,
  265. };
  266. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  267. .gpio_base = OMAP_MAX_GPIO_LINES,
  268. .irq_base = TWL4030_GPIO_IRQ_BASE,
  269. .irq_end = TWL4030_GPIO_IRQ_END,
  270. };
  271. static struct twl4030_madc_platform_data ldp_madc_data = {
  272. .irq_line = 1,
  273. };
  274. static struct regulator_consumer_supply ldp_vmmc1_supply = {
  275. .supply = "vmmc",
  276. };
  277. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  278. static struct regulator_init_data ldp_vmmc1 = {
  279. .constraints = {
  280. .min_uV = 1850000,
  281. .max_uV = 3150000,
  282. .valid_modes_mask = REGULATOR_MODE_NORMAL
  283. | REGULATOR_MODE_STANDBY,
  284. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  285. | REGULATOR_CHANGE_MODE
  286. | REGULATOR_CHANGE_STATUS,
  287. },
  288. .num_consumer_supplies = 1,
  289. .consumer_supplies = &ldp_vmmc1_supply,
  290. };
  291. /* ads7846 on SPI */
  292. static struct regulator_consumer_supply ldp_vaux1_supplies[] = {
  293. REGULATOR_SUPPLY("vcc", "spi1.0"),
  294. };
  295. /* VAUX1 */
  296. static struct regulator_init_data ldp_vaux1 = {
  297. .constraints = {
  298. .min_uV = 3000000,
  299. .max_uV = 3000000,
  300. .apply_uV = true,
  301. .valid_modes_mask = REGULATOR_MODE_NORMAL
  302. | REGULATOR_MODE_STANDBY,
  303. .valid_ops_mask = REGULATOR_CHANGE_MODE
  304. | REGULATOR_CHANGE_STATUS,
  305. },
  306. .num_consumer_supplies = ARRAY_SIZE(ldp_vaux1_supplies),
  307. .consumer_supplies = ldp_vaux1_supplies,
  308. };
  309. static struct twl4030_platform_data ldp_twldata = {
  310. .irq_base = TWL4030_IRQ_BASE,
  311. .irq_end = TWL4030_IRQ_END,
  312. /* platform_data for children goes here */
  313. .madc = &ldp_madc_data,
  314. .usb = &ldp_usb_data,
  315. .vmmc1 = &ldp_vmmc1,
  316. .vaux1 = &ldp_vaux1,
  317. .gpio = &ldp_gpio_data,
  318. .keypad = &ldp_kp_twl4030_data,
  319. };
  320. static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
  321. {
  322. I2C_BOARD_INFO("twl4030", 0x48),
  323. .flags = I2C_CLIENT_WAKE,
  324. .irq = INT_34XX_SYS_NIRQ,
  325. .platform_data = &ldp_twldata,
  326. },
  327. };
  328. static int __init omap_i2c_init(void)
  329. {
  330. omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
  331. ARRAY_SIZE(ldp_i2c_boardinfo));
  332. omap_register_i2c_bus(2, 400, NULL, 0);
  333. omap_register_i2c_bus(3, 400, NULL, 0);
  334. return 0;
  335. }
  336. static struct omap2_hsmmc_info mmc[] __initdata = {
  337. {
  338. .mmc = 1,
  339. .caps = MMC_CAP_4_BIT_DATA,
  340. .gpio_cd = -EINVAL,
  341. .gpio_wp = -EINVAL,
  342. },
  343. {} /* Terminator */
  344. };
  345. static struct platform_device *ldp_devices[] __initdata = {
  346. &ldp_smsc911x_device,
  347. &ldp_lcd_device,
  348. &ldp_gpio_keys_device,
  349. };
  350. #ifdef CONFIG_OMAP_MUX
  351. static struct omap_board_mux board_mux[] __initdata = {
  352. { .reg_offset = OMAP_MUX_TERMINATOR },
  353. };
  354. #endif
  355. static struct omap_musb_board_data musb_board_data = {
  356. .interface_type = MUSB_INTERFACE_ULPI,
  357. .mode = MUSB_OTG,
  358. .power = 100,
  359. };
  360. static struct mtd_partition ldp_nand_partitions[] = {
  361. /* All the partition sizes are listed in terms of NAND block size */
  362. {
  363. .name = "X-Loader-NAND",
  364. .offset = 0,
  365. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  366. .mask_flags = MTD_WRITEABLE, /* force read-only */
  367. },
  368. {
  369. .name = "U-Boot-NAND",
  370. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  371. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  372. .mask_flags = MTD_WRITEABLE, /* force read-only */
  373. },
  374. {
  375. .name = "Boot Env-NAND",
  376. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  377. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  378. },
  379. {
  380. .name = "Kernel-NAND",
  381. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  382. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  383. },
  384. {
  385. .name = "File System - NAND",
  386. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  387. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  388. },
  389. };
  390. static void __init omap_ldp_init(void)
  391. {
  392. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  393. omap_board_config = ldp_config;
  394. omap_board_config_size = ARRAY_SIZE(ldp_config);
  395. ldp_init_smsc911x();
  396. omap_i2c_init();
  397. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  398. ts_gpio = 54;
  399. ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
  400. spi_register_board_info(ldp_spi_board_info,
  401. ARRAY_SIZE(ldp_spi_board_info));
  402. ads7846_dev_init();
  403. omap_serial_init();
  404. usb_musb_init(&musb_board_data);
  405. board_nand_init(ldp_nand_partitions,
  406. ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
  407. omap2_hsmmc_init(mmc);
  408. /* link regulators to MMC adapters */
  409. ldp_vmmc1_supply.dev = mmc[0].dev;
  410. }
  411. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  412. .boot_params = 0x80000100,
  413. .reserve = omap_reserve,
  414. .map_io = omap3_map_io,
  415. .init_early = omap_ldp_init_early,
  416. .init_irq = omap_init_irq,
  417. .init_machine = omap_ldp_init,
  418. .timer = &omap_timer,
  419. MACHINE_END