board-overo.c 13 KB

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