board-ldp.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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 "board-zoom.h"
  38. #include "gpmc.h"
  39. #include "gpmc-smsc911x.h"
  40. #include <video/omapdss.h>
  41. #include <video/omap-panel-data.h>
  42. #include "board-flash.h"
  43. #include "mux.h"
  44. #include "hsmmc.h"
  45. #include "control.h"
  46. #include "common-board-devices.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 struct omap_smsc911x_platform_data smsc911x_cfg = {
  159. .cs = LDP_SMSC911X_CS,
  160. .gpio_irq = LDP_SMSC911X_GPIO,
  161. .gpio_reset = -EINVAL,
  162. .flags = SMSC911X_USE_32BIT,
  163. };
  164. static inline void __init ldp_init_smsc911x(void)
  165. {
  166. gpmc_smsc911x_init(&smsc911x_cfg);
  167. }
  168. /* LCD */
  169. #define LCD_PANEL_RESET_GPIO 55
  170. #define LCD_PANEL_QVGA_GPIO 56
  171. static const struct display_timing ldp_lcd_videomode = {
  172. .pixelclock = { 0, 5400000, 0 },
  173. .hactive = { 0, 240, 0 },
  174. .hfront_porch = { 0, 3, 0 },
  175. .hback_porch = { 0, 39, 0 },
  176. .hsync_len = { 0, 3, 0 },
  177. .vactive = { 0, 320, 0 },
  178. .vfront_porch = { 0, 2, 0 },
  179. .vback_porch = { 0, 7, 0 },
  180. .vsync_len = { 0, 1, 0 },
  181. .flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW |
  182. DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE,
  183. };
  184. static struct panel_dpi_platform_data ldp_lcd_pdata = {
  185. .name = "lcd",
  186. .source = "dpi.0",
  187. .data_lines = 18,
  188. .display_timing = &ldp_lcd_videomode,
  189. .enable_gpio = -1, /* filled in code */
  190. .backlight_gpio = -1, /* filled in code */
  191. };
  192. static struct platform_device ldp_lcd_device = {
  193. .name = "panel-dpi",
  194. .id = 0,
  195. .dev.platform_data = &ldp_lcd_pdata,
  196. };
  197. static struct omap_dss_board_info ldp_dss_data = {
  198. .default_display_name = "lcd",
  199. };
  200. static void __init ldp_display_init(void)
  201. {
  202. int r;
  203. static struct gpio gpios[] __initdata = {
  204. {LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
  205. {LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
  206. };
  207. r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
  208. if (r) {
  209. pr_err("Cannot request LCD GPIOs, error %d\n", r);
  210. return;
  211. }
  212. omap_display_init(&ldp_dss_data);
  213. }
  214. static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
  215. {
  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. return 0;
  221. }
  222. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  223. .setup = ldp_twl_gpio_setup,
  224. };
  225. static struct regulator_consumer_supply ldp_vmmc1_supply[] = {
  226. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  227. };
  228. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  229. static struct regulator_init_data ldp_vmmc1 = {
  230. .constraints = {
  231. .min_uV = 1850000,
  232. .max_uV = 3150000,
  233. .valid_modes_mask = REGULATOR_MODE_NORMAL
  234. | REGULATOR_MODE_STANDBY,
  235. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  236. | REGULATOR_CHANGE_MODE
  237. | REGULATOR_CHANGE_STATUS,
  238. },
  239. .num_consumer_supplies = ARRAY_SIZE(ldp_vmmc1_supply),
  240. .consumer_supplies = ldp_vmmc1_supply,
  241. };
  242. /* ads7846 on SPI */
  243. static struct regulator_consumer_supply ldp_vaux1_supplies[] = {
  244. REGULATOR_SUPPLY("vcc", "spi1.0"),
  245. };
  246. /* VAUX1 */
  247. static struct regulator_init_data ldp_vaux1 = {
  248. .constraints = {
  249. .min_uV = 3000000,
  250. .max_uV = 3000000,
  251. .apply_uV = true,
  252. .valid_modes_mask = REGULATOR_MODE_NORMAL
  253. | REGULATOR_MODE_STANDBY,
  254. .valid_ops_mask = REGULATOR_CHANGE_MODE
  255. | REGULATOR_CHANGE_STATUS,
  256. },
  257. .num_consumer_supplies = ARRAY_SIZE(ldp_vaux1_supplies),
  258. .consumer_supplies = ldp_vaux1_supplies,
  259. };
  260. static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
  261. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  262. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
  263. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
  264. };
  265. static struct regulator_init_data ldp_vpll2 = {
  266. .constraints = {
  267. .name = "VDVI",
  268. .min_uV = 1800000,
  269. .max_uV = 1800000,
  270. .apply_uV = true,
  271. .valid_modes_mask = REGULATOR_MODE_NORMAL
  272. | REGULATOR_MODE_STANDBY,
  273. .valid_ops_mask = REGULATOR_CHANGE_MODE
  274. | REGULATOR_CHANGE_STATUS,
  275. },
  276. .num_consumer_supplies = ARRAY_SIZE(ldp_vpll2_supplies),
  277. .consumer_supplies = ldp_vpll2_supplies,
  278. };
  279. static struct twl4030_platform_data ldp_twldata = {
  280. /* platform_data for children goes here */
  281. .vmmc1 = &ldp_vmmc1,
  282. .vaux1 = &ldp_vaux1,
  283. .vpll2 = &ldp_vpll2,
  284. .gpio = &ldp_gpio_data,
  285. .keypad = &ldp_kp_twl4030_data,
  286. };
  287. static int __init omap_i2c_init(void)
  288. {
  289. omap3_pmic_get_config(&ldp_twldata,
  290. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC, 0);
  291. omap3_pmic_init("twl4030", &ldp_twldata);
  292. omap_register_i2c_bus(2, 400, NULL, 0);
  293. omap_register_i2c_bus(3, 400, NULL, 0);
  294. return 0;
  295. }
  296. static struct omap2_hsmmc_info mmc[] __initdata = {
  297. {
  298. .mmc = 1,
  299. .caps = MMC_CAP_4_BIT_DATA,
  300. .gpio_cd = -EINVAL,
  301. .gpio_wp = -EINVAL,
  302. },
  303. {} /* Terminator */
  304. };
  305. static struct platform_device *ldp_devices[] __initdata = {
  306. &ldp_gpio_keys_device,
  307. &ldp_lcd_device,
  308. };
  309. #ifdef CONFIG_OMAP_MUX
  310. static struct omap_board_mux board_mux[] __initdata = {
  311. { .reg_offset = OMAP_MUX_TERMINATOR },
  312. };
  313. #endif
  314. static struct mtd_partition ldp_nand_partitions[] = {
  315. /* All the partition sizes are listed in terms of NAND block size */
  316. {
  317. .name = "X-Loader-NAND",
  318. .offset = 0,
  319. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  320. .mask_flags = MTD_WRITEABLE, /* force read-only */
  321. },
  322. {
  323. .name = "U-Boot-NAND",
  324. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  325. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  326. .mask_flags = MTD_WRITEABLE, /* force read-only */
  327. },
  328. {
  329. .name = "Boot Env-NAND",
  330. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  331. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  332. },
  333. {
  334. .name = "Kernel-NAND",
  335. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  336. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  337. },
  338. {
  339. .name = "File System - NAND",
  340. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  341. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  342. },
  343. };
  344. static struct regulator_consumer_supply dummy_supplies[] = {
  345. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  346. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  347. };
  348. static void __init omap_ldp_init(void)
  349. {
  350. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  351. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  352. ldp_init_smsc911x();
  353. omap_i2c_init();
  354. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  355. omap_ads7846_init(1, 54, 310, NULL);
  356. omap_serial_init();
  357. omap_sdrc_init(NULL, NULL);
  358. usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
  359. usb_musb_init(NULL);
  360. board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions),
  361. ZOOM_NAND_CS, 0, nand_default_timings);
  362. omap_hsmmc_init(mmc);
  363. ldp_display_init();
  364. }
  365. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  366. .atag_offset = 0x100,
  367. .reserve = omap_reserve,
  368. .map_io = omap3_map_io,
  369. .init_early = omap3430_init_early,
  370. .init_irq = omap3_init_irq,
  371. .handle_irq = omap3_intc_handle_irq,
  372. .init_machine = omap_ldp_init,
  373. .init_late = omap3430_init_late,
  374. .init_time = omap3_sync32k_timer_init,
  375. .restart = omap3xxx_restart,
  376. MACHINE_END