board-overo.c 14 KB

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