board-ldp.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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 <plat/gpmc-smsc911x.h>
  43. #include "board-flash.h"
  44. #include "mux.h"
  45. #include "hsmmc.h"
  46. #include "control.h"
  47. #define LDP_SMSC911X_CS 1
  48. #define LDP_SMSC911X_GPIO 152
  49. #define DEBUG_BASE 0x08000000
  50. #define LDP_ETHR_START DEBUG_BASE
  51. static uint32_t board_keymap[] = {
  52. KEY(0, 0, KEY_1),
  53. KEY(1, 0, KEY_2),
  54. KEY(2, 0, KEY_3),
  55. KEY(0, 1, KEY_4),
  56. KEY(1, 1, KEY_5),
  57. KEY(2, 1, KEY_6),
  58. KEY(3, 1, KEY_F5),
  59. KEY(0, 2, KEY_7),
  60. KEY(1, 2, KEY_8),
  61. KEY(2, 2, KEY_9),
  62. KEY(3, 2, KEY_F6),
  63. KEY(0, 3, KEY_F7),
  64. KEY(1, 3, KEY_0),
  65. KEY(2, 3, KEY_F8),
  66. PERSISTENT_KEY(4, 5),
  67. KEY(4, 4, KEY_VOLUMEUP),
  68. KEY(5, 5, KEY_VOLUMEDOWN),
  69. 0
  70. };
  71. static struct matrix_keymap_data board_map_data = {
  72. .keymap = board_keymap,
  73. .keymap_size = ARRAY_SIZE(board_keymap),
  74. };
  75. static struct twl4030_keypad_data ldp_kp_twl4030_data = {
  76. .keymap_data = &board_map_data,
  77. .rows = 6,
  78. .cols = 6,
  79. .rep = 1,
  80. };
  81. static struct gpio_keys_button ldp_gpio_keys_buttons[] = {
  82. [0] = {
  83. .code = KEY_ENTER,
  84. .gpio = 101,
  85. .desc = "enter sw",
  86. .active_low = 1,
  87. .debounce_interval = 30,
  88. },
  89. [1] = {
  90. .code = KEY_F1,
  91. .gpio = 102,
  92. .desc = "func 1",
  93. .active_low = 1,
  94. .debounce_interval = 30,
  95. },
  96. [2] = {
  97. .code = KEY_F2,
  98. .gpio = 103,
  99. .desc = "func 2",
  100. .active_low = 1,
  101. .debounce_interval = 30,
  102. },
  103. [3] = {
  104. .code = KEY_F3,
  105. .gpio = 104,
  106. .desc = "func 3",
  107. .active_low = 1,
  108. .debounce_interval = 30,
  109. },
  110. [4] = {
  111. .code = KEY_F4,
  112. .gpio = 105,
  113. .desc = "func 4",
  114. .active_low = 1,
  115. .debounce_interval = 30,
  116. },
  117. [5] = {
  118. .code = KEY_LEFT,
  119. .gpio = 106,
  120. .desc = "left sw",
  121. .active_low = 1,
  122. .debounce_interval = 30,
  123. },
  124. [6] = {
  125. .code = KEY_RIGHT,
  126. .gpio = 107,
  127. .desc = "right sw",
  128. .active_low = 1,
  129. .debounce_interval = 30,
  130. },
  131. [7] = {
  132. .code = KEY_UP,
  133. .gpio = 108,
  134. .desc = "up sw",
  135. .active_low = 1,
  136. .debounce_interval = 30,
  137. },
  138. [8] = {
  139. .code = KEY_DOWN,
  140. .gpio = 109,
  141. .desc = "down sw",
  142. .active_low = 1,
  143. .debounce_interval = 30,
  144. },
  145. };
  146. static struct gpio_keys_platform_data ldp_gpio_keys = {
  147. .buttons = ldp_gpio_keys_buttons,
  148. .nbuttons = ARRAY_SIZE(ldp_gpio_keys_buttons),
  149. .rep = 1,
  150. };
  151. static struct platform_device ldp_gpio_keys_device = {
  152. .name = "gpio-keys",
  153. .id = -1,
  154. .dev = {
  155. .platform_data = &ldp_gpio_keys,
  156. },
  157. };
  158. static int ts_gpio;
  159. /**
  160. * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
  161. *
  162. * @return - void. If request gpio fails then Flag KERN_ERR.
  163. */
  164. static void ads7846_dev_init(void)
  165. {
  166. if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
  167. printk(KERN_ERR "can't get ads746 pen down GPIO\n");
  168. return;
  169. }
  170. gpio_direction_input(ts_gpio);
  171. gpio_set_debounce(ts_gpio, 310);
  172. }
  173. static int ads7846_get_pendown_state(void)
  174. {
  175. return !gpio_get_value(ts_gpio);
  176. }
  177. static struct ads7846_platform_data tsc2046_config __initdata = {
  178. .get_pendown_state = ads7846_get_pendown_state,
  179. .keep_vref_on = 1,
  180. };
  181. static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
  182. .turbo_mode = 0,
  183. .single_channel = 1, /* 0: slave, 1: master */
  184. };
  185. static struct spi_board_info ldp_spi_board_info[] __initdata = {
  186. [0] = {
  187. /*
  188. * TSC2046 operates at a max freqency of 2MHz, so
  189. * operate slightly below at 1.5MHz
  190. */
  191. .modalias = "ads7846",
  192. .bus_num = 1,
  193. .chip_select = 0,
  194. .max_speed_hz = 1500000,
  195. .controller_data = &tsc2046_mcspi_config,
  196. .irq = 0,
  197. .platform_data = &tsc2046_config,
  198. },
  199. };
  200. static struct omap_smsc911x_platform_data smsc911x_cfg = {
  201. .cs = LDP_SMSC911X_CS,
  202. .gpio_irq = LDP_SMSC911X_GPIO,
  203. .gpio_reset = -EINVAL,
  204. .flags = SMSC911X_USE_32BIT,
  205. };
  206. static inline void __init ldp_init_smsc911x(void)
  207. {
  208. gpmc_smsc911x_init(&smsc911x_cfg);
  209. }
  210. static struct platform_device ldp_lcd_device = {
  211. .name = "ldp_lcd",
  212. .id = -1,
  213. };
  214. static struct omap_lcd_config ldp_lcd_config __initdata = {
  215. .ctrl_name = "internal",
  216. };
  217. static struct omap_board_config_kernel ldp_config[] __initdata = {
  218. { OMAP_TAG_LCD, &ldp_lcd_config },
  219. };
  220. static void __init omap_ldp_init_early(void)
  221. {
  222. omap2_init_common_infrastructure();
  223. omap2_init_common_devices(NULL, NULL);
  224. }
  225. static struct twl4030_usb_data ldp_usb_data = {
  226. .usb_mode = T2_USB_MODE_ULPI,
  227. };
  228. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  229. .gpio_base = OMAP_MAX_GPIO_LINES,
  230. .irq_base = TWL4030_GPIO_IRQ_BASE,
  231. .irq_end = TWL4030_GPIO_IRQ_END,
  232. };
  233. static struct twl4030_madc_platform_data ldp_madc_data = {
  234. .irq_line = 1,
  235. };
  236. static struct regulator_consumer_supply ldp_vmmc1_supply = {
  237. .supply = "vmmc",
  238. };
  239. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  240. static struct regulator_init_data ldp_vmmc1 = {
  241. .constraints = {
  242. .min_uV = 1850000,
  243. .max_uV = 3150000,
  244. .valid_modes_mask = REGULATOR_MODE_NORMAL
  245. | REGULATOR_MODE_STANDBY,
  246. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  247. | REGULATOR_CHANGE_MODE
  248. | REGULATOR_CHANGE_STATUS,
  249. },
  250. .num_consumer_supplies = 1,
  251. .consumer_supplies = &ldp_vmmc1_supply,
  252. };
  253. /* ads7846 on SPI */
  254. static struct regulator_consumer_supply ldp_vaux1_supplies[] = {
  255. REGULATOR_SUPPLY("vcc", "spi1.0"),
  256. };
  257. /* VAUX1 */
  258. static struct regulator_init_data ldp_vaux1 = {
  259. .constraints = {
  260. .min_uV = 3000000,
  261. .max_uV = 3000000,
  262. .apply_uV = true,
  263. .valid_modes_mask = REGULATOR_MODE_NORMAL
  264. | REGULATOR_MODE_STANDBY,
  265. .valid_ops_mask = REGULATOR_CHANGE_MODE
  266. | REGULATOR_CHANGE_STATUS,
  267. },
  268. .num_consumer_supplies = ARRAY_SIZE(ldp_vaux1_supplies),
  269. .consumer_supplies = ldp_vaux1_supplies,
  270. };
  271. static struct twl4030_platform_data ldp_twldata = {
  272. .irq_base = TWL4030_IRQ_BASE,
  273. .irq_end = TWL4030_IRQ_END,
  274. /* platform_data for children goes here */
  275. .madc = &ldp_madc_data,
  276. .usb = &ldp_usb_data,
  277. .vmmc1 = &ldp_vmmc1,
  278. .vaux1 = &ldp_vaux1,
  279. .gpio = &ldp_gpio_data,
  280. .keypad = &ldp_kp_twl4030_data,
  281. };
  282. static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
  283. {
  284. I2C_BOARD_INFO("twl4030", 0x48),
  285. .flags = I2C_CLIENT_WAKE,
  286. .irq = INT_34XX_SYS_NIRQ,
  287. .platform_data = &ldp_twldata,
  288. },
  289. };
  290. static int __init omap_i2c_init(void)
  291. {
  292. omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
  293. ARRAY_SIZE(ldp_i2c_boardinfo));
  294. omap_register_i2c_bus(2, 400, NULL, 0);
  295. omap_register_i2c_bus(3, 400, NULL, 0);
  296. return 0;
  297. }
  298. static struct omap2_hsmmc_info mmc[] __initdata = {
  299. {
  300. .mmc = 1,
  301. .caps = MMC_CAP_4_BIT_DATA,
  302. .gpio_cd = -EINVAL,
  303. .gpio_wp = -EINVAL,
  304. },
  305. {} /* Terminator */
  306. };
  307. static struct platform_device *ldp_devices[] __initdata = {
  308. &ldp_lcd_device,
  309. &ldp_gpio_keys_device,
  310. };
  311. #ifdef CONFIG_OMAP_MUX
  312. static struct omap_board_mux board_mux[] __initdata = {
  313. { .reg_offset = OMAP_MUX_TERMINATOR },
  314. };
  315. #endif
  316. static struct omap_musb_board_data musb_board_data = {
  317. .interface_type = MUSB_INTERFACE_ULPI,
  318. .mode = MUSB_OTG,
  319. .power = 100,
  320. };
  321. static struct mtd_partition ldp_nand_partitions[] = {
  322. /* All the partition sizes are listed in terms of NAND block size */
  323. {
  324. .name = "X-Loader-NAND",
  325. .offset = 0,
  326. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  327. .mask_flags = MTD_WRITEABLE, /* force read-only */
  328. },
  329. {
  330. .name = "U-Boot-NAND",
  331. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  332. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  333. .mask_flags = MTD_WRITEABLE, /* force read-only */
  334. },
  335. {
  336. .name = "Boot Env-NAND",
  337. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  338. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  339. },
  340. {
  341. .name = "Kernel-NAND",
  342. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  343. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  344. },
  345. {
  346. .name = "File System - NAND",
  347. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  348. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  349. },
  350. };
  351. static void __init omap_ldp_init(void)
  352. {
  353. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  354. omap_board_config = ldp_config;
  355. omap_board_config_size = ARRAY_SIZE(ldp_config);
  356. ldp_init_smsc911x();
  357. omap_i2c_init();
  358. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  359. ts_gpio = 54;
  360. ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
  361. spi_register_board_info(ldp_spi_board_info,
  362. ARRAY_SIZE(ldp_spi_board_info));
  363. ads7846_dev_init();
  364. omap_serial_init();
  365. usb_musb_init(&musb_board_data);
  366. board_nand_init(ldp_nand_partitions,
  367. ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
  368. omap2_hsmmc_init(mmc);
  369. /* link regulators to MMC adapters */
  370. ldp_vmmc1_supply.dev = mmc[0].dev;
  371. }
  372. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  373. .boot_params = 0x80000100,
  374. .reserve = omap_reserve,
  375. .map_io = omap3_map_io,
  376. .init_early = omap_ldp_init_early,
  377. .init_irq = omap_init_irq,
  378. .init_machine = omap_ldp_init,
  379. .timer = &omap_timer,
  380. MACHINE_END