board-osk.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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/mtd/mtd.h>
  35. #include <linux/mtd/partitions.h>
  36. #include <linux/i2c/tps65010.h>
  37. #include <asm/hardware.h>
  38. #include <asm/gpio.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/mach/map.h>
  42. #include <asm/mach/flash.h>
  43. #include <asm/arch/usb.h>
  44. #include <asm/arch/mux.h>
  45. #include <asm/arch/tc.h>
  46. #include <asm/arch/common.h>
  47. #include <asm/arch/mcbsp.h>
  48. #include <asm/arch/omap-alsa.h>
  49. static struct mtd_partition osk_partitions[] = {
  50. /* bootloader (U-Boot, etc) in first sector */
  51. {
  52. .name = "bootloader",
  53. .offset = 0,
  54. .size = SZ_128K,
  55. .mask_flags = MTD_WRITEABLE, /* force read-only */
  56. },
  57. /* bootloader params in the next sector */
  58. {
  59. .name = "params",
  60. .offset = MTDPART_OFS_APPEND,
  61. .size = SZ_128K,
  62. .mask_flags = 0,
  63. }, {
  64. .name = "kernel",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = SZ_2M,
  67. .mask_flags = 0
  68. }, {
  69. .name = "filesystem",
  70. .offset = MTDPART_OFS_APPEND,
  71. .size = MTDPART_SIZ_FULL,
  72. .mask_flags = 0
  73. }
  74. };
  75. static struct flash_platform_data osk_flash_data = {
  76. .map_name = "cfi_probe",
  77. .width = 2,
  78. .parts = osk_partitions,
  79. .nr_parts = ARRAY_SIZE(osk_partitions),
  80. };
  81. static struct resource osk_flash_resource = {
  82. /* this is on CS3, wherever it's mapped */
  83. .flags = IORESOURCE_MEM,
  84. };
  85. static struct platform_device osk5912_flash_device = {
  86. .name = "omapflash",
  87. .id = 0,
  88. .dev = {
  89. .platform_data = &osk_flash_data,
  90. },
  91. .num_resources = 1,
  92. .resource = &osk_flash_resource,
  93. };
  94. static struct resource osk5912_smc91x_resources[] = {
  95. [0] = {
  96. .start = OMAP_OSK_ETHR_START, /* Physical */
  97. .end = OMAP_OSK_ETHR_START + 0xf,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. [1] = {
  101. .start = OMAP_GPIO_IRQ(0),
  102. .end = OMAP_GPIO_IRQ(0),
  103. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  104. },
  105. };
  106. static struct platform_device osk5912_smc91x_device = {
  107. .name = "smc91x",
  108. .id = -1,
  109. .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
  110. .resource = osk5912_smc91x_resources,
  111. };
  112. static struct resource osk5912_cf_resources[] = {
  113. [0] = {
  114. .start = OMAP_GPIO_IRQ(62),
  115. .end = OMAP_GPIO_IRQ(62),
  116. .flags = IORESOURCE_IRQ,
  117. },
  118. };
  119. static struct platform_device osk5912_cf_device = {
  120. .name = "omap_cf",
  121. .id = -1,
  122. .dev = {
  123. .platform_data = (void *) 2 /* CS2 */,
  124. },
  125. .num_resources = ARRAY_SIZE(osk5912_cf_resources),
  126. .resource = osk5912_cf_resources,
  127. };
  128. #define DEFAULT_BITPERSAMPLE 16
  129. static struct omap_mcbsp_reg_cfg mcbsp_regs = {
  130. .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
  131. .spcr1 = RINTM(3) | RRST,
  132. .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
  133. RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
  134. .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
  135. .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
  136. XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
  137. .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
  138. .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
  139. .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
  140. /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
  141. .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
  142. };
  143. static struct omap_alsa_codec_config alsa_config = {
  144. .name = "OSK AIC23",
  145. .mcbsp_regs_alsa = &mcbsp_regs,
  146. .codec_configure_dev = NULL, /* aic23_configure, */
  147. .codec_set_samplerate = NULL, /* aic23_set_samplerate, */
  148. .codec_clock_setup = NULL, /* aic23_clock_setup, */
  149. .codec_clock_on = NULL, /* aic23_clock_on, */
  150. .codec_clock_off = NULL, /* aic23_clock_off, */
  151. .get_default_samplerate = NULL, /* aic23_get_default_samplerate, */
  152. };
  153. static struct platform_device osk5912_mcbsp1_device = {
  154. .name = "omap_alsa_mcbsp",
  155. .id = 1,
  156. .dev = {
  157. .platform_data = &alsa_config,
  158. },
  159. };
  160. static struct platform_device *osk5912_devices[] __initdata = {
  161. &osk5912_flash_device,
  162. &osk5912_smc91x_device,
  163. &osk5912_cf_device,
  164. &osk5912_mcbsp1_device,
  165. };
  166. static struct i2c_board_info __initdata osk_i2c_board_info[] = {
  167. {
  168. I2C_BOARD_INFO("tps65010", 0x48),
  169. .type = "tps65010",
  170. .irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)),
  171. },
  172. /* TODO when driver support is ready:
  173. * - aic23 audio chip at 0x1a
  174. * - on Mistral, 24c04 eeprom at 0x50
  175. * - optionally on Mistral, ov9640 camera sensor at 0x30
  176. */
  177. };
  178. static void __init osk_init_smc91x(void)
  179. {
  180. if ((omap_request_gpio(0)) < 0) {
  181. printk("Error requesting gpio 0 for smc91x irq\n");
  182. return;
  183. }
  184. /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
  185. EMIFS_CCS(1) |= 0x3;
  186. }
  187. static void __init osk_init_cf(void)
  188. {
  189. omap_cfg_reg(M7_1610_GPIO62);
  190. if ((omap_request_gpio(62)) < 0) {
  191. printk("Error requesting gpio 62 for CF irq\n");
  192. return;
  193. }
  194. /* the CF I/O IRQ is really active-low */
  195. set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING);
  196. }
  197. static void __init osk_init_irq(void)
  198. {
  199. omap1_init_common_hw();
  200. omap_init_irq();
  201. omap_gpio_init();
  202. osk_init_smc91x();
  203. osk_init_cf();
  204. }
  205. static struct omap_usb_config osk_usb_config __initdata = {
  206. /* has usb host connector (A) ... for development it can also
  207. * be used, with a NONSTANDARD gender-bending cable/dongle, as
  208. * a peripheral.
  209. */
  210. #ifdef CONFIG_USB_GADGET_OMAP
  211. .register_dev = 1,
  212. .hmc_mode = 0,
  213. #else
  214. .register_host = 1,
  215. .hmc_mode = 16,
  216. .rwc = 1,
  217. #endif
  218. .pins[0] = 2,
  219. };
  220. static struct omap_uart_config osk_uart_config __initdata = {
  221. .enabled_uarts = (1 << 0),
  222. };
  223. #ifdef CONFIG_OMAP_OSK_MISTRAL
  224. static struct omap_lcd_config osk_lcd_config __initdata = {
  225. .ctrl_name = "internal",
  226. };
  227. #endif
  228. static struct omap_board_config_kernel osk_config[] __initdata = {
  229. { OMAP_TAG_USB, &osk_usb_config },
  230. { OMAP_TAG_UART, &osk_uart_config },
  231. #ifdef CONFIG_OMAP_OSK_MISTRAL
  232. { OMAP_TAG_LCD, &osk_lcd_config },
  233. #endif
  234. };
  235. #ifdef CONFIG_OMAP_OSK_MISTRAL
  236. #include <linux/input.h>
  237. #include <linux/spi/spi.h>
  238. #include <linux/spi/ads7846.h>
  239. #include <asm/arch/keypad.h>
  240. static const int osk_keymap[] = {
  241. /* KEY(col, row, code) */
  242. KEY(0, 0, KEY_F1), /* SW4 */
  243. KEY(0, 3, KEY_UP), /* (sw2/up) */
  244. KEY(1, 1, KEY_LEFTCTRL), /* SW5 */
  245. KEY(1, 2, KEY_LEFT), /* (sw2/left) */
  246. KEY(2, 0, KEY_SPACE), /* SW3 */
  247. KEY(2, 1, KEY_ESC), /* SW6 */
  248. KEY(2, 2, KEY_DOWN), /* (sw2/down) */
  249. KEY(3, 2, KEY_ENTER), /* (sw2/select) */
  250. KEY(3, 3, KEY_RIGHT), /* (sw2/right) */
  251. 0
  252. };
  253. static struct omap_kp_platform_data osk_kp_data = {
  254. .rows = 8,
  255. .cols = 8,
  256. .keymap = (int *) osk_keymap,
  257. .keymapsize = ARRAY_SIZE(osk_keymap),
  258. .delay = 9,
  259. };
  260. static struct resource osk5912_kp_resources[] = {
  261. [0] = {
  262. .start = INT_KEYBOARD,
  263. .end = INT_KEYBOARD,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. };
  267. static struct platform_device osk5912_kp_device = {
  268. .name = "omap-keypad",
  269. .id = -1,
  270. .dev = {
  271. .platform_data = &osk_kp_data,
  272. },
  273. .num_resources = ARRAY_SIZE(osk5912_kp_resources),
  274. .resource = osk5912_kp_resources,
  275. };
  276. static struct omap_backlight_config mistral_bl_data = {
  277. .default_intensity = 0xa0,
  278. };
  279. static struct platform_device mistral_bl_device = {
  280. .name = "omap-bl",
  281. .id = -1,
  282. .dev = {
  283. .platform_data = &mistral_bl_data,
  284. },
  285. };
  286. static struct platform_device osk5912_lcd_device = {
  287. .name = "lcd_osk",
  288. .id = -1,
  289. };
  290. static struct platform_device *mistral_devices[] __initdata = {
  291. &osk5912_kp_device,
  292. &mistral_bl_device,
  293. &osk5912_lcd_device,
  294. };
  295. static int mistral_get_pendown_state(void)
  296. {
  297. return !omap_get_gpio_datain(4);
  298. }
  299. static const struct ads7846_platform_data mistral_ts_info = {
  300. .model = 7846,
  301. .vref_delay_usecs = 100, /* internal, no capacitor */
  302. .x_plate_ohms = 419,
  303. .y_plate_ohms = 486,
  304. .get_pendown_state = mistral_get_pendown_state,
  305. };
  306. static struct spi_board_info __initdata mistral_boardinfo[] = { {
  307. /* MicroWire (bus 2) CS0 has an ads7846e */
  308. .modalias = "ads7846",
  309. .platform_data = &mistral_ts_info,
  310. .irq = OMAP_GPIO_IRQ(4),
  311. .max_speed_hz = 120000 /* max sample rate at 3V */
  312. * 26 /* command + data + overhead */,
  313. .bus_num = 2,
  314. .chip_select = 0,
  315. } };
  316. #ifdef CONFIG_PM
  317. static irqreturn_t
  318. osk_mistral_wake_interrupt(int irq, void *ignored)
  319. {
  320. return IRQ_HANDLED;
  321. }
  322. #endif
  323. static void __init osk_mistral_init(void)
  324. {
  325. /* NOTE: we could actually tell if there's a Mistral board
  326. * attached, e.g. by trying to read something from the ads7846.
  327. * But this arch_init() code is too early for that, since we
  328. * can't talk to the ads or even the i2c eeprom.
  329. */
  330. /* parallel camera interface */
  331. omap_cfg_reg(J15_1610_CAM_LCLK);
  332. omap_cfg_reg(J18_1610_CAM_D7);
  333. omap_cfg_reg(J19_1610_CAM_D6);
  334. omap_cfg_reg(J14_1610_CAM_D5);
  335. omap_cfg_reg(K18_1610_CAM_D4);
  336. omap_cfg_reg(K19_1610_CAM_D3);
  337. omap_cfg_reg(K15_1610_CAM_D2);
  338. omap_cfg_reg(K14_1610_CAM_D1);
  339. omap_cfg_reg(L19_1610_CAM_D0);
  340. omap_cfg_reg(L18_1610_CAM_VS);
  341. omap_cfg_reg(L15_1610_CAM_HS);
  342. omap_cfg_reg(M19_1610_CAM_RSTZ);
  343. omap_cfg_reg(Y15_1610_CAM_OUTCLK);
  344. /* serial camera interface */
  345. omap_cfg_reg(H19_1610_CAM_EXCLK);
  346. omap_cfg_reg(W13_1610_CCP_CLKM);
  347. omap_cfg_reg(Y12_1610_CCP_CLKP);
  348. /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
  349. /* omap_cfg_reg(Y14_1610_CCP_DATAM); */
  350. omap_cfg_reg(W14_1610_CCP_DATAP);
  351. /* CAM_PWDN */
  352. if (omap_request_gpio(11) == 0) {
  353. omap_cfg_reg(N20_1610_GPIO11);
  354. omap_set_gpio_direction(11, 0 /* out */);
  355. omap_set_gpio_dataout(11, 0 /* off */);
  356. } else
  357. pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
  358. /* omap_cfg_reg(P19_1610_GPIO6); */ /* BUSY */
  359. omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */
  360. set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING);
  361. spi_register_board_info(mistral_boardinfo,
  362. ARRAY_SIZE(mistral_boardinfo));
  363. /* the sideways button (SW1) is for use as a "wakeup" button */
  364. omap_cfg_reg(N15_1610_MPUIO2);
  365. if (omap_request_gpio(OMAP_MPUIO(2)) == 0) {
  366. int ret = 0;
  367. omap_set_gpio_direction(OMAP_MPUIO(2), 1);
  368. set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING);
  369. #ifdef CONFIG_PM
  370. /* share the IRQ in case someone wants to use the
  371. * button for more than wakeup from system sleep.
  372. */
  373. ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)),
  374. &osk_mistral_wake_interrupt,
  375. IRQF_SHARED, "mistral_wakeup",
  376. &osk_mistral_wake_interrupt);
  377. if (ret != 0) {
  378. omap_free_gpio(OMAP_MPUIO(2));
  379. printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
  380. ret);
  381. } else
  382. enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2)));
  383. #endif
  384. } else
  385. printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
  386. /* LCD: backlight, and power; power controls other devices on the
  387. * board, like the touchscreen, EEPROM, and wakeup (!) switch.
  388. */
  389. omap_cfg_reg(PWL);
  390. if (omap_request_gpio(2) == 0) {
  391. omap_set_gpio_direction(2, 0 /* out */);
  392. omap_set_gpio_dataout(2, 1 /* on */);
  393. }
  394. platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
  395. }
  396. #else
  397. static void __init osk_mistral_init(void) { }
  398. #endif
  399. #define EMIFS_CS3_VAL (0x88013141)
  400. static void __init osk_init(void)
  401. {
  402. /* Workaround for wrong CS3 (NOR flash) timing
  403. * There are some U-Boot versions out there which configure
  404. * wrong CS3 memory timings. This mainly leads to CRC
  405. * or similar errors if you use NOR flash (e.g. with JFFS2)
  406. */
  407. if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
  408. EMIFS_CCS(3) = EMIFS_CS3_VAL;
  409. osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
  410. osk_flash_resource.end += SZ_32M - 1;
  411. platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
  412. omap_board_config = osk_config;
  413. omap_board_config_size = ARRAY_SIZE(osk_config);
  414. USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
  415. /* irq for tps65010 chip */
  416. /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */
  417. if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
  418. gpio_direction_input(OMAP_MPUIO(1));
  419. omap_serial_init();
  420. omap_register_i2c_bus(1, 400, osk_i2c_board_info,
  421. ARRAY_SIZE(osk_i2c_board_info));
  422. osk_mistral_init();
  423. }
  424. static void __init osk_map_io(void)
  425. {
  426. omap1_map_common_io();
  427. }
  428. #ifdef CONFIG_TPS65010
  429. static int __init osk_tps_init(void)
  430. {
  431. if (!machine_is_omap_osk())
  432. return 0;
  433. /* Let LED1 (D9) blink */
  434. tps65010_set_led(LED1, BLINK);
  435. /* Disable LED 2 (D2) */
  436. tps65010_set_led(LED2, OFF);
  437. /* Set GPIO 1 HIGH to disable VBUS power supply;
  438. * OHCI driver powers it up/down as needed.
  439. */
  440. tps65010_set_gpio_out_value(GPIO1, HIGH);
  441. /* Set GPIO 2 low to turn on LED D3 */
  442. tps65010_set_gpio_out_value(GPIO2, HIGH);
  443. /* Set GPIO 3 low to take ethernet out of reset */
  444. tps65010_set_gpio_out_value(GPIO3, LOW);
  445. /* gpio4 for VDD_DSP */
  446. /* FIXME send power to DSP iff it's configured */
  447. /* Enable LOW_PWR */
  448. tps65010_set_low_pwr(ON);
  449. /* Switch VLDO2 to 3.0V for AIC23 */
  450. tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
  451. | TPS_LDO1_ENABLE);
  452. return 0;
  453. }
  454. fs_initcall(osk_tps_init);
  455. #endif
  456. MACHINE_START(OMAP_OSK, "TI-OSK")
  457. /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
  458. .phys_io = 0xfff00000,
  459. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  460. .boot_params = 0x10000100,
  461. .map_io = osk_map_io,
  462. .init_irq = osk_init_irq,
  463. .init_machine = osk_init,
  464. .timer = &omap_timer,
  465. MACHINE_END