board-osk.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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/irq.h>
  32. #include <linux/mtd/mtd.h>
  33. #include <linux/mtd/partitions.h>
  34. #include <asm/hardware.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/flash.h>
  39. #include <asm/arch/gpio.h>
  40. #include <asm/arch/usb.h>
  41. #include <asm/arch/mux.h>
  42. #include <asm/arch/tc.h>
  43. #include <asm/arch/common.h>
  44. #include <asm/arch/mcbsp.h>
  45. #include <asm/arch/omap-alsa.h>
  46. static struct mtd_partition osk_partitions[] = {
  47. /* bootloader (U-Boot, etc) in first sector */
  48. {
  49. .name = "bootloader",
  50. .offset = 0,
  51. .size = SZ_128K,
  52. .mask_flags = MTD_WRITEABLE, /* force read-only */
  53. },
  54. /* bootloader params in the next sector */
  55. {
  56. .name = "params",
  57. .offset = MTDPART_OFS_APPEND,
  58. .size = SZ_128K,
  59. .mask_flags = 0,
  60. }, {
  61. .name = "kernel",
  62. .offset = MTDPART_OFS_APPEND,
  63. .size = SZ_2M,
  64. .mask_flags = 0
  65. }, {
  66. .name = "filesystem",
  67. .offset = MTDPART_OFS_APPEND,
  68. .size = MTDPART_SIZ_FULL,
  69. .mask_flags = 0
  70. }
  71. };
  72. static struct flash_platform_data osk_flash_data = {
  73. .map_name = "cfi_probe",
  74. .width = 2,
  75. .parts = osk_partitions,
  76. .nr_parts = ARRAY_SIZE(osk_partitions),
  77. };
  78. static struct resource osk_flash_resource = {
  79. /* this is on CS3, wherever it's mapped */
  80. .flags = IORESOURCE_MEM,
  81. };
  82. static struct platform_device osk5912_flash_device = {
  83. .name = "omapflash",
  84. .id = 0,
  85. .dev = {
  86. .platform_data = &osk_flash_data,
  87. },
  88. .num_resources = 1,
  89. .resource = &osk_flash_resource,
  90. };
  91. static struct resource osk5912_smc91x_resources[] = {
  92. [0] = {
  93. .start = OMAP_OSK_ETHR_START, /* Physical */
  94. .end = OMAP_OSK_ETHR_START + 0xf,
  95. .flags = IORESOURCE_MEM,
  96. },
  97. [1] = {
  98. .start = OMAP_GPIO_IRQ(0),
  99. .end = OMAP_GPIO_IRQ(0),
  100. .flags = IORESOURCE_IRQ,
  101. },
  102. };
  103. static struct platform_device osk5912_smc91x_device = {
  104. .name = "smc91x",
  105. .id = -1,
  106. .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
  107. .resource = osk5912_smc91x_resources,
  108. };
  109. static struct resource osk5912_cf_resources[] = {
  110. [0] = {
  111. .start = OMAP_GPIO_IRQ(62),
  112. .end = OMAP_GPIO_IRQ(62),
  113. .flags = IORESOURCE_IRQ,
  114. },
  115. };
  116. static struct platform_device osk5912_cf_device = {
  117. .name = "omap_cf",
  118. .id = -1,
  119. .dev = {
  120. .platform_data = (void *) 2 /* CS2 */,
  121. },
  122. .num_resources = ARRAY_SIZE(osk5912_cf_resources),
  123. .resource = osk5912_cf_resources,
  124. };
  125. #define DEFAULT_BITPERSAMPLE 16
  126. static struct omap_mcbsp_reg_cfg mcbsp_regs = {
  127. .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
  128. .spcr1 = RINTM(3) | RRST,
  129. .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
  130. RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
  131. .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
  132. .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
  133. XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
  134. .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
  135. .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
  136. .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
  137. /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
  138. .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
  139. };
  140. static struct omap_alsa_codec_config alsa_config = {
  141. .name = "OSK AIC23",
  142. .mcbsp_regs_alsa = &mcbsp_regs,
  143. .codec_configure_dev = NULL, // aic23_configure,
  144. .codec_set_samplerate = NULL, // aic23_set_samplerate,
  145. .codec_clock_setup = NULL, // aic23_clock_setup,
  146. .codec_clock_on = NULL, // aic23_clock_on,
  147. .codec_clock_off = NULL, // aic23_clock_off,
  148. .get_default_samplerate = NULL, // aic23_get_default_samplerate,
  149. };
  150. static struct platform_device osk5912_mcbsp1_device = {
  151. .name = "omap_alsa_mcbsp",
  152. .id = 1,
  153. .dev = {
  154. .platform_data = &alsa_config,
  155. },
  156. };
  157. static struct platform_device *osk5912_devices[] __initdata = {
  158. &osk5912_flash_device,
  159. &osk5912_smc91x_device,
  160. &osk5912_cf_device,
  161. &osk5912_mcbsp1_device,
  162. };
  163. static void __init osk_init_smc91x(void)
  164. {
  165. if ((omap_request_gpio(0)) < 0) {
  166. printk("Error requesting gpio 0 for smc91x irq\n");
  167. return;
  168. }
  169. /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
  170. EMIFS_CCS(1) |= 0x3;
  171. }
  172. static void __init osk_init_cf(void)
  173. {
  174. omap_cfg_reg(M7_1610_GPIO62);
  175. if ((omap_request_gpio(62)) < 0) {
  176. printk("Error requesting gpio 62 for CF irq\n");
  177. return;
  178. }
  179. /* the CF I/O IRQ is really active-low */
  180. set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING);
  181. }
  182. static void __init osk_init_irq(void)
  183. {
  184. omap1_init_common_hw();
  185. omap_init_irq();
  186. omap_gpio_init();
  187. osk_init_smc91x();
  188. osk_init_cf();
  189. }
  190. static struct omap_usb_config osk_usb_config __initdata = {
  191. /* has usb host connector (A) ... for development it can also
  192. * be used, with a NONSTANDARD gender-bending cable/dongle, as
  193. * a peripheral.
  194. */
  195. #ifdef CONFIG_USB_GADGET_OMAP
  196. .register_dev = 1,
  197. .hmc_mode = 0,
  198. #else
  199. .register_host = 1,
  200. .hmc_mode = 16,
  201. .rwc = 1,
  202. #endif
  203. .pins[0] = 2,
  204. };
  205. static struct omap_uart_config osk_uart_config __initdata = {
  206. .enabled_uarts = (1 << 0),
  207. };
  208. #ifdef CONFIG_OMAP_OSK_MISTRAL
  209. static struct omap_lcd_config osk_lcd_config __initdata = {
  210. .ctrl_name = "internal",
  211. };
  212. #endif
  213. static struct omap_board_config_kernel osk_config[] = {
  214. { OMAP_TAG_USB, &osk_usb_config },
  215. { OMAP_TAG_UART, &osk_uart_config },
  216. #ifdef CONFIG_OMAP_OSK_MISTRAL
  217. { OMAP_TAG_LCD, &osk_lcd_config },
  218. #endif
  219. };
  220. #ifdef CONFIG_OMAP_OSK_MISTRAL
  221. #include <linux/input.h>
  222. #include <linux/spi/spi.h>
  223. #include <linux/spi/ads7846.h>
  224. #include <asm/arch/keypad.h>
  225. static const int osk_keymap[] = {
  226. /* KEY(col, row, code) */
  227. KEY(0, 0, KEY_F1), /* SW4 */
  228. KEY(0, 3, KEY_UP), /* (sw2/up) */
  229. KEY(1, 1, KEY_LEFTCTRL), /* SW5 */
  230. KEY(1, 2, KEY_LEFT), /* (sw2/left) */
  231. KEY(2, 0, KEY_SPACE), /* SW3 */
  232. KEY(2, 1, KEY_ESC), /* SW6 */
  233. KEY(2, 2, KEY_DOWN), /* (sw2/down) */
  234. KEY(3, 2, KEY_ENTER), /* (sw2/select) */
  235. KEY(3, 3, KEY_RIGHT), /* (sw2/right) */
  236. 0
  237. };
  238. static struct omap_kp_platform_data osk_kp_data = {
  239. .rows = 8,
  240. .cols = 8,
  241. .keymap = (int *) osk_keymap,
  242. .keymapsize = ARRAY_SIZE(osk_keymap),
  243. .delay = 9,
  244. };
  245. static struct resource osk5912_kp_resources[] = {
  246. [0] = {
  247. .start = INT_KEYBOARD,
  248. .end = INT_KEYBOARD,
  249. .flags = IORESOURCE_IRQ,
  250. },
  251. };
  252. static struct platform_device osk5912_kp_device = {
  253. .name = "omap-keypad",
  254. .id = -1,
  255. .dev = {
  256. .platform_data = &osk_kp_data,
  257. },
  258. .num_resources = ARRAY_SIZE(osk5912_kp_resources),
  259. .resource = osk5912_kp_resources,
  260. };
  261. static struct platform_device osk5912_lcd_device = {
  262. .name = "lcd_osk",
  263. .id = -1,
  264. };
  265. static struct platform_device *mistral_devices[] __initdata = {
  266. &osk5912_kp_device,
  267. &osk5912_lcd_device,
  268. };
  269. static int mistral_get_pendown_state(void)
  270. {
  271. return !omap_get_gpio_datain(4);
  272. }
  273. static const struct ads7846_platform_data mistral_ts_info = {
  274. .model = 7846,
  275. .vref_delay_usecs = 100, /* internal, no capacitor */
  276. .x_plate_ohms = 419,
  277. .y_plate_ohms = 486,
  278. .get_pendown_state = mistral_get_pendown_state,
  279. };
  280. static struct spi_board_info __initdata mistral_boardinfo[] = { {
  281. /* MicroWire (bus 2) CS0 has an ads7846e */
  282. .modalias = "ads7846",
  283. .platform_data = &mistral_ts_info,
  284. .irq = OMAP_GPIO_IRQ(4),
  285. .max_speed_hz = 120000 /* max sample rate at 3V */
  286. * 26 /* command + data + overhead */,
  287. .bus_num = 2,
  288. .chip_select = 0,
  289. } };
  290. #ifdef CONFIG_PM
  291. static irqreturn_t
  292. osk_mistral_wake_interrupt(int irq, void *ignored)
  293. {
  294. return IRQ_HANDLED;
  295. }
  296. #endif
  297. static void __init osk_mistral_init(void)
  298. {
  299. /* NOTE: we could actually tell if there's a Mistral board
  300. * attached, e.g. by trying to read something from the ads7846.
  301. * But this arch_init() code is too early for that, since we
  302. * can't talk to the ads or even the i2c eeprom.
  303. */
  304. // omap_cfg_reg(P19_1610_GPIO6); // BUSY
  305. omap_cfg_reg(P20_1610_GPIO4); // PENIRQ
  306. set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING);
  307. spi_register_board_info(mistral_boardinfo,
  308. ARRAY_SIZE(mistral_boardinfo));
  309. /* the sideways button (SW1) is for use as a "wakeup" button */
  310. omap_cfg_reg(N15_1610_MPUIO2);
  311. if (omap_request_gpio(OMAP_MPUIO(2)) == 0) {
  312. int ret = 0;
  313. omap_set_gpio_direction(OMAP_MPUIO(2), 1);
  314. set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING);
  315. #ifdef CONFIG_PM
  316. /* share the IRQ in case someone wants to use the
  317. * button for more than wakeup from system sleep.
  318. */
  319. ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)),
  320. &osk_mistral_wake_interrupt,
  321. IRQF_SHARED, "mistral_wakeup",
  322. &osk_mistral_wake_interrupt);
  323. if (ret != 0) {
  324. omap_free_gpio(OMAP_MPUIO(2));
  325. printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
  326. ret);
  327. } else
  328. enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2)));
  329. #endif
  330. } else
  331. printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
  332. platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
  333. }
  334. #else
  335. static void __init osk_mistral_init(void) { }
  336. #endif
  337. #define EMIFS_CS3_VAL (0x88013141)
  338. static void __init osk_init(void)
  339. {
  340. /* Workaround for wrong CS3 (NOR flash) timing
  341. * There are some U-Boot versions out there which configure
  342. * wrong CS3 memory timings. This mainly leads to CRC
  343. * or similiar errors if you use NOR flash (e.g. with JFFS2)
  344. */
  345. if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
  346. EMIFS_CCS(3) = EMIFS_CS3_VAL;
  347. osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
  348. osk_flash_resource.end += SZ_32M - 1;
  349. platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
  350. omap_board_config = osk_config;
  351. omap_board_config_size = ARRAY_SIZE(osk_config);
  352. USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
  353. omap_serial_init();
  354. osk_mistral_init();
  355. }
  356. static void __init osk_map_io(void)
  357. {
  358. omap1_map_common_io();
  359. }
  360. MACHINE_START(OMAP_OSK, "TI-OSK")
  361. /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
  362. .phys_io = 0xfff00000,
  363. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  364. .boot_params = 0x10000100,
  365. .map_io = osk_map_io,
  366. .init_irq = osk_init_irq,
  367. .init_machine = osk_init,
  368. .timer = &omap_timer,
  369. MACHINE_END