board-osk.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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 <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. static struct mtd_partition osk_partitions[] = {
  45. /* bootloader (U-Boot, etc) in first sector */
  46. {
  47. .name = "bootloader",
  48. .offset = 0,
  49. .size = SZ_128K,
  50. .mask_flags = MTD_WRITEABLE, /* force read-only */
  51. },
  52. /* bootloader params in the next sector */
  53. {
  54. .name = "params",
  55. .offset = MTDPART_OFS_APPEND,
  56. .size = SZ_128K,
  57. .mask_flags = 0,
  58. }, {
  59. .name = "kernel",
  60. .offset = MTDPART_OFS_APPEND,
  61. .size = SZ_2M,
  62. .mask_flags = 0
  63. }, {
  64. .name = "filesystem",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = MTDPART_SIZ_FULL,
  67. .mask_flags = 0
  68. }
  69. };
  70. static struct flash_platform_data osk_flash_data = {
  71. .map_name = "cfi_probe",
  72. .width = 2,
  73. .parts = osk_partitions,
  74. .nr_parts = ARRAY_SIZE(osk_partitions),
  75. };
  76. static struct resource osk_flash_resource = {
  77. /* this is on CS3, wherever it's mapped */
  78. .flags = IORESOURCE_MEM,
  79. };
  80. static struct platform_device osk5912_flash_device = {
  81. .name = "omapflash",
  82. .id = 0,
  83. .dev = {
  84. .platform_data = &osk_flash_data,
  85. },
  86. .num_resources = 1,
  87. .resource = &osk_flash_resource,
  88. };
  89. static struct resource osk5912_smc91x_resources[] = {
  90. [0] = {
  91. .start = OMAP_OSK_ETHR_START, /* Physical */
  92. .end = OMAP_OSK_ETHR_START + 0xf,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .start = OMAP_GPIO_IRQ(0),
  97. .end = OMAP_GPIO_IRQ(0),
  98. .flags = IORESOURCE_IRQ,
  99. },
  100. };
  101. static struct platform_device osk5912_smc91x_device = {
  102. .name = "smc91x",
  103. .id = -1,
  104. .num_resources = ARRAY_SIZE(osk5912_smc91x_resources),
  105. .resource = osk5912_smc91x_resources,
  106. };
  107. static struct resource osk5912_cf_resources[] = {
  108. [0] = {
  109. .start = OMAP_GPIO_IRQ(62),
  110. .end = OMAP_GPIO_IRQ(62),
  111. .flags = IORESOURCE_IRQ,
  112. },
  113. };
  114. static struct platform_device osk5912_cf_device = {
  115. .name = "omap_cf",
  116. .id = -1,
  117. .dev = {
  118. .platform_data = (void *) 2 /* CS2 */,
  119. },
  120. .num_resources = ARRAY_SIZE(osk5912_cf_resources),
  121. .resource = osk5912_cf_resources,
  122. };
  123. static struct platform_device osk5912_mcbsp1_device = {
  124. .name = "omap_mcbsp",
  125. .id = 1,
  126. };
  127. static struct platform_device *osk5912_devices[] __initdata = {
  128. &osk5912_flash_device,
  129. &osk5912_smc91x_device,
  130. &osk5912_cf_device,
  131. &osk5912_mcbsp1_device,
  132. };
  133. static void __init osk_init_smc91x(void)
  134. {
  135. if ((omap_request_gpio(0)) < 0) {
  136. printk("Error requesting gpio 0 for smc91x irq\n");
  137. return;
  138. }
  139. /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
  140. EMIFS_CCS(1) |= 0x3;
  141. }
  142. static void __init osk_init_cf(void)
  143. {
  144. omap_cfg_reg(M7_1610_GPIO62);
  145. if ((omap_request_gpio(62)) < 0) {
  146. printk("Error requesting gpio 62 for CF irq\n");
  147. return;
  148. }
  149. /* the CF I/O IRQ is really active-low */
  150. set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING);
  151. }
  152. static void __init osk_init_irq(void)
  153. {
  154. omap_init_irq();
  155. omap_gpio_init();
  156. osk_init_smc91x();
  157. osk_init_cf();
  158. }
  159. static struct omap_usb_config osk_usb_config __initdata = {
  160. /* has usb host connector (A) ... for development it can also
  161. * be used, with a NONSTANDARD gender-bending cable/dongle, as
  162. * a peripheral.
  163. */
  164. #ifdef CONFIG_USB_GADGET_OMAP
  165. .register_dev = 1,
  166. .hmc_mode = 0,
  167. #else
  168. .register_host = 1,
  169. .hmc_mode = 16,
  170. .rwc = 1,
  171. #endif
  172. .pins[0] = 2,
  173. };
  174. static struct omap_uart_config osk_uart_config __initdata = {
  175. .enabled_uarts = (1 << 0),
  176. };
  177. static struct omap_lcd_config osk_lcd_config __initdata = {
  178. .panel_name = "osk",
  179. .ctrl_name = "internal",
  180. };
  181. static struct omap_board_config_kernel osk_config[] = {
  182. { OMAP_TAG_USB, &osk_usb_config },
  183. { OMAP_TAG_UART, &osk_uart_config },
  184. { OMAP_TAG_LCD, &osk_lcd_config },
  185. };
  186. #ifdef CONFIG_OMAP_OSK_MISTRAL
  187. #ifdef CONFIG_PM
  188. static irqreturn_t
  189. osk_mistral_wake_interrupt(int irq, void *ignored, struct pt_regs *regs)
  190. {
  191. return IRQ_HANDLED;
  192. }
  193. #endif
  194. static void __init osk_mistral_init(void)
  195. {
  196. /* FIXME here's where to feed in framebuffer, touchpad, and
  197. * keyboard setup ... not in the drivers for those devices!
  198. *
  199. * NOTE: we could actually tell if there's a Mistral board
  200. * attached, e.g. by trying to read something from the ads7846.
  201. * But this is too early for that...
  202. */
  203. /* the sideways button (SW1) is for use as a "wakeup" button */
  204. omap_cfg_reg(N15_1610_MPUIO2);
  205. if (omap_request_gpio(OMAP_MPUIO(2)) == 0) {
  206. int ret = 0;
  207. omap_set_gpio_direction(OMAP_MPUIO(2), 1);
  208. set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING);
  209. #ifdef CONFIG_PM
  210. /* share the IRQ in case someone wants to use the
  211. * button for more than wakeup from system sleep.
  212. */
  213. ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)),
  214. &osk_mistral_wake_interrupt,
  215. SA_SHIRQ, "mistral_wakeup",
  216. &osk_mistral_wake_interrupt);
  217. if (ret != 0) {
  218. omap_free_gpio(OMAP_MPUIO(2));
  219. printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
  220. ret);
  221. } else
  222. enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2)));
  223. #endif
  224. } else
  225. printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
  226. }
  227. #else
  228. static void __init osk_mistral_init(void) { }
  229. #endif
  230. static void __init osk_init(void)
  231. {
  232. osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
  233. osk_flash_resource.end += SZ_32M - 1;
  234. platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
  235. omap_board_config = osk_config;
  236. omap_board_config_size = ARRAY_SIZE(osk_config);
  237. USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
  238. omap_serial_init();
  239. osk_mistral_init();
  240. }
  241. static void __init osk_map_io(void)
  242. {
  243. omap_map_common_io();
  244. }
  245. MACHINE_START(OMAP_OSK, "TI-OSK")
  246. /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
  247. .phys_io = 0xfff00000,
  248. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  249. .boot_params = 0x10000100,
  250. .map_io = osk_map_io,
  251. .init_irq = osk_init_irq,
  252. .init_machine = osk_init,
  253. .timer = &omap_timer,
  254. MACHINE_END