board-osk.c 9.8 KB

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