mach-h1940.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /* linux/arch/arm/mach-s3c2410/mach-h1940.c
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.handhelds.org/projects/h1940.html
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/timer.h>
  18. #include <linux/init.h>
  19. #include <linux/sysdev.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/io.h>
  23. #include <linux/gpio.h>
  24. #include <linux/mmc/host.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <mach/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/mach-types.h>
  31. #include <plat/regs-serial.h>
  32. #include <mach/regs-lcd.h>
  33. #include <mach/regs-clock.h>
  34. #include <mach/regs-gpio.h>
  35. #include <mach/gpio-fns.h>
  36. #include <mach/gpio-nrs.h>
  37. #include <mach/h1940.h>
  38. #include <mach/h1940-latch.h>
  39. #include <mach/fb.h>
  40. #include <plat/udc.h>
  41. #include <plat/iic.h>
  42. #include <plat/clock.h>
  43. #include <plat/devs.h>
  44. #include <plat/cpu.h>
  45. #include <plat/pll.h>
  46. #include <plat/pm.h>
  47. #include <plat/mci.h>
  48. static struct map_desc h1940_iodesc[] __initdata = {
  49. [0] = {
  50. .virtual = (unsigned long)H1940_LATCH,
  51. .pfn = __phys_to_pfn(H1940_PA_LATCH),
  52. .length = SZ_16K,
  53. .type = MT_DEVICE
  54. },
  55. };
  56. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  57. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  58. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  59. static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
  60. [0] = {
  61. .hwport = 0,
  62. .flags = 0,
  63. .ucon = 0x3c5,
  64. .ulcon = 0x03,
  65. .ufcon = 0x51,
  66. },
  67. [1] = {
  68. .hwport = 1,
  69. .flags = 0,
  70. .ucon = 0x245,
  71. .ulcon = 0x03,
  72. .ufcon = 0x00,
  73. },
  74. /* IR port */
  75. [2] = {
  76. .hwport = 2,
  77. .flags = 0,
  78. .uart_flags = UPF_CONS_FLOW,
  79. .ucon = 0x3c5,
  80. .ulcon = 0x43,
  81. .ufcon = 0x51,
  82. }
  83. };
  84. /* Board control latch control */
  85. static unsigned int latch_state = H1940_LATCH_DEFAULT;
  86. void h1940_latch_control(unsigned int clear, unsigned int set)
  87. {
  88. unsigned long flags;
  89. local_irq_save(flags);
  90. latch_state &= ~clear;
  91. latch_state |= set;
  92. __raw_writel(latch_state, H1940_LATCH);
  93. local_irq_restore(flags);
  94. }
  95. EXPORT_SYMBOL_GPL(h1940_latch_control);
  96. static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd)
  97. {
  98. printk(KERN_DEBUG "udc: pullup(%d)\n",cmd);
  99. switch (cmd)
  100. {
  101. case S3C2410_UDC_P_ENABLE :
  102. h1940_latch_control(0, H1940_LATCH_USB_DP);
  103. break;
  104. case S3C2410_UDC_P_DISABLE :
  105. h1940_latch_control(H1940_LATCH_USB_DP, 0);
  106. break;
  107. case S3C2410_UDC_P_RESET :
  108. break;
  109. default:
  110. break;
  111. }
  112. }
  113. static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
  114. .udc_command = h1940_udc_pullup,
  115. .vbus_pin = S3C2410_GPG(5),
  116. .vbus_pin_inverted = 1,
  117. };
  118. /**
  119. * Set lcd on or off
  120. **/
  121. static struct s3c2410fb_display h1940_lcd __initdata = {
  122. .lcdcon5= S3C2410_LCDCON5_FRM565 | \
  123. S3C2410_LCDCON5_INVVLINE | \
  124. S3C2410_LCDCON5_HWSWP,
  125. .type = S3C2410_LCDCON1_TFT,
  126. .width = 240,
  127. .height = 320,
  128. .pixclock = 260000,
  129. .xres = 240,
  130. .yres = 320,
  131. .bpp = 16,
  132. .left_margin = 20,
  133. .right_margin = 8,
  134. .hsync_len = 4,
  135. .upper_margin = 8,
  136. .lower_margin = 7,
  137. .vsync_len = 1,
  138. };
  139. static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
  140. .displays = &h1940_lcd,
  141. .num_displays = 1,
  142. .default_display = 0,
  143. .lpcsel= 0x02,
  144. .gpccon= 0xaa940659,
  145. .gpccon_mask= 0xffffffff,
  146. .gpcup= 0x0000ffff,
  147. .gpcup_mask= 0xffffffff,
  148. .gpdcon= 0xaa84aaa0,
  149. .gpdcon_mask= 0xffffffff,
  150. .gpdup= 0x0000faff,
  151. .gpdup_mask= 0xffffffff,
  152. };
  153. static struct platform_device h1940_device_leds = {
  154. .name = "h1940-leds",
  155. .id = -1,
  156. };
  157. static struct platform_device h1940_device_bluetooth = {
  158. .name = "h1940-bt",
  159. .id = -1,
  160. };
  161. static struct s3c24xx_mci_pdata h1940_mmc_cfg = {
  162. .gpio_detect = S3C2410_GPF(5),
  163. .gpio_wprotect = S3C2410_GPH(8),
  164. .set_power = NULL,
  165. .ocr_avail = MMC_VDD_32_33,
  166. };
  167. static struct platform_device *h1940_devices[] __initdata = {
  168. &s3c_device_usb,
  169. &s3c_device_lcd,
  170. &s3c_device_wdt,
  171. &s3c_device_i2c0,
  172. &s3c_device_iis,
  173. &s3c_device_usbgadget,
  174. &h1940_device_leds,
  175. &h1940_device_bluetooth,
  176. &s3c_device_sdi,
  177. &s3c_device_rtc,
  178. };
  179. static void __init h1940_map_io(void)
  180. {
  181. s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
  182. s3c24xx_init_clocks(0);
  183. s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
  184. /* setup PM */
  185. #ifdef CONFIG_PM_H1940
  186. memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
  187. #endif
  188. s3c_pm_init();
  189. }
  190. static void __init h1940_init_irq(void)
  191. {
  192. s3c24xx_init_irq();
  193. }
  194. static void __init h1940_init(void)
  195. {
  196. u32 tmp;
  197. s3c24xx_fb_set_platdata(&h1940_fb_info);
  198. s3c24xx_udc_set_platdata(&h1940_udc_cfg);
  199. s3c_i2c0_set_platdata(NULL);
  200. s3c_device_sdi.dev.platform_data = &h1940_mmc_cfg;
  201. /* Turn off suspend on both USB ports, and switch the
  202. * selectable USB port to USB device mode. */
  203. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  204. S3C2410_MISCCR_USBSUSPND0 |
  205. S3C2410_MISCCR_USBSUSPND1, 0x0);
  206. tmp = (0x78 << S3C24XX_PLLCON_MDIVSHIFT)
  207. | (0x02 << S3C24XX_PLLCON_PDIVSHIFT)
  208. | (0x03 << S3C24XX_PLLCON_SDIVSHIFT);
  209. writel(tmp, S3C2410_UPLLCON);
  210. platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
  211. }
  212. MACHINE_START(H1940, "IPAQ-H1940")
  213. /* Maintainer: Ben Dooks <ben@fluff.org> */
  214. .phys_io = S3C2410_PA_UART,
  215. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  216. .boot_params = S3C2410_SDRAM_PA + 0x100,
  217. .map_io = h1940_map_io,
  218. .init_irq = h1940_init_irq,
  219. .init_machine = h1940_init,
  220. .timer = &s3c24xx_timer,
  221. MACHINE_END