board-overo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /*
  2. * board-overo.c (Gumstix Overo)
  3. *
  4. * Initial code: Steve Sakoman <steve@sakoman.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. #include <linux/clk.h>
  22. #include <linux/delay.h>
  23. #include <linux/err.h>
  24. #include <linux/init.h>
  25. #include <linux/io.h>
  26. #include <linux/gpio.h>
  27. #include <linux/kernel.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/i2c/twl.h>
  30. #include <linux/regulator/machine.h>
  31. #include <linux/regulator/fixed.h>
  32. #include <linux/spi/spi.h>
  33. #include <linux/mtd/mtd.h>
  34. #include <linux/mtd/nand.h>
  35. #include <linux/mtd/partitions.h>
  36. #include <linux/mmc/host.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/flash.h>
  40. #include <asm/mach/map.h>
  41. #include <plat/board.h>
  42. #include "common.h"
  43. #include <video/omapdss.h>
  44. #include <video/omap-panel-generic-dpi.h>
  45. #include <video/omap-panel-dvi.h>
  46. #include <plat/gpmc.h>
  47. #include <mach/hardware.h>
  48. #include <plat/nand.h>
  49. #include <plat/mcspi.h>
  50. #include <plat/mux.h>
  51. #include <plat/usb.h>
  52. #include "mux.h"
  53. #include "sdram-micron-mt46h32m32lf-6.h"
  54. #include "hsmmc.h"
  55. #include "common-board-devices.h"
  56. #define OVERO_GPIO_BT_XGATE 15
  57. #define OVERO_GPIO_W2W_NRESET 16
  58. #define OVERO_GPIO_PENDOWN 114
  59. #define OVERO_GPIO_BT_NRESET 164
  60. #define OVERO_GPIO_USBH_CPEN 168
  61. #define OVERO_GPIO_USBH_NRESET 183
  62. #define OVERO_SMSC911X_CS 5
  63. #define OVERO_SMSC911X_GPIO 176
  64. #define OVERO_SMSC911X2_CS 4
  65. #define OVERO_SMSC911X2_GPIO 65
  66. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
  67. defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  68. /* fixed regulator for ads7846 */
  69. static struct regulator_consumer_supply ads7846_supply[] = {
  70. REGULATOR_SUPPLY("vcc", "spi1.0"),
  71. };
  72. static struct regulator_init_data vads7846_regulator = {
  73. .constraints = {
  74. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  75. },
  76. .num_consumer_supplies = ARRAY_SIZE(ads7846_supply),
  77. .consumer_supplies = ads7846_supply,
  78. };
  79. static struct fixed_voltage_config vads7846 = {
  80. .supply_name = "vads7846",
  81. .microvolts = 3300000, /* 3.3V */
  82. .gpio = -EINVAL,
  83. .startup_delay = 0,
  84. .init_data = &vads7846_regulator,
  85. };
  86. static struct platform_device vads7846_device = {
  87. .name = "reg-fixed-voltage",
  88. .id = 1,
  89. .dev = {
  90. .platform_data = &vads7846,
  91. },
  92. };
  93. static void __init overo_ads7846_init(void)
  94. {
  95. omap_ads7846_init(1, OVERO_GPIO_PENDOWN, 0, NULL);
  96. platform_device_register(&vads7846_device);
  97. }
  98. #else
  99. static inline void __init overo_ads7846_init(void) { return; }
  100. #endif
  101. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  102. #include <linux/smsc911x.h>
  103. #include <plat/gpmc-smsc911x.h>
  104. static struct omap_smsc911x_platform_data smsc911x_cfg = {
  105. .id = 0,
  106. .cs = OVERO_SMSC911X_CS,
  107. .gpio_irq = OVERO_SMSC911X_GPIO,
  108. .gpio_reset = -EINVAL,
  109. .flags = SMSC911X_USE_32BIT,
  110. };
  111. static struct omap_smsc911x_platform_data smsc911x2_cfg = {
  112. .id = 1,
  113. .cs = OVERO_SMSC911X2_CS,
  114. .gpio_irq = OVERO_SMSC911X2_GPIO,
  115. .gpio_reset = -EINVAL,
  116. .flags = SMSC911X_USE_32BIT,
  117. };
  118. static void __init overo_init_smsc911x(void)
  119. {
  120. gpmc_smsc911x_init(&smsc911x_cfg);
  121. gpmc_smsc911x_init(&smsc911x2_cfg);
  122. }
  123. #else
  124. static inline void __init overo_init_smsc911x(void) { return; }
  125. #endif
  126. /* DSS */
  127. static int lcd_enabled;
  128. static int dvi_enabled;
  129. #define OVERO_GPIO_LCD_EN 144
  130. #define OVERO_GPIO_LCD_BL 145
  131. static struct gpio overo_dss_gpios[] __initdata = {
  132. { OVERO_GPIO_LCD_EN, GPIOF_OUT_INIT_HIGH, "OVERO_GPIO_LCD_EN" },
  133. { OVERO_GPIO_LCD_BL, GPIOF_OUT_INIT_HIGH, "OVERO_GPIO_LCD_BL" },
  134. };
  135. static void __init overo_display_init(void)
  136. {
  137. if (gpio_request_array(overo_dss_gpios, ARRAY_SIZE(overo_dss_gpios))) {
  138. printk(KERN_ERR "could not obtain DSS control GPIOs\n");
  139. return;
  140. }
  141. gpio_export(OVERO_GPIO_LCD_EN, 0);
  142. gpio_export(OVERO_GPIO_LCD_BL, 0);
  143. }
  144. static int overo_panel_enable_dvi(struct omap_dss_device *dssdev)
  145. {
  146. if (lcd_enabled) {
  147. printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
  148. return -EINVAL;
  149. }
  150. dvi_enabled = 1;
  151. return 0;
  152. }
  153. static void overo_panel_disable_dvi(struct omap_dss_device *dssdev)
  154. {
  155. dvi_enabled = 0;
  156. }
  157. static struct panel_dvi_platform_data dvi_panel = {
  158. .platform_enable = overo_panel_enable_dvi,
  159. .platform_disable = overo_panel_disable_dvi,
  160. .i2c_bus_num = 3,
  161. };
  162. static struct omap_dss_device overo_dvi_device = {
  163. .name = "dvi",
  164. .type = OMAP_DISPLAY_TYPE_DPI,
  165. .driver_name = "dvi",
  166. .data = &dvi_panel,
  167. .phy.dpi.data_lines = 24,
  168. };
  169. static struct omap_dss_device overo_tv_device = {
  170. .name = "tv",
  171. .driver_name = "venc",
  172. .type = OMAP_DISPLAY_TYPE_VENC,
  173. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  174. };
  175. static int overo_panel_enable_lcd(struct omap_dss_device *dssdev)
  176. {
  177. if (dvi_enabled) {
  178. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  179. return -EINVAL;
  180. }
  181. gpio_set_value(OVERO_GPIO_LCD_EN, 1);
  182. gpio_set_value(OVERO_GPIO_LCD_BL, 1);
  183. lcd_enabled = 1;
  184. return 0;
  185. }
  186. static void overo_panel_disable_lcd(struct omap_dss_device *dssdev)
  187. {
  188. gpio_set_value(OVERO_GPIO_LCD_EN, 0);
  189. gpio_set_value(OVERO_GPIO_LCD_BL, 0);
  190. lcd_enabled = 0;
  191. }
  192. static struct panel_generic_dpi_data lcd43_panel = {
  193. .name = "samsung_lte430wq_f0c",
  194. .platform_enable = overo_panel_enable_lcd,
  195. .platform_disable = overo_panel_disable_lcd,
  196. };
  197. static struct omap_dss_device overo_lcd43_device = {
  198. .name = "lcd43",
  199. .type = OMAP_DISPLAY_TYPE_DPI,
  200. .driver_name = "generic_dpi_panel",
  201. .data = &lcd43_panel,
  202. .phy.dpi.data_lines = 24,
  203. };
  204. #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
  205. defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
  206. static struct omap_dss_device overo_lcd35_device = {
  207. .type = OMAP_DISPLAY_TYPE_DPI,
  208. .name = "lcd35",
  209. .driver_name = "lgphilips_lb035q02_panel",
  210. .phy.dpi.data_lines = 24,
  211. .platform_enable = overo_panel_enable_lcd,
  212. .platform_disable = overo_panel_disable_lcd,
  213. };
  214. #endif
  215. static struct omap_dss_device *overo_dss_devices[] = {
  216. &overo_dvi_device,
  217. &overo_tv_device,
  218. #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
  219. defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
  220. &overo_lcd35_device,
  221. #endif
  222. &overo_lcd43_device,
  223. };
  224. static struct omap_dss_board_info overo_dss_data = {
  225. .num_devices = ARRAY_SIZE(overo_dss_devices),
  226. .devices = overo_dss_devices,
  227. .default_device = &overo_dvi_device,
  228. };
  229. static struct mtd_partition overo_nand_partitions[] = {
  230. {
  231. .name = "xloader",
  232. .offset = 0, /* Offset = 0x00000 */
  233. .size = 4 * NAND_BLOCK_SIZE,
  234. .mask_flags = MTD_WRITEABLE
  235. },
  236. {
  237. .name = "uboot",
  238. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  239. .size = 14 * NAND_BLOCK_SIZE,
  240. },
  241. {
  242. .name = "uboot environment",
  243. .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
  244. .size = 2 * NAND_BLOCK_SIZE,
  245. },
  246. {
  247. .name = "linux",
  248. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  249. .size = 32 * NAND_BLOCK_SIZE,
  250. },
  251. {
  252. .name = "rootfs",
  253. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  254. .size = MTDPART_SIZ_FULL,
  255. },
  256. };
  257. static struct omap2_hsmmc_info mmc[] = {
  258. {
  259. .mmc = 1,
  260. .caps = MMC_CAP_4_BIT_DATA,
  261. .gpio_cd = -EINVAL,
  262. .gpio_wp = -EINVAL,
  263. },
  264. {
  265. .mmc = 2,
  266. .caps = MMC_CAP_4_BIT_DATA,
  267. .gpio_cd = -EINVAL,
  268. .gpio_wp = -EINVAL,
  269. .transceiver = true,
  270. .ocr_mask = 0x00100000, /* 3.3V */
  271. },
  272. {} /* Terminator */
  273. };
  274. static struct regulator_consumer_supply overo_vmmc1_supply[] = {
  275. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  276. };
  277. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  278. #include <linux/leds.h>
  279. static struct gpio_led gpio_leds[] = {
  280. {
  281. .name = "overo:red:gpio21",
  282. .default_trigger = "heartbeat",
  283. .gpio = 21,
  284. .active_low = true,
  285. },
  286. {
  287. .name = "overo:blue:gpio22",
  288. .default_trigger = "none",
  289. .gpio = 22,
  290. .active_low = true,
  291. },
  292. {
  293. .name = "overo:blue:COM",
  294. .default_trigger = "mmc0",
  295. .gpio = -EINVAL, /* gets replaced */
  296. .active_low = true,
  297. },
  298. };
  299. static struct gpio_led_platform_data gpio_leds_pdata = {
  300. .leds = gpio_leds,
  301. .num_leds = ARRAY_SIZE(gpio_leds),
  302. };
  303. static struct platform_device gpio_leds_device = {
  304. .name = "leds-gpio",
  305. .id = -1,
  306. .dev = {
  307. .platform_data = &gpio_leds_pdata,
  308. },
  309. };
  310. static void __init overo_init_led(void)
  311. {
  312. platform_device_register(&gpio_leds_device);
  313. }
  314. #else
  315. static inline void __init overo_init_led(void) { return; }
  316. #endif
  317. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  318. #include <linux/input.h>
  319. #include <linux/gpio_keys.h>
  320. static struct gpio_keys_button gpio_buttons[] = {
  321. {
  322. .code = BTN_0,
  323. .gpio = 23,
  324. .desc = "button0",
  325. .wakeup = 1,
  326. },
  327. {
  328. .code = BTN_1,
  329. .gpio = 14,
  330. .desc = "button1",
  331. .wakeup = 1,
  332. },
  333. };
  334. static struct gpio_keys_platform_data gpio_keys_pdata = {
  335. .buttons = gpio_buttons,
  336. .nbuttons = ARRAY_SIZE(gpio_buttons),
  337. };
  338. static struct platform_device gpio_keys_device = {
  339. .name = "gpio-keys",
  340. .id = -1,
  341. .dev = {
  342. .platform_data = &gpio_keys_pdata,
  343. },
  344. };
  345. static void __init overo_init_keys(void)
  346. {
  347. platform_device_register(&gpio_keys_device);
  348. }
  349. #else
  350. static inline void __init overo_init_keys(void) { return; }
  351. #endif
  352. static int overo_twl_gpio_setup(struct device *dev,
  353. unsigned gpio, unsigned ngpio)
  354. {
  355. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  356. /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
  357. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  358. #endif
  359. return 0;
  360. }
  361. static struct twl4030_gpio_platform_data overo_gpio_data = {
  362. .gpio_base = OMAP_MAX_GPIO_LINES,
  363. .irq_base = TWL4030_GPIO_IRQ_BASE,
  364. .irq_end = TWL4030_GPIO_IRQ_END,
  365. .use_leds = true,
  366. .setup = overo_twl_gpio_setup,
  367. };
  368. static struct regulator_init_data overo_vmmc1 = {
  369. .constraints = {
  370. .min_uV = 1850000,
  371. .max_uV = 3150000,
  372. .valid_modes_mask = REGULATOR_MODE_NORMAL
  373. | REGULATOR_MODE_STANDBY,
  374. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  375. | REGULATOR_CHANGE_MODE
  376. | REGULATOR_CHANGE_STATUS,
  377. },
  378. .num_consumer_supplies = ARRAY_SIZE(overo_vmmc1_supply),
  379. .consumer_supplies = overo_vmmc1_supply,
  380. };
  381. static struct twl4030_platform_data overo_twldata = {
  382. .gpio = &overo_gpio_data,
  383. .vmmc1 = &overo_vmmc1,
  384. };
  385. static int __init overo_i2c_init(void)
  386. {
  387. omap3_pmic_get_config(&overo_twldata,
  388. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
  389. TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
  390. overo_twldata.vpll2->constraints.name = "VDVI";
  391. omap3_pmic_init("tps65950", &overo_twldata);
  392. /* i2c2 pins are used for gpio */
  393. omap_register_i2c_bus(3, 400, NULL, 0);
  394. return 0;
  395. }
  396. static struct spi_board_info overo_spi_board_info[] __initdata = {
  397. #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
  398. defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
  399. {
  400. .modalias = "lgphilips_lb035q02_panel-spi",
  401. .bus_num = 1,
  402. .chip_select = 1,
  403. .max_speed_hz = 500000,
  404. .mode = SPI_MODE_3,
  405. },
  406. #endif
  407. };
  408. static int __init overo_spi_init(void)
  409. {
  410. overo_ads7846_init();
  411. spi_register_board_info(overo_spi_board_info,
  412. ARRAY_SIZE(overo_spi_board_info));
  413. return 0;
  414. }
  415. static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
  416. .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
  417. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  418. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  419. .phy_reset = true,
  420. .reset_gpio_port[0] = -EINVAL,
  421. .reset_gpio_port[1] = OVERO_GPIO_USBH_NRESET,
  422. .reset_gpio_port[2] = -EINVAL
  423. };
  424. #ifdef CONFIG_OMAP_MUX
  425. static struct omap_board_mux board_mux[] __initdata = {
  426. { .reg_offset = OMAP_MUX_TERMINATOR },
  427. };
  428. #endif
  429. static struct gpio overo_bt_gpios[] __initdata = {
  430. { OVERO_GPIO_BT_XGATE, GPIOF_OUT_INIT_LOW, "lcd enable" },
  431. { OVERO_GPIO_BT_NRESET, GPIOF_OUT_INIT_HIGH, "lcd bl enable" },
  432. };
  433. static void __init overo_init(void)
  434. {
  435. int ret;
  436. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  437. omap_hsmmc_init(mmc);
  438. overo_i2c_init();
  439. omap_display_init(&overo_dss_data);
  440. omap_serial_init();
  441. omap_sdrc_init(mt46h32m32lf6_sdrc_params,
  442. mt46h32m32lf6_sdrc_params);
  443. omap_nand_flash_init(0, overo_nand_partitions,
  444. ARRAY_SIZE(overo_nand_partitions));
  445. usb_musb_init(NULL);
  446. usbhs_init(&usbhs_bdata);
  447. overo_spi_init();
  448. overo_init_smsc911x();
  449. overo_display_init();
  450. overo_init_led();
  451. overo_init_keys();
  452. /* Ensure SDRC pins are mux'd for self-refresh */
  453. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  454. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  455. ret = gpio_request_one(OVERO_GPIO_W2W_NRESET, GPIOF_OUT_INIT_HIGH,
  456. "OVERO_GPIO_W2W_NRESET");
  457. if (ret == 0) {
  458. gpio_export(OVERO_GPIO_W2W_NRESET, 0);
  459. gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
  460. udelay(10);
  461. gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
  462. } else {
  463. printk(KERN_ERR "could not obtain gpio for "
  464. "OVERO_GPIO_W2W_NRESET\n");
  465. }
  466. ret = gpio_request_array(overo_bt_gpios, ARRAY_SIZE(overo_bt_gpios));
  467. if (ret) {
  468. pr_err("%s: could not obtain BT gpios\n", __func__);
  469. } else {
  470. gpio_export(OVERO_GPIO_BT_XGATE, 0);
  471. gpio_export(OVERO_GPIO_BT_NRESET, 0);
  472. gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
  473. mdelay(6);
  474. gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
  475. }
  476. ret = gpio_request_one(OVERO_GPIO_USBH_CPEN, GPIOF_OUT_INIT_HIGH,
  477. "OVERO_GPIO_USBH_CPEN");
  478. if (ret == 0)
  479. gpio_export(OVERO_GPIO_USBH_CPEN, 0);
  480. else
  481. printk(KERN_ERR "could not obtain gpio for "
  482. "OVERO_GPIO_USBH_CPEN\n");
  483. }
  484. MACHINE_START(OVERO, "Gumstix Overo")
  485. .atag_offset = 0x100,
  486. .reserve = omap_reserve,
  487. .map_io = omap3_map_io,
  488. .init_early = omap35xx_init_early,
  489. .init_irq = omap3_init_irq,
  490. .handle_irq = omap3_intc_handle_irq,
  491. .init_machine = overo_init,
  492. .timer = &omap3_timer,
  493. .restart = omap_prcm_restart,
  494. MACHINE_END