board-overo.c 14 KB

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