board-ldp.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. int res;
  216. /* LCD enable GPIO */
  217. ldp_lcd_pdata.enable_gpio = gpio + 7;
  218. /* Backlight enable GPIO */
  219. ldp_lcd_pdata.backlight_gpio = gpio + 15;
  220. res = platform_device_register(&ldp_lcd_device);
  221. if (res)
  222. pr_err("Unable to register LCD: %d\n", res);
  223. return 0;
  224. }
  225. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  226. .setup = ldp_twl_gpio_setup,
  227. };
  228. static struct regulator_consumer_supply ldp_vmmc1_supply[] = {
  229. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  230. };
  231. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  232. static struct regulator_init_data ldp_vmmc1 = {
  233. .constraints = {
  234. .min_uV = 1850000,
  235. .max_uV = 3150000,
  236. .valid_modes_mask = REGULATOR_MODE_NORMAL
  237. | REGULATOR_MODE_STANDBY,
  238. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  239. | REGULATOR_CHANGE_MODE
  240. | REGULATOR_CHANGE_STATUS,
  241. },
  242. .num_consumer_supplies = ARRAY_SIZE(ldp_vmmc1_supply),
  243. .consumer_supplies = ldp_vmmc1_supply,
  244. };
  245. /* ads7846 on SPI */
  246. static struct regulator_consumer_supply ldp_vaux1_supplies[] = {
  247. REGULATOR_SUPPLY("vcc", "spi1.0"),
  248. };
  249. /* VAUX1 */
  250. static struct regulator_init_data ldp_vaux1 = {
  251. .constraints = {
  252. .min_uV = 3000000,
  253. .max_uV = 3000000,
  254. .apply_uV = true,
  255. .valid_modes_mask = REGULATOR_MODE_NORMAL
  256. | REGULATOR_MODE_STANDBY,
  257. .valid_ops_mask = REGULATOR_CHANGE_MODE
  258. | REGULATOR_CHANGE_STATUS,
  259. },
  260. .num_consumer_supplies = ARRAY_SIZE(ldp_vaux1_supplies),
  261. .consumer_supplies = ldp_vaux1_supplies,
  262. };
  263. static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
  264. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  265. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
  266. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
  267. };
  268. static struct regulator_init_data ldp_vpll2 = {
  269. .constraints = {
  270. .name = "VDVI",
  271. .min_uV = 1800000,
  272. .max_uV = 1800000,
  273. .apply_uV = true,
  274. .valid_modes_mask = REGULATOR_MODE_NORMAL
  275. | REGULATOR_MODE_STANDBY,
  276. .valid_ops_mask = REGULATOR_CHANGE_MODE
  277. | REGULATOR_CHANGE_STATUS,
  278. },
  279. .num_consumer_supplies = ARRAY_SIZE(ldp_vpll2_supplies),
  280. .consumer_supplies = ldp_vpll2_supplies,
  281. };
  282. static struct twl4030_platform_data ldp_twldata = {
  283. /* platform_data for children goes here */
  284. .vmmc1 = &ldp_vmmc1,
  285. .vaux1 = &ldp_vaux1,
  286. .vpll2 = &ldp_vpll2,
  287. .gpio = &ldp_gpio_data,
  288. .keypad = &ldp_kp_twl4030_data,
  289. };
  290. static int __init omap_i2c_init(void)
  291. {
  292. omap3_pmic_get_config(&ldp_twldata,
  293. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC, 0);
  294. omap3_pmic_init("twl4030", &ldp_twldata);
  295. omap_register_i2c_bus(2, 400, NULL, 0);
  296. omap_register_i2c_bus(3, 400, NULL, 0);
  297. return 0;
  298. }
  299. static struct omap2_hsmmc_info mmc[] __initdata = {
  300. {
  301. .mmc = 1,
  302. .caps = MMC_CAP_4_BIT_DATA,
  303. .gpio_cd = -EINVAL,
  304. .gpio_wp = -EINVAL,
  305. },
  306. {} /* Terminator */
  307. };
  308. static struct platform_device *ldp_devices[] __initdata = {
  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 mtd_partition ldp_nand_partitions[] = {
  317. /* All the partition sizes are listed in terms of NAND block size */
  318. {
  319. .name = "X-Loader-NAND",
  320. .offset = 0,
  321. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  322. .mask_flags = MTD_WRITEABLE, /* force read-only */
  323. },
  324. {
  325. .name = "U-Boot-NAND",
  326. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  327. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  328. .mask_flags = MTD_WRITEABLE, /* force read-only */
  329. },
  330. {
  331. .name = "Boot Env-NAND",
  332. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  333. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  334. },
  335. {
  336. .name = "Kernel-NAND",
  337. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  338. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  339. },
  340. {
  341. .name = "File System - NAND",
  342. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  343. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  344. },
  345. };
  346. static struct regulator_consumer_supply dummy_supplies[] = {
  347. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  348. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  349. };
  350. static void __init omap_ldp_init(void)
  351. {
  352. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  353. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  354. ldp_init_smsc911x();
  355. omap_i2c_init();
  356. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  357. omap_ads7846_init(1, 54, 310, NULL);
  358. omap_serial_init();
  359. omap_sdrc_init(NULL, NULL);
  360. usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
  361. usb_musb_init(NULL);
  362. board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions),
  363. 0, 0, nand_default_timings);
  364. omap_hsmmc_init(mmc);
  365. ldp_display_init();
  366. }
  367. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  368. .atag_offset = 0x100,
  369. .reserve = omap_reserve,
  370. .map_io = omap3_map_io,
  371. .init_early = omap3430_init_early,
  372. .init_irq = omap3_init_irq,
  373. .init_machine = omap_ldp_init,
  374. .init_late = omap3430_init_late,
  375. .init_time = omap3_sync32k_timer_init,
  376. .restart = omap3xxx_restart,
  377. MACHINE_END