blob: 329f6ffb8c655529f2f9b2d8cf78552e8cc8f6e3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012*/
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/list.h>
18#include <linux/timer.h>
19#include <linux/init.h>
Ben Dooks333a42e2007-05-20 11:55:53 +010020#include <linux/sysdev.h>
Ben Dooksb6d1f542006-12-17 23:22:26 +010021#include <linux/serial_core.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010022#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010023#include <linux/io.h>
arnaud.patard@rtp-net.org3909b9f2009-11-17 14:54:56 +010024#include <linux/gpio.h>
25
26#include <linux/mmc/host.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30#include <asm/mach/irq.h>
31
Russell Kinga09e64f2008-08-05 16:14:15 +010032#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/irq.h>
34#include <asm/mach-types.h>
35
Ben Dooksa2b7ba92008-10-07 22:26:09 +010036#include <plat/regs-serial.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/regs-lcd.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010038#include <mach/regs-clock.h>
Arnaud Patardf92273c2005-09-09 13:10:10 -070039
arnaud.patard@rtp-net.org3909b9f2009-11-17 14:54:56 +010040#include <mach/regs-gpio.h>
41#include <mach/gpio-fns.h>
42#include <mach/gpio-nrs.h>
43
Russell Kinga09e64f2008-08-05 16:14:15 +010044#include <mach/h1940.h>
45#include <mach/h1940-latch.h>
46#include <mach/fb.h>
Ben Dooks57bd4b92008-10-30 10:14:37 +000047#include <plat/udc.h>
Ben Dooks3e1b7762008-10-31 16:14:40 +000048#include <plat/iic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Ben Dooksd5120ae2008-10-07 23:09:51 +010050#include <plat/clock.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010051#include <plat/devs.h>
52#include <plat/cpu.h>
Ben Dookse24b8642008-10-21 14:06:34 +010053#include <plat/pll.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010054#include <plat/pm.h>
arnaud.patard@rtp-net.org3909b9f2009-11-17 14:54:56 +010055#include <plat/mci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57static struct map_desc h1940_iodesc[] __initdata = {
Ben Dookse1981682006-02-10 22:40:51 +000058 [0] = {
59 .virtual = (unsigned long)H1940_LATCH,
60 .pfn = __phys_to_pfn(H1940_PA_LATCH),
61 .length = SZ_16K,
62 .type = MT_DEVICE
63 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070064};
65
66#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
67#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
68#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
69
Ben Dooks66a9b492006-06-18 23:04:05 +010070static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 [0] = {
72 .hwport = 0,
73 .flags = 0,
74 .ucon = 0x3c5,
75 .ulcon = 0x03,
76 .ufcon = 0x51,
77 },
78 [1] = {
79 .hwport = 1,
80 .flags = 0,
81 .ucon = 0x245,
82 .ulcon = 0x03,
83 .ufcon = 0x00,
84 },
85 /* IR port */
86 [2] = {
87 .hwport = 2,
88 .flags = 0,
89 .uart_flags = UPF_CONS_FLOW,
90 .ucon = 0x3c5,
91 .ulcon = 0x43,
92 .ufcon = 0x51,
93 }
94};
95
Ben Dookse1981682006-02-10 22:40:51 +000096/* Board control latch control */
97
98static unsigned int latch_state = H1940_LATCH_DEFAULT;
99
100void h1940_latch_control(unsigned int clear, unsigned int set)
101{
102 unsigned long flags;
103
104 local_irq_save(flags);
105
106 latch_state &= ~clear;
107 latch_state |= set;
108
109 __raw_writel(latch_state, H1940_LATCH);
110
111 local_irq_restore(flags);
112}
113
114EXPORT_SYMBOL_GPL(h1940_latch_control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Arnaud Patard71a9c422007-02-13 00:21:26 +0100116static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd)
117{
118 printk(KERN_DEBUG "udc: pullup(%d)\n",cmd);
119
120 switch (cmd)
121 {
122 case S3C2410_UDC_P_ENABLE :
123 h1940_latch_control(0, H1940_LATCH_USB_DP);
124 break;
125 case S3C2410_UDC_P_DISABLE :
126 h1940_latch_control(H1940_LATCH_USB_DP, 0);
127 break;
128 case S3C2410_UDC_P_RESET :
129 break;
130 default:
131 break;
132 }
133}
134
135static struct s3c2410_udc_mach_info h1940_udc_cfg __initdata = {
136 .udc_command = h1940_udc_pullup,
Ben Dooks070276d2009-05-17 22:32:23 +0100137 .vbus_pin = S3C2410_GPG(5),
Arnaud Patard71a9c422007-02-13 00:21:26 +0100138 .vbus_pin_inverted = 1,
139};
140
141
Arnaud Patardf92273c2005-09-09 13:10:10 -0700142/**
143 * Set lcd on or off
144 **/
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700145static struct s3c2410fb_display h1940_lcd __initdata = {
Krzysztof Heltf28ef572007-10-16 01:28:58 -0700146 .lcdcon5= S3C2410_LCDCON5_FRM565 | \
147 S3C2410_LCDCON5_INVVLINE | \
148 S3C2410_LCDCON5_HWSWP,
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700149
Krzysztof Helt1f411532007-10-16 01:28:57 -0700150 .type = S3C2410_LCDCON1_TFT,
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700151 .width = 240,
152 .height = 320,
Krzysztof Helt69816692007-10-16 01:29:06 -0700153 .pixclock = 260000,
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700154 .xres = 240,
155 .yres = 320,
156 .bpp = 16,
Krzysztof Helt1f411532007-10-16 01:28:57 -0700157 .left_margin = 20,
158 .right_margin = 8,
Krzysztof Helt93d11f52007-10-16 01:29:00 -0700159 .hsync_len = 4,
Krzysztof Helt5f20f692007-10-16 01:28:59 -0700160 .upper_margin = 8,
161 .lower_margin = 7,
Krzysztof Helt93d11f52007-10-16 01:29:00 -0700162 .vsync_len = 1,
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700163};
164
165static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700166 .displays = &h1940_lcd,
167 .num_displays = 1,
168 .default_display = 0,
169
Arnaud Patardf92273c2005-09-09 13:10:10 -0700170 .lpcsel= 0x02,
171 .gpccon= 0xaa940659,
172 .gpccon_mask= 0xffffffff,
173 .gpcup= 0x0000ffff,
174 .gpcup_mask= 0xffffffff,
175 .gpdcon= 0xaa84aaa0,
176 .gpdcon_mask= 0xffffffff,
177 .gpdup= 0x0000faff,
178 .gpdup_mask= 0xffffffff,
Arnaud Patardf92273c2005-09-09 13:10:10 -0700179};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
Ben Dooksff34aaa2009-09-28 12:45:47 +0900181static struct platform_device h1940_device_leds = {
Arnaud Patardd2a76022007-02-13 00:50:34 +0100182 .name = "h1940-leds",
183 .id = -1,
184};
185
Ben Dooksff34aaa2009-09-28 12:45:47 +0900186static struct platform_device h1940_device_bluetooth = {
Arnaud Patard7fdc7842007-05-09 21:41:03 +0100187 .name = "h1940-bt",
188 .id = -1,
189};
190
arnaud.patard@rtp-net.org3909b9f2009-11-17 14:54:56 +0100191static struct s3c24xx_mci_pdata h1940_mmc_cfg = {
192 .gpio_detect = S3C2410_GPF(5),
193 .gpio_wprotect = S3C2410_GPH(8),
194 .set_power = NULL,
195 .ocr_avail = MMC_VDD_32_33,
196};
197
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198static struct platform_device *h1940_devices[] __initdata = {
199 &s3c_device_usb,
200 &s3c_device_lcd,
201 &s3c_device_wdt,
Ben Dooks3e1b7762008-10-31 16:14:40 +0000202 &s3c_device_i2c0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 &s3c_device_iis,
Arnaud Patard71a9c422007-02-13 00:21:26 +0100204 &s3c_device_usbgadget,
Ben Dooksff34aaa2009-09-28 12:45:47 +0900205 &h1940_device_leds,
206 &h1940_device_bluetooth,
arnaud.patard@rtp-net.org3909b9f2009-11-17 14:54:56 +0100207 &s3c_device_sdi,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208};
209
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100210static void __init h1940_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211{
212 s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
213 s3c24xx_init_clocks(0);
214 s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
Ben Dooks90733412006-12-06 01:50:24 +0100215
216 /* setup PM */
217
Krzysztof Heltb1dfe1f2007-03-19 15:10:20 +0100218#ifdef CONFIG_PM_H1940
Ben Dooks90733412006-12-06 01:50:24 +0100219 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
Krzysztof Heltb1dfe1f2007-03-19 15:10:20 +0100220#endif
Ben Dooks4e59c252008-12-12 00:24:18 +0000221 s3c_pm_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222}
223
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100224static void __init h1940_init_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225{
226 s3c24xx_init_irq();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227}
228
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100229static void __init h1940_init(void)
Arnaud Patardf92273c2005-09-09 13:10:10 -0700230{
Arnaud Patard71a9c422007-02-13 00:21:26 +0100231 u32 tmp;
232
Krzysztof Helt09fe75f2007-10-16 01:28:56 -0700233 s3c24xx_fb_set_platdata(&h1940_fb_info);
Arnaud Patard71a9c422007-02-13 00:21:26 +0100234 s3c24xx_udc_set_platdata(&h1940_udc_cfg);
Ben Dooks3e1b7762008-10-31 16:14:40 +0000235 s3c_i2c0_set_platdata(NULL);
Arnaud Patard71a9c422007-02-13 00:21:26 +0100236
arnaud.patard@rtp-net.org3909b9f2009-11-17 14:54:56 +0100237 s3c_device_sdi.dev.platform_data = &h1940_mmc_cfg;
238
Arnaud Patard71a9c422007-02-13 00:21:26 +0100239 /* Turn off suspend on both USB ports, and switch the
240 * selectable USB port to USB device mode. */
241
242 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
243 S3C2410_MISCCR_USBSUSPND0 |
244 S3C2410_MISCCR_USBSUSPND1, 0x0);
245
Ben Dookse24b8642008-10-21 14:06:34 +0100246 tmp = (0x78 << S3C24XX_PLLCON_MDIVSHIFT)
247 | (0x02 << S3C24XX_PLLCON_PDIVSHIFT)
248 | (0x03 << S3C24XX_PLLCON_SDIVSHIFT);
Arnaud Patard71a9c422007-02-13 00:21:26 +0100249 writel(tmp, S3C2410_UPLLCON);
Ben Dooks57e51712007-04-20 11:19:16 +0100250
251 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
Arnaud Patardf92273c2005-09-09 13:10:10 -0700252}
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254MACHINE_START(H1940, "IPAQ-H1940")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100255 /* Maintainer: Ben Dooks <ben@fluff.org> */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100256 .phys_io = S3C2410_PA_UART,
257 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
258 .boot_params = S3C2410_SDRAM_PA + 0x100,
259 .map_io = h1940_map_io,
260 .init_irq = h1940_init_irq,
Arnaud Patard71a9c422007-02-13 00:21:26 +0100261 .init_machine = h1940_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 .timer = &s3c24xx_timer,
263MACHINE_END