board-osk.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /*
  2. * linux/arch/arm/mach-omap1/board-osk.c
  3. *
  4. * Board specific init for OMAP5912 OSK
  5. *
  6. * Written by Dirk Behme <dirk.behme@de.bosch.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  14. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  16. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * You should have received a copy of the GNU General Public License along
  25. * with this program; if not, write to the Free Software Foundation, Inc.,
  26. * 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #include <linux/kernel.h>
  29. #include <linux/init.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/interrupt.h>
  32. #include <linux/irq.h>
  33. #include <linux/i2c.h>
  34. #include <linux/leds.h>
  35. #include <linux/mtd/mtd.h>
  36. #include <linux/mtd/partitions.h>
  37. #include <linux/i2c/tps65010.h>
  38. #include <mach/hardware.h>
  39. #include <asm/gpio.h>
  40. #include <asm/mach-types.h>
  41. #include <asm/mach/arch.h>
  42. #include <asm/mach/map.h>
  43. #include <asm/mach/flash.h>
  44. #include <mach/usb.h>
  45. #include <mach/mux.h>
  46. #include <mach/tc.h>
  47. #include <mach/common.h>
  48. static struct mtd_partition osk_partitions[] = {
  49. /* bootloader (U-Boot, etc) in first sector */
  50. {
  51. .name = "bootloader",
  52. .offset = 0,
  53. .size = SZ_128K,
  54. .mask_flags = MTD_WRITEABLE, /* force read-only */
  55. },
  56. /* bootloader params in the next sector */
  57. {
  58. .name = "params",
  59. .offset = MTDPART_OFS_APPEND,
  60. .size = SZ_128K,
  61. .mask_flags = 0,
  62. }, {
  63. .name = "kernel",
  64. .offset = MTDPART_OFS_APPEND,
  65. .size = SZ_2M,
  66. .mask_flags = 0
  67. }, {
  68. .name = "filesystem",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = MTDPART_SIZ_FULL,
  71. .mask_flags = 0
  72. }
  73. };
  74. static struct flash_platform_data osk_flash_data = {
  75. .map_name = "cfi_probe",
  76. .width = 2,
  77. .parts = osk_partitions,
  78. .nr_parts = ARRAY_SIZE(osk_partitions),
  79. };
  80. static struct resource osk_flash_resource = {
  81. /* this is on CS3, wherever it's mapped */
  82. .flags = IORESOURCE_MEM,
  83. };
  84. static struct platform_device osk5912_flash_device = {
  85. .name = "omapflash",
  86. .id = 0,
  87. .dev = {
  88. .platform_data = &osk_flash_data,
  89. },
  90. .num_resources = 1,
  91. .resource = &osk_flash_resource,
  92. };
  93. static struct resource osk5912_smc91x_resources[] = {
  94. [0] = {
  95. .start = OMAP_OSK_ETHR_START, /* Physical */
  96. .end = OMAP_OSK_ETHR_START + 0xf,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. [1] = {
  100. .start = OMAP_GPIO_IRQ(0),
  101. .end = OMAP_GPIO_IRQ(0),
  102. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  103. },
  104. };
  105. static struct platform_device osk5912_smc91x_device = {
  106. .name = "smc91x",
  107. .id = -1,
  108. .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
  109. .resource = osk5912_smc91x_resources,
  110. };
  111. static struct resource osk5912_cf_resources[] = {
  112. [0] = {
  113. .start = OMAP_GPIO_IRQ(62),
  114. .end = OMAP_GPIO_IRQ(62),
  115. .flags = IORESOURCE_IRQ,
  116. },
  117. };
  118. static struct platform_device osk5912_cf_device = {
  119. .name = "omap_cf",
  120. .id = -1,
  121. .dev = {
  122. .platform_data = (void *) 2 /* CS2 */,
  123. },
  124. .num_resources = ARRAY_SIZE(osk5912_cf_resources),
  125. .resource = osk5912_cf_resources,
  126. };
  127. static struct platform_device *osk5912_devices[] __initdata = {
  128. &osk5912_flash_device,
  129. &osk5912_smc91x_device,
  130. &osk5912_cf_device,
  131. };
  132. static struct gpio_led tps_leds[] = {
  133. /* NOTE: D9 and D2 have hardware blink support.
  134. * Also, D9 requires non-battery power.
  135. */
  136. { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9",
  137. .default_trigger = "ide-disk", },
  138. { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
  139. { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
  140. .default_trigger = "heartbeat", },
  141. };
  142. static struct gpio_led_platform_data tps_leds_data = {
  143. .num_leds = 3,
  144. .leds = tps_leds,
  145. };
  146. static struct platform_device osk5912_tps_leds = {
  147. .name = "leds-gpio",
  148. .id = 0,
  149. .dev.platform_data = &tps_leds_data,
  150. };
  151. static int osk_tps_setup(struct i2c_client *client, void *context)
  152. {
  153. /* Set GPIO 1 HIGH to disable VBUS power supply;
  154. * OHCI driver powers it up/down as needed.
  155. */
  156. gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
  157. gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
  158. /* Set GPIO 2 high so LED D3 is off by default */
  159. tps65010_set_gpio_out_value(GPIO2, HIGH);
  160. /* Set GPIO 3 low to take ethernet out of reset */
  161. gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
  162. gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
  163. /* GPIO4 is VDD_DSP */
  164. gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
  165. gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
  166. /* REVISIT if DSP support isn't configured, power it off ... */
  167. /* Let LED1 (D9) blink; leds-gpio may override it */
  168. tps65010_set_led(LED1, BLINK);
  169. /* Set LED2 off by default */
  170. tps65010_set_led(LED2, OFF);
  171. /* Enable LOW_PWR handshake */
  172. tps65010_set_low_pwr(ON);
  173. /* Switch VLDO2 to 3.0V for AIC23 */
  174. tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
  175. | TPS_LDO1_ENABLE);
  176. /* register these three LEDs */
  177. osk5912_tps_leds.dev.parent = &client->dev;
  178. platform_device_register(&osk5912_tps_leds);
  179. return 0;
  180. }
  181. static struct tps65010_board tps_board = {
  182. .base = OSK_TPS_GPIO_BASE,
  183. .outmask = 0x0f,
  184. .setup = osk_tps_setup,
  185. };
  186. static struct i2c_board_info __initdata osk_i2c_board_info[] = {
  187. {
  188. I2C_BOARD_INFO("tps65010", 0x48),
  189. .irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)),
  190. .platform_data = &tps_board,
  191. },
  192. {
  193. I2C_BOARD_INFO("tlv320aic23", 0x1B),
  194. },
  195. /* TODO when driver support is ready:
  196. * - optionally on Mistral, ov9640 camera sensor at 0x30
  197. */
  198. };
  199. static void __init osk_init_smc91x(void)
  200. {
  201. u32 l;
  202. if ((gpio_request(0, "smc_irq")) < 0) {
  203. printk("Error requesting gpio 0 for smc91x irq\n");
  204. return;
  205. }
  206. /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
  207. l = omap_readl(EMIFS_CCS(1));
  208. l |= 0x3;
  209. omap_writel(l, EMIFS_CCS(1));
  210. }
  211. static void __init osk_init_cf(void)
  212. {
  213. omap_cfg_reg(M7_1610_GPIO62);
  214. if ((gpio_request(62, "cf_irq")) < 0) {
  215. printk("Error requesting gpio 62 for CF irq\n");
  216. return;
  217. }
  218. /* the CF I/O IRQ is really active-low */
  219. set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING);
  220. }
  221. static void __init osk_init_irq(void)
  222. {
  223. omap1_init_common_hw();
  224. omap_init_irq();
  225. omap_gpio_init();
  226. osk_init_smc91x();
  227. osk_init_cf();
  228. }
  229. static struct omap_usb_config osk_usb_config __initdata = {
  230. /* has usb host connector (A) ... for development it can also
  231. * be used, with a NONSTANDARD gender-bending cable/dongle, as
  232. * a peripheral.
  233. */
  234. #ifdef CONFIG_USB_GADGET_OMAP
  235. .register_dev = 1,
  236. .hmc_mode = 0,
  237. #else
  238. .register_host = 1,
  239. .hmc_mode = 16,
  240. .rwc = 1,
  241. #endif
  242. .pins[0] = 2,
  243. };
  244. static struct omap_uart_config osk_uart_config __initdata = {
  245. .enabled_uarts = (1 << 0),
  246. };
  247. #ifdef CONFIG_OMAP_OSK_MISTRAL
  248. static struct omap_lcd_config osk_lcd_config __initdata = {
  249. .ctrl_name = "internal",
  250. };
  251. #endif
  252. static struct omap_board_config_kernel osk_config[] __initdata = {
  253. { OMAP_TAG_USB, &osk_usb_config },
  254. { OMAP_TAG_UART, &osk_uart_config },
  255. #ifdef CONFIG_OMAP_OSK_MISTRAL
  256. { OMAP_TAG_LCD, &osk_lcd_config },
  257. #endif
  258. };
  259. #ifdef CONFIG_OMAP_OSK_MISTRAL
  260. #include <linux/input.h>
  261. #include <linux/i2c/at24.h>
  262. #include <linux/spi/spi.h>
  263. #include <linux/spi/ads7846.h>
  264. #include <mach/keypad.h>
  265. static struct at24_platform_data at24c04 = {
  266. .byte_len = SZ_4K / 8,
  267. .page_size = 16,
  268. };
  269. static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
  270. {
  271. /* NOTE: powered from LCD supply */
  272. I2C_BOARD_INFO("24c04", 0x50),
  273. .platform_data = &at24c04,
  274. },
  275. /* TODO when driver support is ready:
  276. * - optionally ov9640 camera sensor at 0x30
  277. */
  278. };
  279. static const int osk_keymap[] = {
  280. /* KEY(col, row, code) */
  281. KEY(0, 0, KEY_F1), /* SW4 */
  282. KEY(0, 3, KEY_UP), /* (sw2/up) */
  283. KEY(1, 1, KEY_LEFTCTRL), /* SW5 */
  284. KEY(1, 2, KEY_LEFT), /* (sw2/left) */
  285. KEY(2, 0, KEY_SPACE), /* SW3 */
  286. KEY(2, 1, KEY_ESC), /* SW6 */
  287. KEY(2, 2, KEY_DOWN), /* (sw2/down) */
  288. KEY(3, 2, KEY_ENTER), /* (sw2/select) */
  289. KEY(3, 3, KEY_RIGHT), /* (sw2/right) */
  290. 0
  291. };
  292. static struct omap_kp_platform_data osk_kp_data = {
  293. .rows = 8,
  294. .cols = 8,
  295. .keymap = (int *) osk_keymap,
  296. .keymapsize = ARRAY_SIZE(osk_keymap),
  297. .delay = 9,
  298. };
  299. static struct resource osk5912_kp_resources[] = {
  300. [0] = {
  301. .start = INT_KEYBOARD,
  302. .end = INT_KEYBOARD,
  303. .flags = IORESOURCE_IRQ,
  304. },
  305. };
  306. static struct platform_device osk5912_kp_device = {
  307. .name = "omap-keypad",
  308. .id = -1,
  309. .dev = {
  310. .platform_data = &osk_kp_data,
  311. },
  312. .num_resources = ARRAY_SIZE(osk5912_kp_resources),
  313. .resource = osk5912_kp_resources,
  314. };
  315. static struct omap_backlight_config mistral_bl_data = {
  316. .default_intensity = 0xa0,
  317. };
  318. static struct platform_device mistral_bl_device = {
  319. .name = "omap-bl",
  320. .id = -1,
  321. .dev = {
  322. .platform_data = &mistral_bl_data,
  323. },
  324. };
  325. static struct platform_device osk5912_lcd_device = {
  326. .name = "lcd_osk",
  327. .id = -1,
  328. };
  329. static struct platform_device *mistral_devices[] __initdata = {
  330. &osk5912_kp_device,
  331. &mistral_bl_device,
  332. &osk5912_lcd_device,
  333. };
  334. static int mistral_get_pendown_state(void)
  335. {
  336. return !gpio_get_value(4);
  337. }
  338. static const struct ads7846_platform_data mistral_ts_info = {
  339. .model = 7846,
  340. .vref_delay_usecs = 100, /* internal, no capacitor */
  341. .x_plate_ohms = 419,
  342. .y_plate_ohms = 486,
  343. .get_pendown_state = mistral_get_pendown_state,
  344. };
  345. static struct spi_board_info __initdata mistral_boardinfo[] = { {
  346. /* MicroWire (bus 2) CS0 has an ads7846e */
  347. .modalias = "ads7846",
  348. .platform_data = &mistral_ts_info,
  349. .irq = OMAP_GPIO_IRQ(4),
  350. .max_speed_hz = 120000 /* max sample rate at 3V */
  351. * 26 /* command + data + overhead */,
  352. .bus_num = 2,
  353. .chip_select = 0,
  354. } };
  355. #ifdef CONFIG_PM
  356. static irqreturn_t
  357. osk_mistral_wake_interrupt(int irq, void *ignored)
  358. {
  359. return IRQ_HANDLED;
  360. }
  361. #endif
  362. static void __init osk_mistral_init(void)
  363. {
  364. /* NOTE: we could actually tell if there's a Mistral board
  365. * attached, e.g. by trying to read something from the ads7846.
  366. * But this arch_init() code is too early for that, since we
  367. * can't talk to the ads or even the i2c eeprom.
  368. */
  369. /* parallel camera interface */
  370. omap_cfg_reg(J15_1610_CAM_LCLK);
  371. omap_cfg_reg(J18_1610_CAM_D7);
  372. omap_cfg_reg(J19_1610_CAM_D6);
  373. omap_cfg_reg(J14_1610_CAM_D5);
  374. omap_cfg_reg(K18_1610_CAM_D4);
  375. omap_cfg_reg(K19_1610_CAM_D3);
  376. omap_cfg_reg(K15_1610_CAM_D2);
  377. omap_cfg_reg(K14_1610_CAM_D1);
  378. omap_cfg_reg(L19_1610_CAM_D0);
  379. omap_cfg_reg(L18_1610_CAM_VS);
  380. omap_cfg_reg(L15_1610_CAM_HS);
  381. omap_cfg_reg(M19_1610_CAM_RSTZ);
  382. omap_cfg_reg(Y15_1610_CAM_OUTCLK);
  383. /* serial camera interface */
  384. omap_cfg_reg(H19_1610_CAM_EXCLK);
  385. omap_cfg_reg(W13_1610_CCP_CLKM);
  386. omap_cfg_reg(Y12_1610_CCP_CLKP);
  387. /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
  388. /* omap_cfg_reg(Y14_1610_CCP_DATAM); */
  389. omap_cfg_reg(W14_1610_CCP_DATAP);
  390. /* CAM_PWDN */
  391. if (gpio_request(11, "cam_pwdn") == 0) {
  392. omap_cfg_reg(N20_1610_GPIO11);
  393. gpio_direction_output(11, 0);
  394. } else
  395. pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
  396. /* omap_cfg_reg(P19_1610_GPIO6); */ /* BUSY */
  397. gpio_request(6, "ts_busy");
  398. gpio_direction_input(6);
  399. omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */
  400. gpio_request(4, "ts_int");
  401. gpio_direction_input(4);
  402. set_irq_type(gpio_to_irq(4), IRQ_TYPE_EDGE_FALLING);
  403. spi_register_board_info(mistral_boardinfo,
  404. ARRAY_SIZE(mistral_boardinfo));
  405. /* the sideways button (SW1) is for use as a "wakeup" button
  406. *
  407. * NOTE: The Mistral board has the wakeup button (SW1) wired
  408. * to the LCD 3.3V rail, which is powered down during suspend.
  409. * To allow this button to wake up the omap, work around this
  410. * HW bug by rewiring SW1 to use the main 3.3V rail.
  411. */
  412. omap_cfg_reg(N15_1610_MPUIO2);
  413. if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) {
  414. int ret = 0;
  415. int irq = gpio_to_irq(OMAP_MPUIO(2));
  416. gpio_direction_input(OMAP_MPUIO(2));
  417. set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
  418. #ifdef CONFIG_PM
  419. /* share the IRQ in case someone wants to use the
  420. * button for more than wakeup from system sleep.
  421. */
  422. ret = request_irq(irq,
  423. &osk_mistral_wake_interrupt,
  424. IRQF_SHARED, "mistral_wakeup",
  425. &osk_mistral_wake_interrupt);
  426. if (ret != 0) {
  427. gpio_free(OMAP_MPUIO(2));
  428. printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
  429. ret);
  430. } else
  431. enable_irq_wake(irq);
  432. #endif
  433. } else
  434. printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
  435. /* LCD: backlight, and power; power controls other devices on the
  436. * board, like the touchscreen, EEPROM, and wakeup (!) switch.
  437. */
  438. omap_cfg_reg(PWL);
  439. if (gpio_request(2, "lcd_pwr") == 0)
  440. gpio_direction_output(2, 1);
  441. i2c_register_board_info(1, mistral_i2c_board_info,
  442. ARRAY_SIZE(mistral_i2c_board_info));
  443. platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
  444. }
  445. #else
  446. static void __init osk_mistral_init(void) { }
  447. #endif
  448. #define EMIFS_CS3_VAL (0x88013141)
  449. static void __init osk_init(void)
  450. {
  451. u32 l;
  452. /* Workaround for wrong CS3 (NOR flash) timing
  453. * There are some U-Boot versions out there which configure
  454. * wrong CS3 memory timings. This mainly leads to CRC
  455. * or similar errors if you use NOR flash (e.g. with JFFS2)
  456. */
  457. l = omap_readl(EMIFS_CCS(3));
  458. if (l != EMIFS_CS3_VAL)
  459. omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3));
  460. osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
  461. osk_flash_resource.end += SZ_32M - 1;
  462. platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
  463. omap_board_config = osk_config;
  464. omap_board_config_size = ARRAY_SIZE(osk_config);
  465. l = omap_readl(USB_TRANSCEIVER_CTRL);
  466. l |= (3 << 1);
  467. omap_writel(l, USB_TRANSCEIVER_CTRL);
  468. /* irq for tps65010 chip */
  469. /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */
  470. if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
  471. gpio_direction_input(OMAP_MPUIO(1));
  472. omap_serial_init();
  473. omap_register_i2c_bus(1, 400, osk_i2c_board_info,
  474. ARRAY_SIZE(osk_i2c_board_info));
  475. osk_mistral_init();
  476. }
  477. static void __init osk_map_io(void)
  478. {
  479. omap1_map_common_io();
  480. }
  481. MACHINE_START(OMAP_OSK, "TI-OSK")
  482. /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
  483. .phys_io = 0xfff00000,
  484. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  485. .boot_params = 0x10000100,
  486. .map_io = osk_map_io,
  487. .init_irq = osk_init_irq,
  488. .init_machine = osk_init,
  489. .timer = &omap_timer,
  490. MACHINE_END