board-ldp.c 10 KB

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