board-ldp.c 10.0 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/gpio.h>
  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/gpio_keys.h>
  21. #include <linux/workqueue.h>
  22. #include <linux/err.h>
  23. #include <linux/clk.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/regulator/fixed.h>
  26. #include <linux/regulator/machine.h>
  27. #include <linux/i2c/twl.h>
  28. #include <linux/io.h>
  29. #include <linux/smsc911x.h>
  30. #include <linux/mmc/host.h>
  31. #include <linux/usb/phy.h>
  32. #include <linux/platform_data/spi-omap2-mcspi.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include "common.h"
  37. #include "gpmc.h"
  38. #include "gpmc-smsc911x.h"
  39. #include <video/omapdss.h>
  40. #include <video/omap-panel-data.h>
  41. #include "board-flash.h"
  42. #include "mux.h"
  43. #include "hsmmc.h"
  44. #include "control.h"
  45. #include "common-board-devices.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 uint32_t board_keymap[] = {
  51. KEY(0, 0, KEY_1),
  52. KEY(1, 0, KEY_2),
  53. KEY(2, 0, KEY_3),
  54. KEY(0, 1, KEY_4),
  55. KEY(1, 1, KEY_5),
  56. KEY(2, 1, KEY_6),
  57. KEY(3, 1, KEY_F5),
  58. KEY(0, 2, KEY_7),
  59. KEY(1, 2, KEY_8),
  60. KEY(2, 2, KEY_9),
  61. KEY(3, 2, KEY_F6),
  62. KEY(0, 3, KEY_F7),
  63. KEY(1, 3, KEY_0),
  64. KEY(2, 3, KEY_F8),
  65. PERSISTENT_KEY(4, 5),
  66. KEY(4, 4, KEY_VOLUMEUP),
  67. KEY(5, 5, KEY_VOLUMEDOWN),
  68. 0
  69. };
  70. static struct matrix_keymap_data board_map_data = {
  71. .keymap = board_keymap,
  72. .keymap_size = ARRAY_SIZE(board_keymap),
  73. };
  74. static struct twl4030_keypad_data ldp_kp_twl4030_data = {
  75. .keymap_data = &board_map_data,
  76. .rows = 6,
  77. .cols = 6,
  78. .rep = 1,
  79. };
  80. static struct gpio_keys_button ldp_gpio_keys_buttons[] = {
  81. [0] = {
  82. .code = KEY_ENTER,
  83. .gpio = 101,
  84. .desc = "enter sw",
  85. .active_low = 1,
  86. .debounce_interval = 30,
  87. },
  88. [1] = {
  89. .code = KEY_F1,
  90. .gpio = 102,
  91. .desc = "func 1",
  92. .active_low = 1,
  93. .debounce_interval = 30,
  94. },
  95. [2] = {
  96. .code = KEY_F2,
  97. .gpio = 103,
  98. .desc = "func 2",
  99. .active_low = 1,
  100. .debounce_interval = 30,
  101. },
  102. [3] = {
  103. .code = KEY_F3,
  104. .gpio = 104,
  105. .desc = "func 3",
  106. .active_low = 1,
  107. .debounce_interval = 30,
  108. },
  109. [4] = {
  110. .code = KEY_F4,
  111. .gpio = 105,
  112. .desc = "func 4",
  113. .active_low = 1,
  114. .debounce_interval = 30,
  115. },
  116. [5] = {
  117. .code = KEY_LEFT,
  118. .gpio = 106,
  119. .desc = "left sw",
  120. .active_low = 1,
  121. .debounce_interval = 30,
  122. },
  123. [6] = {
  124. .code = KEY_RIGHT,
  125. .gpio = 107,
  126. .desc = "right sw",
  127. .active_low = 1,
  128. .debounce_interval = 30,
  129. },
  130. [7] = {
  131. .code = KEY_UP,
  132. .gpio = 108,
  133. .desc = "up sw",
  134. .active_low = 1,
  135. .debounce_interval = 30,
  136. },
  137. [8] = {
  138. .code = KEY_DOWN,
  139. .gpio = 109,
  140. .desc = "down sw",
  141. .active_low = 1,
  142. .debounce_interval = 30,
  143. },
  144. };
  145. static struct gpio_keys_platform_data ldp_gpio_keys = {
  146. .buttons = ldp_gpio_keys_buttons,
  147. .nbuttons = ARRAY_SIZE(ldp_gpio_keys_buttons),
  148. .rep = 1,
  149. };
  150. static struct platform_device ldp_gpio_keys_device = {
  151. .name = "gpio-keys",
  152. .id = -1,
  153. .dev = {
  154. .platform_data = &ldp_gpio_keys,
  155. },
  156. };
  157. static struct omap_smsc911x_platform_data smsc911x_cfg = {
  158. .cs = LDP_SMSC911X_CS,
  159. .gpio_irq = LDP_SMSC911X_GPIO,
  160. .gpio_reset = -EINVAL,
  161. .flags = SMSC911X_USE_32BIT,
  162. };
  163. static inline void __init ldp_init_smsc911x(void)
  164. {
  165. gpmc_smsc911x_init(&smsc911x_cfg);
  166. }
  167. /* LCD */
  168. #define LCD_PANEL_RESET_GPIO 55
  169. #define LCD_PANEL_QVGA_GPIO 56
  170. static const struct display_timing ldp_lcd_videomode = {
  171. .pixelclock = { 0, 5400000, 0 },
  172. .hactive = { 0, 240, 0 },
  173. .hfront_porch = { 0, 3, 0 },
  174. .hback_porch = { 0, 39, 0 },
  175. .hsync_len = { 0, 3, 0 },
  176. .vactive = { 0, 320, 0 },
  177. .vfront_porch = { 0, 2, 0 },
  178. .vback_porch = { 0, 7, 0 },
  179. .vsync_len = { 0, 1, 0 },
  180. .flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW |
  181. DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE,
  182. };
  183. static struct panel_dpi_platform_data ldp_lcd_pdata = {
  184. .name = "lcd",
  185. .source = "dpi.0",
  186. .data_lines = 18,
  187. .display_timing = &ldp_lcd_videomode,
  188. .enable_gpio = -1, /* filled in code */
  189. .backlight_gpio = -1, /* filled in code */
  190. };
  191. static struct platform_device ldp_lcd_device = {
  192. .name = "panel-dpi",
  193. .id = 0,
  194. .dev.platform_data = &ldp_lcd_pdata,
  195. };
  196. static struct omap_dss_board_info ldp_dss_data = {
  197. .default_display_name = "lcd",
  198. };
  199. static void __init ldp_display_init(void)
  200. {
  201. int r;
  202. static struct gpio gpios[] __initdata = {
  203. {LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
  204. {LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
  205. };
  206. r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
  207. if (r) {
  208. pr_err("Cannot request LCD GPIOs, error %d\n", r);
  209. return;
  210. }
  211. omap_display_init(&ldp_dss_data);
  212. }
  213. static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
  214. {
  215. /* LCD enable GPIO */
  216. ldp_lcd_pdata.enable_gpio = gpio + 7;
  217. /* Backlight enable GPIO */
  218. ldp_lcd_pdata.backlight_gpio = gpio + 15;
  219. return 0;
  220. }
  221. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  222. .setup = ldp_twl_gpio_setup,
  223. };
  224. static struct regulator_consumer_supply ldp_vmmc1_supply[] = {
  225. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  226. };
  227. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  228. static struct regulator_init_data ldp_vmmc1 = {
  229. .constraints = {
  230. .min_uV = 1850000,
  231. .max_uV = 3150000,
  232. .valid_modes_mask = REGULATOR_MODE_NORMAL
  233. | REGULATOR_MODE_STANDBY,
  234. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  235. | REGULATOR_CHANGE_MODE
  236. | REGULATOR_CHANGE_STATUS,
  237. },
  238. .num_consumer_supplies = ARRAY_SIZE(ldp_vmmc1_supply),
  239. .consumer_supplies = ldp_vmmc1_supply,
  240. };
  241. /* ads7846 on SPI */
  242. static struct regulator_consumer_supply ldp_vaux1_supplies[] = {
  243. REGULATOR_SUPPLY("vcc", "spi1.0"),
  244. };
  245. /* VAUX1 */
  246. static struct regulator_init_data ldp_vaux1 = {
  247. .constraints = {
  248. .min_uV = 3000000,
  249. .max_uV = 3000000,
  250. .apply_uV = true,
  251. .valid_modes_mask = REGULATOR_MODE_NORMAL
  252. | REGULATOR_MODE_STANDBY,
  253. .valid_ops_mask = REGULATOR_CHANGE_MODE
  254. | REGULATOR_CHANGE_STATUS,
  255. },
  256. .num_consumer_supplies = ARRAY_SIZE(ldp_vaux1_supplies),
  257. .consumer_supplies = ldp_vaux1_supplies,
  258. };
  259. static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
  260. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  261. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
  262. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
  263. };
  264. static struct regulator_init_data ldp_vpll2 = {
  265. .constraints = {
  266. .name = "VDVI",
  267. .min_uV = 1800000,
  268. .max_uV = 1800000,
  269. .apply_uV = true,
  270. .valid_modes_mask = REGULATOR_MODE_NORMAL
  271. | REGULATOR_MODE_STANDBY,
  272. .valid_ops_mask = REGULATOR_CHANGE_MODE
  273. | REGULATOR_CHANGE_STATUS,
  274. },
  275. .num_consumer_supplies = ARRAY_SIZE(ldp_vpll2_supplies),
  276. .consumer_supplies = ldp_vpll2_supplies,
  277. };
  278. static struct twl4030_platform_data ldp_twldata = {
  279. /* platform_data for children goes here */
  280. .vmmc1 = &ldp_vmmc1,
  281. .vaux1 = &ldp_vaux1,
  282. .vpll2 = &ldp_vpll2,
  283. .gpio = &ldp_gpio_data,
  284. .keypad = &ldp_kp_twl4030_data,
  285. };
  286. static int __init omap_i2c_init(void)
  287. {
  288. omap3_pmic_get_config(&ldp_twldata,
  289. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC, 0);
  290. omap3_pmic_init("twl4030", &ldp_twldata);
  291. omap_register_i2c_bus(2, 400, NULL, 0);
  292. omap_register_i2c_bus(3, 400, NULL, 0);
  293. return 0;
  294. }
  295. static struct omap2_hsmmc_info mmc[] __initdata = {
  296. {
  297. .mmc = 1,
  298. .caps = MMC_CAP_4_BIT_DATA,
  299. .gpio_cd = -EINVAL,
  300. .gpio_wp = -EINVAL,
  301. },
  302. {} /* Terminator */
  303. };
  304. static struct platform_device *ldp_devices[] __initdata = {
  305. &ldp_gpio_keys_device,
  306. &ldp_lcd_device,
  307. };
  308. #ifdef CONFIG_OMAP_MUX
  309. static struct omap_board_mux board_mux[] __initdata = {
  310. { .reg_offset = OMAP_MUX_TERMINATOR },
  311. };
  312. #endif
  313. static struct mtd_partition ldp_nand_partitions[] = {
  314. /* All the partition sizes are listed in terms of NAND block size */
  315. {
  316. .name = "X-Loader-NAND",
  317. .offset = 0,
  318. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  319. .mask_flags = MTD_WRITEABLE, /* force read-only */
  320. },
  321. {
  322. .name = "U-Boot-NAND",
  323. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  324. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  325. .mask_flags = MTD_WRITEABLE, /* force read-only */
  326. },
  327. {
  328. .name = "Boot Env-NAND",
  329. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  330. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  331. },
  332. {
  333. .name = "Kernel-NAND",
  334. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  335. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  336. },
  337. {
  338. .name = "File System - NAND",
  339. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  340. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  341. },
  342. };
  343. static struct regulator_consumer_supply dummy_supplies[] = {
  344. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  345. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  346. };
  347. static void __init omap_ldp_init(void)
  348. {
  349. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  350. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  351. ldp_init_smsc911x();
  352. omap_i2c_init();
  353. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  354. omap_ads7846_init(1, 54, 310, NULL);
  355. omap_serial_init();
  356. omap_sdrc_init(NULL, NULL);
  357. usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
  358. usb_musb_init(NULL);
  359. board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions),
  360. 0, 0, nand_default_timings);
  361. omap_hsmmc_init(mmc);
  362. ldp_display_init();
  363. }
  364. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  365. .atag_offset = 0x100,
  366. .reserve = omap_reserve,
  367. .map_io = omap3_map_io,
  368. .init_early = omap3430_init_early,
  369. .init_irq = omap3_init_irq,
  370. .handle_irq = omap3_intc_handle_irq,
  371. .init_machine = omap_ldp_init,
  372. .init_late = omap3430_init_late,
  373. .init_time = omap3_sync32k_timer_init,
  374. .restart = omap3xxx_restart,
  375. MACHINE_END