board-osk.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. /*
  2. * linux/arch/arm/mach-omap1/board-osk.c
  3. *
  4. * Board specific init for OMAP5912 OSK
  5. *
  6. * Written by Dirk Behme <[email protected]>
  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/gpio.h>
  29. #include <linux/gpio/machine.h>
  30. #include <linux/kernel.h>
  31. #include <linux/init.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/irq.h>
  35. #include <linux/i2c.h>
  36. #include <linux/leds.h>
  37. #include <linux/smc91x.h>
  38. #include <linux/omapfb.h>
  39. #include <linux/mtd/mtd.h>
  40. #include <linux/mtd/partitions.h>
  41. #include <linux/mtd/physmap.h>
  42. #include <linux/mfd/tps65010.h>
  43. #include <linux/platform_data/gpio-omap.h>
  44. #include <linux/platform_data/omap1_bl.h>
  45. #include <linux/soc/ti/omap1-io.h>
  46. #include <asm/mach-types.h>
  47. #include <asm/mach/arch.h>
  48. #include <asm/mach/map.h>
  49. #include "tc.h"
  50. #include "flash.h"
  51. #include "mux.h"
  52. #include "hardware.h"
  53. #include "usb.h"
  54. #include "common.h"
  55. /* Name of the GPIO chip used by the OMAP for GPIOs 0..15 */
  56. #define OMAP_GPIO_LABEL "gpio-0-15"
  57. /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */
  58. #define OMAP_OSK_ETHR_START 0x04800300
  59. /* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with
  60. * alternate pin configurations for hardware-controlled blinking.
  61. */
  62. #define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
  63. # define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0)
  64. # define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1)
  65. # define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2)
  66. # define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3)
  67. # define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4)
  68. # define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5)
  69. static struct mtd_partition osk_partitions[] = {
  70. /* bootloader (U-Boot, etc) in first sector */
  71. {
  72. .name = "bootloader",
  73. .offset = 0,
  74. .size = SZ_128K,
  75. .mask_flags = MTD_WRITEABLE, /* force read-only */
  76. },
  77. /* bootloader params in the next sector */
  78. {
  79. .name = "params",
  80. .offset = MTDPART_OFS_APPEND,
  81. .size = SZ_128K,
  82. .mask_flags = 0,
  83. }, {
  84. .name = "kernel",
  85. .offset = MTDPART_OFS_APPEND,
  86. .size = SZ_2M,
  87. .mask_flags = 0
  88. }, {
  89. .name = "filesystem",
  90. .offset = MTDPART_OFS_APPEND,
  91. .size = MTDPART_SIZ_FULL,
  92. .mask_flags = 0
  93. }
  94. };
  95. static struct physmap_flash_data osk_flash_data = {
  96. .width = 2,
  97. .set_vpp = omap1_set_vpp,
  98. .parts = osk_partitions,
  99. .nr_parts = ARRAY_SIZE(osk_partitions),
  100. };
  101. static struct resource osk_flash_resource = {
  102. /* this is on CS3, wherever it's mapped */
  103. .flags = IORESOURCE_MEM,
  104. };
  105. static struct platform_device osk5912_flash_device = {
  106. .name = "physmap-flash",
  107. .id = 0,
  108. .dev = {
  109. .platform_data = &osk_flash_data,
  110. },
  111. .num_resources = 1,
  112. .resource = &osk_flash_resource,
  113. };
  114. static struct smc91x_platdata osk5912_smc91x_info = {
  115. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  116. .leda = RPC_LED_100_10,
  117. .ledb = RPC_LED_TX_RX,
  118. };
  119. static struct resource osk5912_smc91x_resources[] = {
  120. [0] = {
  121. .start = OMAP_OSK_ETHR_START, /* Physical */
  122. .end = OMAP_OSK_ETHR_START + 0xf,
  123. .flags = IORESOURCE_MEM,
  124. },
  125. [1] = {
  126. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  127. },
  128. };
  129. static struct platform_device osk5912_smc91x_device = {
  130. .name = "smc91x",
  131. .id = -1,
  132. .dev = {
  133. .platform_data = &osk5912_smc91x_info,
  134. },
  135. .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
  136. .resource = osk5912_smc91x_resources,
  137. };
  138. static struct resource osk5912_cf_resources[] = {
  139. [0] = {
  140. .flags = IORESOURCE_IRQ,
  141. },
  142. [1] = {
  143. .flags = IORESOURCE_MEM,
  144. },
  145. };
  146. static struct platform_device osk5912_cf_device = {
  147. .name = "omap_cf",
  148. .id = -1,
  149. .num_resources = ARRAY_SIZE(osk5912_cf_resources),
  150. .resource = osk5912_cf_resources,
  151. };
  152. static struct platform_device *osk5912_devices[] __initdata = {
  153. &osk5912_flash_device,
  154. &osk5912_smc91x_device,
  155. &osk5912_cf_device,
  156. };
  157. static const struct gpio_led tps_leds[] = {
  158. /* NOTE: D9 and D2 have hardware blink support.
  159. * Also, D9 requires non-battery power.
  160. */
  161. { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9",
  162. .default_trigger = "disk-activity", },
  163. { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
  164. { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
  165. .default_trigger = "heartbeat", },
  166. };
  167. static struct gpio_led_platform_data tps_leds_data = {
  168. .num_leds = 3,
  169. .leds = tps_leds,
  170. };
  171. static struct platform_device osk5912_tps_leds = {
  172. .name = "leds-gpio",
  173. .id = 0,
  174. .dev.platform_data = &tps_leds_data,
  175. };
  176. static int osk_tps_setup(struct i2c_client *client, void *context)
  177. {
  178. if (!IS_BUILTIN(CONFIG_TPS65010))
  179. return -ENOSYS;
  180. /* Set GPIO 1 HIGH to disable VBUS power supply;
  181. * OHCI driver powers it up/down as needed.
  182. */
  183. gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
  184. gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
  185. /* Free the GPIO again as the driver will request it */
  186. gpio_free(OSK_TPS_GPIO_USB_PWR_EN);
  187. /* Set GPIO 2 high so LED D3 is off by default */
  188. tps65010_set_gpio_out_value(GPIO2, HIGH);
  189. /* Set GPIO 3 low to take ethernet out of reset */
  190. gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
  191. gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
  192. /* GPIO4 is VDD_DSP */
  193. gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
  194. gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
  195. /* REVISIT if DSP support isn't configured, power it off ... */
  196. /* Let LED1 (D9) blink; leds-gpio may override it */
  197. tps65010_set_led(LED1, BLINK);
  198. /* Set LED2 off by default */
  199. tps65010_set_led(LED2, OFF);
  200. /* Enable LOW_PWR handshake */
  201. tps65010_set_low_pwr(ON);
  202. /* Switch VLDO2 to 3.0V for AIC23 */
  203. tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
  204. | TPS_LDO1_ENABLE);
  205. /* register these three LEDs */
  206. osk5912_tps_leds.dev.parent = &client->dev;
  207. platform_device_register(&osk5912_tps_leds);
  208. return 0;
  209. }
  210. static struct tps65010_board tps_board = {
  211. .base = OSK_TPS_GPIO_BASE,
  212. .outmask = 0x0f,
  213. .setup = osk_tps_setup,
  214. };
  215. static struct i2c_board_info __initdata osk_i2c_board_info[] = {
  216. {
  217. /* This device will get the name "i2c-tps65010" */
  218. I2C_BOARD_INFO("tps65010", 0x48),
  219. .dev_name = "tps65010",
  220. .platform_data = &tps_board,
  221. },
  222. {
  223. I2C_BOARD_INFO("tlv320aic23", 0x1B),
  224. },
  225. /* TODO when driver support is ready:
  226. * - optionally on Mistral, ov9640 camera sensor at 0x30
  227. */
  228. };
  229. static void __init osk_init_smc91x(void)
  230. {
  231. u32 l;
  232. if ((gpio_request(0, "smc_irq")) < 0) {
  233. printk("Error requesting gpio 0 for smc91x irq\n");
  234. return;
  235. }
  236. /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
  237. l = omap_readl(EMIFS_CCS(1));
  238. l |= 0x3;
  239. omap_writel(l, EMIFS_CCS(1));
  240. }
  241. static void __init osk_init_cf(int seg)
  242. {
  243. struct resource *res = &osk5912_cf_resources[1];
  244. omap_cfg_reg(M7_1610_GPIO62);
  245. if ((gpio_request(62, "cf_irq")) < 0) {
  246. printk("Error requesting gpio 62 for CF irq\n");
  247. return;
  248. }
  249. switch (seg) {
  250. /* NOTE: CS0 could be configured too ... */
  251. case 1:
  252. res->start = OMAP_CS1_PHYS;
  253. break;
  254. case 2:
  255. res->start = OMAP_CS2_PHYS;
  256. break;
  257. case 3:
  258. res->start = omap_cs3_phys();
  259. break;
  260. }
  261. res->end = res->start + SZ_8K - 1;
  262. osk5912_cf_device.dev.platform_data = (void *)(uintptr_t)seg;
  263. /* NOTE: better EMIFS setup might support more cards; but the
  264. * TRM only shows how to affect regular flash signals, not their
  265. * CF/PCMCIA variants...
  266. */
  267. pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", __func__,
  268. seg, omap_readl(EMIFS_CCS(seg)), omap_readl(EMIFS_ACS(seg)));
  269. omap_writel(0x0004a1b3, EMIFS_CCS(seg)); /* synch mode 4 etc */
  270. omap_writel(0x00000000, EMIFS_ACS(seg)); /* OE hold/setup */
  271. /* the CF I/O IRQ is really active-low */
  272. irq_set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING);
  273. }
  274. static struct gpiod_lookup_table osk_usb_gpio_table = {
  275. .dev_id = "ohci",
  276. .table = {
  277. /* Power GPIO on the I2C-attached TPS65010 */
  278. GPIO_LOOKUP("tps65010", 0, "power", GPIO_ACTIVE_HIGH),
  279. GPIO_LOOKUP(OMAP_GPIO_LABEL, 9, "overcurrent",
  280. GPIO_ACTIVE_HIGH),
  281. },
  282. };
  283. static struct omap_usb_config osk_usb_config __initdata = {
  284. /* has usb host connector (A) ... for development it can also
  285. * be used, with a NONSTANDARD gender-bending cable/dongle, as
  286. * a peripheral.
  287. */
  288. #if IS_ENABLED(CONFIG_USB_OMAP)
  289. .register_dev = 1,
  290. .hmc_mode = 0,
  291. #else
  292. .register_host = 1,
  293. .hmc_mode = 16,
  294. .rwc = 1,
  295. #endif
  296. .pins[0] = 2,
  297. };
  298. #ifdef CONFIG_OMAP_OSK_MISTRAL
  299. static const struct omap_lcd_config osk_lcd_config __initconst = {
  300. .ctrl_name = "internal",
  301. };
  302. #endif
  303. #ifdef CONFIG_OMAP_OSK_MISTRAL
  304. #include <linux/input.h>
  305. #include <linux/property.h>
  306. #include <linux/spi/spi.h>
  307. #include <linux/spi/ads7846.h>
  308. #include <linux/platform_data/keypad-omap.h>
  309. static const struct property_entry mistral_at24_properties[] = {
  310. PROPERTY_ENTRY_U32("pagesize", 16),
  311. { }
  312. };
  313. static const struct software_node mistral_at24_node = {
  314. .properties = mistral_at24_properties,
  315. };
  316. static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
  317. {
  318. /* NOTE: powered from LCD supply */
  319. I2C_BOARD_INFO("24c04", 0x50),
  320. .swnode = &mistral_at24_node,
  321. },
  322. /* TODO when driver support is ready:
  323. * - optionally ov9640 camera sensor at 0x30
  324. */
  325. };
  326. static const unsigned int osk_keymap[] = {
  327. /* KEY(col, row, code) */
  328. KEY(0, 0, KEY_F1), /* SW4 */
  329. KEY(3, 0, KEY_UP), /* (sw2/up) */
  330. KEY(1, 1, KEY_LEFTCTRL), /* SW5 */
  331. KEY(2, 1, KEY_LEFT), /* (sw2/left) */
  332. KEY(0, 2, KEY_SPACE), /* SW3 */
  333. KEY(1, 2, KEY_ESC), /* SW6 */
  334. KEY(2, 2, KEY_DOWN), /* (sw2/down) */
  335. KEY(2, 3, KEY_ENTER), /* (sw2/select) */
  336. KEY(3, 3, KEY_RIGHT), /* (sw2/right) */
  337. };
  338. static const struct matrix_keymap_data osk_keymap_data = {
  339. .keymap = osk_keymap,
  340. .keymap_size = ARRAY_SIZE(osk_keymap),
  341. };
  342. static struct omap_kp_platform_data osk_kp_data = {
  343. .rows = 8,
  344. .cols = 8,
  345. .keymap_data = &osk_keymap_data,
  346. .delay = 9,
  347. };
  348. static struct resource osk5912_kp_resources[] = {
  349. [0] = {
  350. .start = INT_KEYBOARD,
  351. .end = INT_KEYBOARD,
  352. .flags = IORESOURCE_IRQ,
  353. },
  354. };
  355. static struct platform_device osk5912_kp_device = {
  356. .name = "omap-keypad",
  357. .id = -1,
  358. .dev = {
  359. .platform_data = &osk_kp_data,
  360. },
  361. .num_resources = ARRAY_SIZE(osk5912_kp_resources),
  362. .resource = osk5912_kp_resources,
  363. };
  364. static struct omap_backlight_config mistral_bl_data = {
  365. .default_intensity = 0xa0,
  366. };
  367. static struct platform_device mistral_bl_device = {
  368. .name = "omap-bl",
  369. .id = -1,
  370. .dev = {
  371. .platform_data = &mistral_bl_data,
  372. },
  373. };
  374. static struct platform_device osk5912_lcd_device = {
  375. .name = "lcd_osk",
  376. .id = -1,
  377. };
  378. static const struct gpio_led mistral_gpio_led_pins[] = {
  379. {
  380. .name = "mistral:red",
  381. .default_trigger = "heartbeat",
  382. .gpio = 3,
  383. },
  384. {
  385. .name = "mistral:green",
  386. .default_trigger = "cpu0",
  387. .gpio = OMAP_MPUIO(4),
  388. },
  389. };
  390. static struct gpio_led_platform_data mistral_gpio_led_data = {
  391. .leds = mistral_gpio_led_pins,
  392. .num_leds = ARRAY_SIZE(mistral_gpio_led_pins),
  393. };
  394. static struct platform_device mistral_gpio_leds = {
  395. .name = "leds-gpio",
  396. .id = -1,
  397. .dev = {
  398. .platform_data = &mistral_gpio_led_data,
  399. },
  400. };
  401. static struct platform_device *mistral_devices[] __initdata = {
  402. &osk5912_kp_device,
  403. &mistral_bl_device,
  404. &osk5912_lcd_device,
  405. &mistral_gpio_leds,
  406. };
  407. static int mistral_get_pendown_state(void)
  408. {
  409. return !gpio_get_value(4);
  410. }
  411. static const struct ads7846_platform_data mistral_ts_info = {
  412. .model = 7846,
  413. .vref_delay_usecs = 100, /* internal, no capacitor */
  414. .x_plate_ohms = 419,
  415. .y_plate_ohms = 486,
  416. .get_pendown_state = mistral_get_pendown_state,
  417. };
  418. static struct spi_board_info __initdata mistral_boardinfo[] = { {
  419. /* MicroWire (bus 2) CS0 has an ads7846e */
  420. .modalias = "ads7846",
  421. .platform_data = &mistral_ts_info,
  422. .max_speed_hz = 120000 /* max sample rate at 3V */
  423. * 26 /* command + data + overhead */,
  424. .bus_num = 2,
  425. .chip_select = 0,
  426. } };
  427. static irqreturn_t
  428. osk_mistral_wake_interrupt(int irq, void *ignored)
  429. {
  430. return IRQ_HANDLED;
  431. }
  432. static void __init osk_mistral_init(void)
  433. {
  434. /* NOTE: we could actually tell if there's a Mistral board
  435. * attached, e.g. by trying to read something from the ads7846.
  436. * But this arch_init() code is too early for that, since we
  437. * can't talk to the ads or even the i2c eeprom.
  438. */
  439. /* parallel camera interface */
  440. omap_cfg_reg(J15_1610_CAM_LCLK);
  441. omap_cfg_reg(J18_1610_CAM_D7);
  442. omap_cfg_reg(J19_1610_CAM_D6);
  443. omap_cfg_reg(J14_1610_CAM_D5);
  444. omap_cfg_reg(K18_1610_CAM_D4);
  445. omap_cfg_reg(K19_1610_CAM_D3);
  446. omap_cfg_reg(K15_1610_CAM_D2);
  447. omap_cfg_reg(K14_1610_CAM_D1);
  448. omap_cfg_reg(L19_1610_CAM_D0);
  449. omap_cfg_reg(L18_1610_CAM_VS);
  450. omap_cfg_reg(L15_1610_CAM_HS);
  451. omap_cfg_reg(M19_1610_CAM_RSTZ);
  452. omap_cfg_reg(Y15_1610_CAM_OUTCLK);
  453. /* serial camera interface */
  454. omap_cfg_reg(H19_1610_CAM_EXCLK);
  455. omap_cfg_reg(W13_1610_CCP_CLKM);
  456. omap_cfg_reg(Y12_1610_CCP_CLKP);
  457. /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
  458. /* omap_cfg_reg(Y14_1610_CCP_DATAM); */
  459. omap_cfg_reg(W14_1610_CCP_DATAP);
  460. /* CAM_PWDN */
  461. if (gpio_request(11, "cam_pwdn") == 0) {
  462. omap_cfg_reg(N20_1610_GPIO11);
  463. gpio_direction_output(11, 0);
  464. } else
  465. pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
  466. /* omap_cfg_reg(P19_1610_GPIO6); */ /* BUSY */
  467. gpio_request(6, "ts_busy");
  468. gpio_direction_input(6);
  469. omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */
  470. gpio_request(4, "ts_int");
  471. gpio_direction_input(4);
  472. irq_set_irq_type(gpio_to_irq(4), IRQ_TYPE_EDGE_FALLING);
  473. mistral_boardinfo[0].irq = gpio_to_irq(4);
  474. spi_register_board_info(mistral_boardinfo,
  475. ARRAY_SIZE(mistral_boardinfo));
  476. /* the sideways button (SW1) is for use as a "wakeup" button
  477. *
  478. * NOTE: The Mistral board has the wakeup button (SW1) wired
  479. * to the LCD 3.3V rail, which is powered down during suspend.
  480. * To allow this button to wake up the omap, work around this
  481. * HW bug by rewiring SW1 to use the main 3.3V rail.
  482. */
  483. omap_cfg_reg(N15_1610_MPUIO2);
  484. if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) {
  485. int ret = 0;
  486. int irq = gpio_to_irq(OMAP_MPUIO(2));
  487. gpio_direction_input(OMAP_MPUIO(2));
  488. irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
  489. /* share the IRQ in case someone wants to use the
  490. * button for more than wakeup from system sleep.
  491. */
  492. ret = request_irq(irq,
  493. &osk_mistral_wake_interrupt,
  494. IRQF_SHARED, "mistral_wakeup",
  495. &osk_mistral_wake_interrupt);
  496. if (ret != 0) {
  497. gpio_free(OMAP_MPUIO(2));
  498. printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
  499. ret);
  500. } else
  501. enable_irq_wake(irq);
  502. } else
  503. printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
  504. /* LCD: backlight, and power; power controls other devices on the
  505. * board, like the touchscreen, EEPROM, and wakeup (!) switch.
  506. */
  507. omap_cfg_reg(PWL);
  508. if (gpio_request(2, "lcd_pwr") == 0)
  509. gpio_direction_output(2, 1);
  510. /*
  511. * GPIO based LEDs
  512. */
  513. omap_cfg_reg(P18_1610_GPIO3);
  514. omap_cfg_reg(MPUIO4);
  515. i2c_register_board_info(1, mistral_i2c_board_info,
  516. ARRAY_SIZE(mistral_i2c_board_info));
  517. platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
  518. }
  519. #else
  520. static void __init osk_mistral_init(void) { }
  521. #endif
  522. #define EMIFS_CS3_VAL (0x88013141)
  523. static void __init osk_init(void)
  524. {
  525. u32 l;
  526. osk_init_smc91x();
  527. osk_init_cf(2); /* CS2 */
  528. /* Workaround for wrong CS3 (NOR flash) timing
  529. * There are some U-Boot versions out there which configure
  530. * wrong CS3 memory timings. This mainly leads to CRC
  531. * or similar errors if you use NOR flash (e.g. with JFFS2)
  532. */
  533. l = omap_readl(EMIFS_CCS(3));
  534. if (l != EMIFS_CS3_VAL)
  535. omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3));
  536. osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
  537. osk_flash_resource.end += SZ_32M - 1;
  538. osk5912_smc91x_resources[1].start = gpio_to_irq(0);
  539. osk5912_smc91x_resources[1].end = gpio_to_irq(0);
  540. osk5912_cf_resources[0].start = gpio_to_irq(62);
  541. osk5912_cf_resources[0].end = gpio_to_irq(62);
  542. platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
  543. l = omap_readl(USB_TRANSCEIVER_CTRL);
  544. l |= (3 << 1);
  545. omap_writel(l, USB_TRANSCEIVER_CTRL);
  546. gpiod_add_lookup_table(&osk_usb_gpio_table);
  547. omap1_usb_init(&osk_usb_config);
  548. /* irq for tps65010 chip */
  549. /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */
  550. if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
  551. gpio_direction_input(OMAP_MPUIO(1));
  552. omap_serial_init();
  553. osk_i2c_board_info[0].irq = gpio_to_irq(OMAP_MPUIO(1));
  554. omap_register_i2c_bus(1, 400, osk_i2c_board_info,
  555. ARRAY_SIZE(osk_i2c_board_info));
  556. osk_mistral_init();
  557. #ifdef CONFIG_OMAP_OSK_MISTRAL
  558. omapfb_set_lcd_config(&osk_lcd_config);
  559. #endif
  560. }
  561. MACHINE_START(OMAP_OSK, "TI-OSK")
  562. /* Maintainer: Dirk Behme <[email protected]> */
  563. .atag_offset = 0x100,
  564. .map_io = omap16xx_map_io,
  565. .init_early = omap1_init_early,
  566. .init_irq = omap1_init_irq,
  567. .handle_irq = omap1_handle_irq,
  568. .init_machine = osk_init,
  569. .init_late = omap1_init_late,
  570. .init_time = omap1_timer_init,
  571. .restart = omap1_restart,
  572. MACHINE_END