board-osk.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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/interrupt.h>
  34. #include <linux/mtd/mtd.h>
  35. #include <linux/mtd/partitions.h>
  36. #include <asm/hardware.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/map.h>
  40. #include <asm/mach/flash.h>
  41. #include <asm/arch/gpio.h>
  42. #include <asm/arch/usb.h>
  43. #include <asm/arch/mux.h>
  44. #include <asm/arch/tc.h>
  45. #include <asm/arch/common.h>
  46. #include <asm/arch/mcbsp.h>
  47. #include <asm/arch/omap-alsa.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,
  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. #define DEFAULT_BITPERSAMPLE 16
  128. static struct omap_mcbsp_reg_cfg mcbsp_regs = {
  129. .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
  130. .spcr1 = RINTM(3) | RRST,
  131. .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
  132. RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
  133. .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
  134. .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
  135. XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
  136. .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
  137. .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
  138. .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
  139. /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
  140. .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
  141. };
  142. static struct omap_alsa_codec_config alsa_config = {
  143. .name = "OSK AIC23",
  144. .mcbsp_regs_alsa = &mcbsp_regs,
  145. .codec_configure_dev = NULL, // aic23_configure,
  146. .codec_set_samplerate = NULL, // aic23_set_samplerate,
  147. .codec_clock_setup = NULL, // aic23_clock_setup,
  148. .codec_clock_on = NULL, // aic23_clock_on,
  149. .codec_clock_off = NULL, // aic23_clock_off,
  150. .get_default_samplerate = NULL, // aic23_get_default_samplerate,
  151. };
  152. static struct platform_device osk5912_mcbsp1_device = {
  153. .name = "omap_alsa_mcbsp",
  154. .id = 1,
  155. .dev = {
  156. .platform_data = &alsa_config,
  157. },
  158. };
  159. static struct platform_device *osk5912_devices[] __initdata = {
  160. &osk5912_flash_device,
  161. &osk5912_smc91x_device,
  162. &osk5912_cf_device,
  163. &osk5912_mcbsp1_device,
  164. };
  165. static void __init osk_init_smc91x(void)
  166. {
  167. if ((omap_request_gpio(0)) < 0) {
  168. printk("Error requesting gpio 0 for smc91x irq\n");
  169. return;
  170. }
  171. /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
  172. EMIFS_CCS(1) |= 0x3;
  173. }
  174. static void __init osk_init_cf(void)
  175. {
  176. omap_cfg_reg(M7_1610_GPIO62);
  177. if ((omap_request_gpio(62)) < 0) {
  178. printk("Error requesting gpio 62 for CF irq\n");
  179. return;
  180. }
  181. /* the CF I/O IRQ is really active-low */
  182. set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING);
  183. }
  184. static void __init osk_init_irq(void)
  185. {
  186. omap1_init_common_hw();
  187. omap_init_irq();
  188. omap_gpio_init();
  189. osk_init_smc91x();
  190. osk_init_cf();
  191. }
  192. static struct omap_usb_config osk_usb_config __initdata = {
  193. /* has usb host connector (A) ... for development it can also
  194. * be used, with a NONSTANDARD gender-bending cable/dongle, as
  195. * a peripheral.
  196. */
  197. #ifdef CONFIG_USB_GADGET_OMAP
  198. .register_dev = 1,
  199. .hmc_mode = 0,
  200. #else
  201. .register_host = 1,
  202. .hmc_mode = 16,
  203. .rwc = 1,
  204. #endif
  205. .pins[0] = 2,
  206. };
  207. static struct omap_uart_config osk_uart_config __initdata = {
  208. .enabled_uarts = (1 << 0),
  209. };
  210. #ifdef CONFIG_OMAP_OSK_MISTRAL
  211. static struct omap_lcd_config osk_lcd_config __initdata = {
  212. .ctrl_name = "internal",
  213. };
  214. #endif
  215. static struct omap_board_config_kernel osk_config[] = {
  216. { OMAP_TAG_USB, &osk_usb_config },
  217. { OMAP_TAG_UART, &osk_uart_config },
  218. #ifdef CONFIG_OMAP_OSK_MISTRAL
  219. { OMAP_TAG_LCD, &osk_lcd_config },
  220. #endif
  221. };
  222. #ifdef CONFIG_OMAP_OSK_MISTRAL
  223. #include <linux/input.h>
  224. #include <linux/spi/spi.h>
  225. #include <linux/spi/ads7846.h>
  226. #include <asm/arch/keypad.h>
  227. static const int osk_keymap[] = {
  228. /* KEY(col, row, code) */
  229. KEY(0, 0, KEY_F1), /* SW4 */
  230. KEY(0, 3, KEY_UP), /* (sw2/up) */
  231. KEY(1, 1, KEY_LEFTCTRL), /* SW5 */
  232. KEY(1, 2, KEY_LEFT), /* (sw2/left) */
  233. KEY(2, 0, KEY_SPACE), /* SW3 */
  234. KEY(2, 1, KEY_ESC), /* SW6 */
  235. KEY(2, 2, KEY_DOWN), /* (sw2/down) */
  236. KEY(3, 2, KEY_ENTER), /* (sw2/select) */
  237. KEY(3, 3, KEY_RIGHT), /* (sw2/right) */
  238. 0
  239. };
  240. static struct omap_kp_platform_data osk_kp_data = {
  241. .rows = 8,
  242. .cols = 8,
  243. .keymap = (int *) osk_keymap,
  244. .keymapsize = ARRAY_SIZE(osk_keymap),
  245. .delay = 9,
  246. };
  247. static struct resource osk5912_kp_resources[] = {
  248. [0] = {
  249. .start = INT_KEYBOARD,
  250. .end = INT_KEYBOARD,
  251. .flags = IORESOURCE_IRQ,
  252. },
  253. };
  254. static struct platform_device osk5912_kp_device = {
  255. .name = "omap-keypad",
  256. .id = -1,
  257. .dev = {
  258. .platform_data = &osk_kp_data,
  259. },
  260. .num_resources = ARRAY_SIZE(osk5912_kp_resources),
  261. .resource = osk5912_kp_resources,
  262. };
  263. static struct omap_backlight_config mistral_bl_data = {
  264. .default_intensity = 0xa0,
  265. };
  266. static struct platform_device mistral_bl_device = {
  267. .name = "omap-bl",
  268. .id = -1,
  269. .dev = {
  270. .platform_data = &mistral_bl_data,
  271. },
  272. };
  273. static struct platform_device osk5912_lcd_device = {
  274. .name = "lcd_osk",
  275. .id = -1,
  276. };
  277. static struct platform_device *mistral_devices[] __initdata = {
  278. &osk5912_kp_device,
  279. &mistral_bl_device,
  280. &osk5912_lcd_device,
  281. };
  282. static int mistral_get_pendown_state(void)
  283. {
  284. return !omap_get_gpio_datain(4);
  285. }
  286. static const struct ads7846_platform_data mistral_ts_info = {
  287. .model = 7846,
  288. .vref_delay_usecs = 100, /* internal, no capacitor */
  289. .x_plate_ohms = 419,
  290. .y_plate_ohms = 486,
  291. .get_pendown_state = mistral_get_pendown_state,
  292. };
  293. static struct spi_board_info __initdata mistral_boardinfo[] = { {
  294. /* MicroWire (bus 2) CS0 has an ads7846e */
  295. .modalias = "ads7846",
  296. .platform_data = &mistral_ts_info,
  297. .irq = OMAP_GPIO_IRQ(4),
  298. .max_speed_hz = 120000 /* max sample rate at 3V */
  299. * 26 /* command + data + overhead */,
  300. .bus_num = 2,
  301. .chip_select = 0,
  302. } };
  303. #ifdef CONFIG_PM
  304. static irqreturn_t
  305. osk_mistral_wake_interrupt(int irq, void *ignored)
  306. {
  307. return IRQ_HANDLED;
  308. }
  309. #endif
  310. static void __init osk_mistral_init(void)
  311. {
  312. /* NOTE: we could actually tell if there's a Mistral board
  313. * attached, e.g. by trying to read something from the ads7846.
  314. * But this arch_init() code is too early for that, since we
  315. * can't talk to the ads or even the i2c eeprom.
  316. */
  317. /* parallel camera interface */
  318. omap_cfg_reg(J15_1610_CAM_LCLK);
  319. omap_cfg_reg(J18_1610_CAM_D7);
  320. omap_cfg_reg(J19_1610_CAM_D6);
  321. omap_cfg_reg(J14_1610_CAM_D5);
  322. omap_cfg_reg(K18_1610_CAM_D4);
  323. omap_cfg_reg(K19_1610_CAM_D3);
  324. omap_cfg_reg(K15_1610_CAM_D2);
  325. omap_cfg_reg(K14_1610_CAM_D1);
  326. omap_cfg_reg(L19_1610_CAM_D0);
  327. omap_cfg_reg(L18_1610_CAM_VS);
  328. omap_cfg_reg(L15_1610_CAM_HS);
  329. omap_cfg_reg(M19_1610_CAM_RSTZ);
  330. omap_cfg_reg(Y15_1610_CAM_OUTCLK);
  331. /* serial camera interface */
  332. omap_cfg_reg(H19_1610_CAM_EXCLK);
  333. omap_cfg_reg(W13_1610_CCP_CLKM);
  334. omap_cfg_reg(Y12_1610_CCP_CLKP);
  335. /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
  336. // omap_cfg_reg(Y14_1610_CCP_DATAM);
  337. omap_cfg_reg(W14_1610_CCP_DATAP);
  338. /* CAM_PWDN */
  339. if (omap_request_gpio(11) == 0) {
  340. omap_cfg_reg(N20_1610_GPIO11);
  341. omap_set_gpio_direction(11, 0 /* out */);
  342. omap_set_gpio_dataout(11, 0 /* off */);
  343. } else
  344. pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
  345. // omap_cfg_reg(P19_1610_GPIO6); // BUSY
  346. omap_cfg_reg(P20_1610_GPIO4); // PENIRQ
  347. set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING);
  348. spi_register_board_info(mistral_boardinfo,
  349. ARRAY_SIZE(mistral_boardinfo));
  350. /* the sideways button (SW1) is for use as a "wakeup" button */
  351. omap_cfg_reg(N15_1610_MPUIO2);
  352. if (omap_request_gpio(OMAP_MPUIO(2)) == 0) {
  353. int ret = 0;
  354. omap_set_gpio_direction(OMAP_MPUIO(2), 1);
  355. set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING);
  356. #ifdef CONFIG_PM
  357. /* share the IRQ in case someone wants to use the
  358. * button for more than wakeup from system sleep.
  359. */
  360. ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)),
  361. &osk_mistral_wake_interrupt,
  362. IRQF_SHARED, "mistral_wakeup",
  363. &osk_mistral_wake_interrupt);
  364. if (ret != 0) {
  365. omap_free_gpio(OMAP_MPUIO(2));
  366. printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
  367. ret);
  368. } else
  369. enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2)));
  370. #endif
  371. } else
  372. printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
  373. /* LCD: backlight, and power; power controls other devices on the
  374. * board, like the touchscreen, EEPROM, and wakeup (!) switch.
  375. */
  376. omap_cfg_reg(PWL);
  377. if (omap_request_gpio(2) == 0) {
  378. omap_set_gpio_direction(2, 0 /* out */);
  379. omap_set_gpio_dataout(2, 1 /* on */);
  380. }
  381. platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
  382. }
  383. #else
  384. static void __init osk_mistral_init(void) { }
  385. #endif
  386. #define EMIFS_CS3_VAL (0x88013141)
  387. static void __init osk_init(void)
  388. {
  389. /* Workaround for wrong CS3 (NOR flash) timing
  390. * There are some U-Boot versions out there which configure
  391. * wrong CS3 memory timings. This mainly leads to CRC
  392. * or similar errors if you use NOR flash (e.g. with JFFS2)
  393. */
  394. if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
  395. EMIFS_CCS(3) = EMIFS_CS3_VAL;
  396. osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
  397. osk_flash_resource.end += SZ_32M - 1;
  398. platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
  399. omap_board_config = osk_config;
  400. omap_board_config_size = ARRAY_SIZE(osk_config);
  401. USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
  402. omap_serial_init();
  403. osk_mistral_init();
  404. }
  405. static void __init osk_map_io(void)
  406. {
  407. omap1_map_common_io();
  408. }
  409. MACHINE_START(OMAP_OSK, "TI-OSK")
  410. /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
  411. .phys_io = 0xfff00000,
  412. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  413. .boot_params = 0x10000100,
  414. .map_io = osk_map_io,
  415. .init_irq = osk_init_irq,
  416. .init_machine = osk_init,
  417. .timer = &omap_timer,
  418. MACHINE_END