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/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/platform_data/spi-omap2-mcspi.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include "common.h"
  36. #include "board-zoom.h"
  37. #include "gpmc.h"
  38. #include "gpmc-smsc911x.h"
  39. #include <video/omapdss.h>
  40. #include <video/omap-panel-generic-dpi.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. static int ldp_backlight_gpio;
  169. static int ldp_lcd_enable_gpio;
  170. #define LCD_PANEL_RESET_GPIO 55
  171. #define LCD_PANEL_QVGA_GPIO 56
  172. static int ldp_panel_enable_lcd(struct omap_dss_device *dssdev)
  173. {
  174. if (gpio_is_valid(ldp_lcd_enable_gpio))
  175. gpio_direction_output(ldp_lcd_enable_gpio, 1);
  176. if (gpio_is_valid(ldp_backlight_gpio))
  177. gpio_direction_output(ldp_backlight_gpio, 1);
  178. return 0;
  179. }
  180. static void ldp_panel_disable_lcd(struct omap_dss_device *dssdev)
  181. {
  182. if (gpio_is_valid(ldp_lcd_enable_gpio))
  183. gpio_direction_output(ldp_lcd_enable_gpio, 0);
  184. if (gpio_is_valid(ldp_backlight_gpio))
  185. gpio_direction_output(ldp_backlight_gpio, 0);
  186. }
  187. static struct panel_generic_dpi_data ldp_panel_data = {
  188. .name = "nec_nl2432dr22-11b",
  189. .platform_enable = ldp_panel_enable_lcd,
  190. .platform_disable = ldp_panel_disable_lcd,
  191. };
  192. static struct omap_dss_device ldp_lcd_device = {
  193. .name = "lcd",
  194. .driver_name = "generic_dpi_panel",
  195. .type = OMAP_DISPLAY_TYPE_DPI,
  196. .phy.dpi.data_lines = 18,
  197. .data = &ldp_panel_data,
  198. };
  199. static struct omap_dss_device *ldp_dss_devices[] = {
  200. &ldp_lcd_device,
  201. };
  202. static struct omap_dss_board_info ldp_dss_data = {
  203. .num_devices = ARRAY_SIZE(ldp_dss_devices),
  204. .devices = ldp_dss_devices,
  205. .default_device = &ldp_lcd_device,
  206. };
  207. static void __init ldp_display_init(void)
  208. {
  209. int r;
  210. static struct gpio gpios[] __initdata = {
  211. {LCD_PANEL_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "LCD RESET"},
  212. {LCD_PANEL_QVGA_GPIO, GPIOF_OUT_INIT_HIGH, "LCD QVGA"},
  213. };
  214. r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
  215. if (r) {
  216. pr_err("Cannot request LCD GPIOs, error %d\n", r);
  217. return;
  218. }
  219. omap_display_init(&ldp_dss_data);
  220. }
  221. static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio)
  222. {
  223. int r;
  224. struct gpio gpios[] = {
  225. {gpio + 7 , GPIOF_OUT_INIT_LOW, "LCD ENABLE"},
  226. {gpio + 15, GPIOF_OUT_INIT_LOW, "LCD BACKLIGHT"},
  227. };
  228. r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
  229. if (r) {
  230. pr_err("Cannot request LCD GPIOs, error %d\n", r);
  231. ldp_backlight_gpio = -EINVAL;
  232. ldp_lcd_enable_gpio = -EINVAL;
  233. return r;
  234. }
  235. ldp_backlight_gpio = gpio + 15;
  236. ldp_lcd_enable_gpio = gpio + 7;
  237. return 0;
  238. }
  239. static struct twl4030_gpio_platform_data ldp_gpio_data = {
  240. .setup = ldp_twl_gpio_setup,
  241. };
  242. static struct regulator_consumer_supply ldp_vmmc1_supply[] = {
  243. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  244. };
  245. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  246. static struct regulator_init_data ldp_vmmc1 = {
  247. .constraints = {
  248. .min_uV = 1850000,
  249. .max_uV = 3150000,
  250. .valid_modes_mask = REGULATOR_MODE_NORMAL
  251. | REGULATOR_MODE_STANDBY,
  252. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  253. | REGULATOR_CHANGE_MODE
  254. | REGULATOR_CHANGE_STATUS,
  255. },
  256. .num_consumer_supplies = ARRAY_SIZE(ldp_vmmc1_supply),
  257. .consumer_supplies = ldp_vmmc1_supply,
  258. };
  259. /* ads7846 on SPI */
  260. static struct regulator_consumer_supply ldp_vaux1_supplies[] = {
  261. REGULATOR_SUPPLY("vcc", "spi1.0"),
  262. };
  263. /* VAUX1 */
  264. static struct regulator_init_data ldp_vaux1 = {
  265. .constraints = {
  266. .min_uV = 3000000,
  267. .max_uV = 3000000,
  268. .apply_uV = true,
  269. .valid_modes_mask = REGULATOR_MODE_NORMAL
  270. | REGULATOR_MODE_STANDBY,
  271. .valid_ops_mask = REGULATOR_CHANGE_MODE
  272. | REGULATOR_CHANGE_STATUS,
  273. },
  274. .num_consumer_supplies = ARRAY_SIZE(ldp_vaux1_supplies),
  275. .consumer_supplies = ldp_vaux1_supplies,
  276. };
  277. static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
  278. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  279. REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
  280. };
  281. static struct regulator_init_data ldp_vpll2 = {
  282. .constraints = {
  283. .name = "VDVI",
  284. .min_uV = 1800000,
  285. .max_uV = 1800000,
  286. .apply_uV = true,
  287. .valid_modes_mask = REGULATOR_MODE_NORMAL
  288. | REGULATOR_MODE_STANDBY,
  289. .valid_ops_mask = REGULATOR_CHANGE_MODE
  290. | REGULATOR_CHANGE_STATUS,
  291. },
  292. .num_consumer_supplies = ARRAY_SIZE(ldp_vpll2_supplies),
  293. .consumer_supplies = ldp_vpll2_supplies,
  294. };
  295. static struct twl4030_platform_data ldp_twldata = {
  296. /* platform_data for children goes here */
  297. .vmmc1 = &ldp_vmmc1,
  298. .vaux1 = &ldp_vaux1,
  299. .vpll2 = &ldp_vpll2,
  300. .gpio = &ldp_gpio_data,
  301. .keypad = &ldp_kp_twl4030_data,
  302. };
  303. static int __init omap_i2c_init(void)
  304. {
  305. omap3_pmic_get_config(&ldp_twldata,
  306. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC, 0);
  307. omap3_pmic_init("twl4030", &ldp_twldata);
  308. omap_register_i2c_bus(2, 400, NULL, 0);
  309. omap_register_i2c_bus(3, 400, NULL, 0);
  310. return 0;
  311. }
  312. static struct omap2_hsmmc_info mmc[] __initdata = {
  313. {
  314. .mmc = 1,
  315. .caps = MMC_CAP_4_BIT_DATA,
  316. .gpio_cd = -EINVAL,
  317. .gpio_wp = -EINVAL,
  318. },
  319. {} /* Terminator */
  320. };
  321. static struct platform_device *ldp_devices[] __initdata = {
  322. &ldp_gpio_keys_device,
  323. };
  324. #ifdef CONFIG_OMAP_MUX
  325. static struct omap_board_mux board_mux[] __initdata = {
  326. { .reg_offset = OMAP_MUX_TERMINATOR },
  327. };
  328. #endif
  329. static struct mtd_partition ldp_nand_partitions[] = {
  330. /* All the partition sizes are listed in terms of NAND block size */
  331. {
  332. .name = "X-Loader-NAND",
  333. .offset = 0,
  334. .size = 4 * (64 * 2048), /* 512KB, 0x80000 */
  335. .mask_flags = MTD_WRITEABLE, /* force read-only */
  336. },
  337. {
  338. .name = "U-Boot-NAND",
  339. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  340. .size = 10 * (64 * 2048), /* 1.25MB, 0x140000 */
  341. .mask_flags = MTD_WRITEABLE, /* force read-only */
  342. },
  343. {
  344. .name = "Boot Env-NAND",
  345. .offset = MTDPART_OFS_APPEND, /* Offset = 0x1c0000 */
  346. .size = 2 * (64 * 2048), /* 256KB, 0x40000 */
  347. },
  348. {
  349. .name = "Kernel-NAND",
  350. .offset = MTDPART_OFS_APPEND, /* Offset = 0x0200000*/
  351. .size = 240 * (64 * 2048), /* 30M, 0x1E00000 */
  352. },
  353. {
  354. .name = "File System - NAND",
  355. .offset = MTDPART_OFS_APPEND, /* Offset = 0x2000000 */
  356. .size = MTDPART_SIZ_FULL, /* 96MB, 0x6000000 */
  357. },
  358. };
  359. static struct regulator_consumer_supply dummy_supplies[] = {
  360. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  361. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  362. };
  363. static void __init omap_ldp_init(void)
  364. {
  365. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  366. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  367. ldp_init_smsc911x();
  368. omap_i2c_init();
  369. platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
  370. omap_ads7846_init(1, 54, 310, NULL);
  371. omap_serial_init();
  372. omap_sdrc_init(NULL, NULL);
  373. usb_musb_init(NULL);
  374. board_nand_init(ldp_nand_partitions, ARRAY_SIZE(ldp_nand_partitions),
  375. ZOOM_NAND_CS, 0, nand_default_timings);
  376. omap_hsmmc_init(mmc);
  377. ldp_display_init();
  378. }
  379. MACHINE_START(OMAP_LDP, "OMAP LDP board")
  380. .atag_offset = 0x100,
  381. .reserve = omap_reserve,
  382. .map_io = omap3_map_io,
  383. .init_early = omap3430_init_early,
  384. .init_irq = omap3_init_irq,
  385. .handle_irq = omap3_intc_handle_irq,
  386. .init_machine = omap_ldp_init,
  387. .init_late = omap3430_init_late,
  388. .timer = &omap3_timer,
  389. .restart = omap_prcm_restart,
  390. MACHINE_END