board-overo.c 14 KB

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