mach-h1940.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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/serial_core.h>
  20. #include <linux/platform_device.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/mach/irq.h>
  24. #include <asm/hardware.h>
  25. #include <asm/io.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/arch/regs-serial.h>
  29. #include <asm/arch/regs-lcd.h>
  30. #include <asm/arch/regs-gpio.h>
  31. #include <asm/arch/regs-clock.h>
  32. #include <asm/arch/h1940.h>
  33. #include <asm/arch/h1940-latch.h>
  34. #include <asm/arch/fb.h>
  35. #include <asm/arch/udc.h>
  36. #include <asm/plat-s3c24xx/clock.h>
  37. #include <asm/plat-s3c24xx/devs.h>
  38. #include <asm/plat-s3c24xx/cpu.h>
  39. #include <asm/plat-s3c24xx/pm.h>
  40. static struct map_desc h1940_iodesc[] __initdata = {
  41. [0] = {
  42. .virtual = (unsigned long)H1940_LATCH,
  43. .pfn = __phys_to_pfn(H1940_PA_LATCH),
  44. .length = SZ_16K,
  45. .type = MT_DEVICE
  46. },
  47. };
  48. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  49. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  50. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  51. static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
  52. [0] = {
  53. .hwport = 0,
  54. .flags = 0,
  55. .ucon = 0x3c5,
  56. .ulcon = 0x03,
  57. .ufcon = 0x51,
  58. },
  59. [1] = {
  60. .hwport = 1,
  61. .flags = 0,
  62. .ucon = 0x245,
  63. .ulcon = 0x03,
  64. .ufcon = 0x00,
  65. },
  66. /* IR port */
  67. [2] = {
  68. .hwport = 2,
  69. .flags = 0,
  70. .uart_flags = UPF_CONS_FLOW,
  71. .ucon = 0x3c5,
  72. .ulcon = 0x43,
  73. .ufcon = 0x51,
  74. }
  75. };
  76. /* Board control latch control */
  77. static unsigned int latch_state = H1940_LATCH_DEFAULT;
  78. void h1940_latch_control(unsigned int clear, unsigned int set)
  79. {
  80. unsigned long flags;
  81. local_irq_save(flags);
  82. latch_state &= ~clear;
  83. latch_state |= set;
  84. __raw_writel(latch_state, H1940_LATCH);
  85. local_irq_restore(flags);
  86. }
  87. EXPORT_SYMBOL_GPL(h1940_latch_control);
  88. static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd)
  89. {
  90. printk(KERN_DEBUG "udc: pullup(%d)\n",cmd);
  91. switch (cmd)
  92. {
  93. case S3C2410_UDC_P_ENABLE :
  94. h1940_latch_control(0, H1940_LATCH_USB_DP);
  95. break;
  96. case S3C2410_UDC_P_DISABLE :
  97. h1940_latch_control(H1940_LATCH_USB_DP, 0);
  98. break;
  99. case S3C2410_UDC_P_RESET :
  100. break;
  101. default:
  102. break;
  103. }
  104. }
  105. static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
  106. .udc_command = h1940_udc_pullup,
  107. .vbus_pin = S3C2410_GPG5,
  108. .vbus_pin_inverted = 1,
  109. };
  110. /**
  111. * Set lcd on or off
  112. **/
  113. static struct s3c2410fb_mach_info h1940_lcdcfg __initdata = {
  114. .fixed_syncs= 1,
  115. .regs={
  116. .lcdcon1= S3C2410_LCDCON1_TFT16BPP | \
  117. S3C2410_LCDCON1_TFT | \
  118. S3C2410_LCDCON1_CLKVAL(0x0C),
  119. .lcdcon2= S3C2410_LCDCON2_VBPD(7) | \
  120. S3C2410_LCDCON2_LINEVAL(319) | \
  121. S3C2410_LCDCON2_VFPD(6) | \
  122. S3C2410_LCDCON2_VSPW(0),
  123. .lcdcon3= S3C2410_LCDCON3_HBPD(19) | \
  124. S3C2410_LCDCON3_HOZVAL(239) | \
  125. S3C2410_LCDCON3_HFPD(7),
  126. .lcdcon4= S3C2410_LCDCON4_MVAL(0) | \
  127. S3C2410_LCDCON4_HSPW(3),
  128. .lcdcon5= S3C2410_LCDCON5_FRM565 | \
  129. S3C2410_LCDCON5_INVVLINE | \
  130. S3C2410_LCDCON5_HWSWP,
  131. },
  132. .lpcsel= 0x02,
  133. .gpccon= 0xaa940659,
  134. .gpccon_mask= 0xffffffff,
  135. .gpcup= 0x0000ffff,
  136. .gpcup_mask= 0xffffffff,
  137. .gpdcon= 0xaa84aaa0,
  138. .gpdcon_mask= 0xffffffff,
  139. .gpdup= 0x0000faff,
  140. .gpdup_mask= 0xffffffff,
  141. .width= 240,
  142. .height= 320,
  143. .xres= {240,240,240},
  144. .yres= {320,320,320},
  145. .bpp= {16,16,16},
  146. };
  147. static struct platform_device s3c_device_leds = {
  148. .name = "h1940-leds",
  149. .id = -1,
  150. };
  151. static struct platform_device *h1940_devices[] __initdata = {
  152. &s3c_device_usb,
  153. &s3c_device_lcd,
  154. &s3c_device_wdt,
  155. &s3c_device_i2c,
  156. &s3c_device_iis,
  157. &s3c_device_usbgadget,
  158. &s3c_device_leds,
  159. };
  160. static struct s3c24xx_board h1940_board __initdata = {
  161. .devices = h1940_devices,
  162. .devices_count = ARRAY_SIZE(h1940_devices)
  163. };
  164. static void __init h1940_map_io(void)
  165. {
  166. s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
  167. s3c24xx_init_clocks(0);
  168. s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
  169. s3c24xx_set_board(&h1940_board);
  170. /* setup PM */
  171. #ifdef CONFIG_PM_H1940
  172. memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
  173. #endif
  174. s3c2410_pm_init();
  175. }
  176. static void __init h1940_init_irq(void)
  177. {
  178. s3c24xx_init_irq();
  179. }
  180. static void __init h1940_init(void)
  181. {
  182. u32 tmp;
  183. s3c24xx_fb_set_platdata(&h1940_lcdcfg);
  184. s3c24xx_udc_set_platdata(&h1940_udc_cfg);
  185. /* Turn off suspend on both USB ports, and switch the
  186. * selectable USB port to USB device mode. */
  187. s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
  188. S3C2410_MISCCR_USBSUSPND0 |
  189. S3C2410_MISCCR_USBSUSPND1, 0x0);
  190. tmp = (
  191. 0x78 << S3C2410_PLLCON_MDIVSHIFT)
  192. | (0x02 << S3C2410_PLLCON_PDIVSHIFT)
  193. | (0x03 << S3C2410_PLLCON_SDIVSHIFT);
  194. writel(tmp, S3C2410_UPLLCON);
  195. }
  196. MACHINE_START(H1940, "IPAQ-H1940")
  197. /* Maintainer: Ben Dooks <ben@fluff.org> */
  198. .phys_io = S3C2410_PA_UART,
  199. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  200. .boot_params = S3C2410_SDRAM_PA + 0x100,
  201. .map_io = h1940_map_io,
  202. .init_irq = h1940_init_irq,
  203. .init_machine = h1940_init,
  204. .timer = &s3c24xx_timer,
  205. MACHINE_END