Merge branch 'origin'
[pandora-kernel.git] / arch / arm / mach-s3c2410 / mach-h1940.c
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  * Modifications:
13  *     16-May-2003 BJD  Created initial version
14  *     16-Aug-2003 BJD  Fixed header files and copyright, added URL
15  *     05-Sep-2003 BJD  Moved to v2.6 kernel
16  *     06-Jan-2003 BJD  Updates for <arch/map.h>
17  *     18-Jan-2003 BJD  Added serial port configuration
18  *     17-Feb-2003 BJD  Copied to mach-ipaq.c
19  *     21-Aug-2004 BJD  Added struct s3c2410_board
20  *     04-Sep-2004 BJD  Changed uart init, renamed ipaq_ -> h1940_
21  *     18-Oct-2004 BJD  Updated new board structure name
22  *     04-Nov-2004 BJD  Change for new serial clock
23  *     04-Jan-2005 BJD  Updated uart init call
24  *     10-Jan-2005 BJD  Removed include of s3c2410.h
25  *     14-Jan-2005 BJD  Added clock init
26  *     10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
27  *     20-Sep-2005 BJD  Added static to non-exported items
28  *     26-Oct-2005 BJD  Changed name of fb init call
29 */
30
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/interrupt.h>
34 #include <linux/list.h>
35 #include <linux/timer.h>
36 #include <linux/init.h>
37 #include <linux/platform_device.h>
38
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/irq.h>
42
43 #include <asm/hardware.h>
44 #include <asm/hardware/iomd.h>
45 #include <asm/io.h>
46 #include <asm/irq.h>
47 #include <asm/mach-types.h>
48
49
50 #include <asm/arch/regs-serial.h>
51 #include <asm/arch/regs-lcd.h>
52
53 #include <asm/arch/h1940-latch.h>
54 #include <asm/arch/fb.h>
55
56 #include <linux/serial_core.h>
57
58 #include "clock.h"
59 #include "devs.h"
60 #include "cpu.h"
61
62 static struct map_desc h1940_iodesc[] __initdata = {
63         [0] = {
64                 .virtual        = (unsigned long)H1940_LATCH,
65                 .pfn            = __phys_to_pfn(H1940_PA_LATCH),
66                 .length         = SZ_16K,
67                 .type           = MT_DEVICE
68         },
69 };
70
71 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
72 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
73 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
74
75 static struct s3c2410_uartcfg h1940_uartcfgs[] = {
76         [0] = {
77                 .hwport      = 0,
78                 .flags       = 0,
79                 .ucon        = 0x3c5,
80                 .ulcon       = 0x03,
81                 .ufcon       = 0x51,
82         },
83         [1] = {
84                 .hwport      = 1,
85                 .flags       = 0,
86                 .ucon        = 0x245,
87                 .ulcon       = 0x03,
88                 .ufcon       = 0x00,
89         },
90         /* IR port */
91         [2] = {
92                 .hwport      = 2,
93                 .flags       = 0,
94                 .uart_flags  = UPF_CONS_FLOW,
95                 .ucon        = 0x3c5,
96                 .ulcon       = 0x43,
97                 .ufcon       = 0x51,
98         }
99 };
100
101 /* Board control latch control */
102
103 static unsigned int latch_state = H1940_LATCH_DEFAULT;
104
105 void h1940_latch_control(unsigned int clear, unsigned int set)
106 {
107         unsigned long flags;
108
109         local_irq_save(flags);
110
111         latch_state &= ~clear;
112         latch_state |= set;
113
114         __raw_writel(latch_state, H1940_LATCH);
115
116         local_irq_restore(flags);
117 }
118
119 EXPORT_SYMBOL_GPL(h1940_latch_control);
120
121
122 /**
123  * Set lcd on or off
124  **/
125 static struct s3c2410fb_mach_info h1940_lcdcfg __initdata = {
126         .fixed_syncs=           1,
127         .regs={
128                 .lcdcon1=       S3C2410_LCDCON1_TFT16BPP | \
129                                 S3C2410_LCDCON1_TFT | \
130                                 S3C2410_LCDCON1_CLKVAL(0x0C),
131
132                 .lcdcon2=       S3C2410_LCDCON2_VBPD(7) | \
133                                 S3C2410_LCDCON2_LINEVAL(319) | \
134                                 S3C2410_LCDCON2_VFPD(6) | \
135                                 S3C2410_LCDCON2_VSPW(0),
136
137                 .lcdcon3=       S3C2410_LCDCON3_HBPD(19) | \
138                                 S3C2410_LCDCON3_HOZVAL(239) | \
139                                 S3C2410_LCDCON3_HFPD(7),
140
141                 .lcdcon4=       S3C2410_LCDCON4_MVAL(0) | \
142                                 S3C2410_LCDCON4_HSPW(3),
143
144                 .lcdcon5=       S3C2410_LCDCON5_FRM565 | \
145                                 S3C2410_LCDCON5_INVVLINE | \
146                                 S3C2410_LCDCON5_HWSWP,
147         },
148         .lpcsel=        0x02,
149         .gpccon=        0xaa940659,
150         .gpccon_mask=   0xffffffff,
151         .gpcup=         0x0000ffff,
152         .gpcup_mask=    0xffffffff,
153         .gpdcon=        0xaa84aaa0,
154         .gpdcon_mask=   0xffffffff,
155         .gpdup=         0x0000faff,
156         .gpdup_mask=    0xffffffff,
157
158         .width=         240,
159         .height=        320,
160         .xres=          {240,240,240},
161         .yres=          {320,320,320},
162         .bpp=           {16,16,16},
163 };
164
165 static struct platform_device *h1940_devices[] __initdata = {
166         &s3c_device_usb,
167         &s3c_device_lcd,
168         &s3c_device_wdt,
169         &s3c_device_i2c,
170         &s3c_device_iis,
171 };
172
173 static struct s3c24xx_board h1940_board __initdata = {
174         .devices       = h1940_devices,
175         .devices_count = ARRAY_SIZE(h1940_devices)
176 };
177
178 static void __init h1940_map_io(void)
179 {
180         s3c24xx_init_io(h1940_iodesc, ARRAY_SIZE(h1940_iodesc));
181         s3c24xx_init_clocks(0);
182         s3c24xx_init_uarts(h1940_uartcfgs, ARRAY_SIZE(h1940_uartcfgs));
183         s3c24xx_set_board(&h1940_board);
184 }
185
186 static void __init h1940_init_irq(void)
187 {
188         s3c24xx_init_irq();
189
190 }
191
192 static void __init h1940_init(void)
193 {
194         s3c24xx_fb_set_platdata(&h1940_lcdcfg);
195 }
196
197 MACHINE_START(H1940, "IPAQ-H1940")
198         /* Maintainer: Ben Dooks <ben@fluff.org> */
199         .phys_io        = S3C2410_PA_UART,
200         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
201         .boot_params    = S3C2410_SDRAM_PA + 0x100,
202         .map_io         = h1940_map_io,
203         .init_irq       = h1940_init_irq,
204         .init_machine   = h1940_init,
205         .timer          = &s3c24xx_timer,
206 MACHINE_END