board-ldp.c 10 KB

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