board-osk.c 11 KB

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