board-overo.c 14 KB

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