Merge branch 'master' of /home/trondmy/kernel/linux-2.6/ into merge_linus
[linux-2.6] / arch / arm / mach-s3c2410 / mach-amlm5900.c
1 /***********************************************************************
2  *
3  * linux/arch/arm/mach-s3c2410/mach-amlm5900.c
4  *
5  * Copyright (c) 2006 American Microsystems Limited
6  *      David Anders <danders@amltd.com>
7
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  *
23  * @History:
24  * derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by
25  * Ben Dooks <ben@simtec.co.uk>
26  *
27  ***********************************************************************/
28
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/interrupt.h>
32 #include <linux/list.h>
33 #include <linux/timer.h>
34 #include <linux/init.h>
35 #include <linux/device.h>
36 #include <linux/platform_device.h>
37 #include <linux/proc_fs.h>
38
39
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/irq.h>
43 #include <asm/mach/flash.h>
44
45 #include <asm/hardware.h>
46 #include <asm/io.h>
47 #include <asm/irq.h>
48 #include <asm/mach-types.h>
49 #include <asm/arch/fb.h>
50
51 #include <asm/arch/regs-serial.h>
52 #include <asm/arch/regs-lcd.h>
53 #include <asm/arch/regs-gpio.h>
54
55 #include "devs.h"
56 #include "cpu.h"
57
58 #ifdef CONFIG_MTD_PARTITIONS
59
60 #include <linux/mtd/mtd.h>
61 #include <linux/mtd/partitions.h>
62 #include <linux/mtd/map.h>
63 #include <linux/mtd/physmap.h>
64
65 static struct resource amlm5900_nor_resource = {
66                 .start = 0x00000000,
67                 .end   = 0x01000000 - 1,
68                 .flags = IORESOURCE_MEM,
69 };
70
71
72
73 static struct mtd_partition amlm5900_mtd_partitions[] = {
74         {
75                 .name           = "System",
76                 .size           = 0x240000,
77                 .offset         = 0,
78                 .mask_flags     = MTD_WRITEABLE,  /* force read-only */
79         }, {
80                 .name           = "Kernel",
81                 .size           = 0x100000,
82                 .offset         = MTDPART_OFS_APPEND,
83         }, {
84                 .name           = "Ramdisk",
85                 .size           = 0x300000,
86                 .offset         = MTDPART_OFS_APPEND,
87         }, {
88                 .name           = "JFFS2",
89                 .size           = 0x9A0000,
90                 .offset         = MTDPART_OFS_APPEND,
91         }, {
92                 .name           = "Settings",
93                 .size           = MTDPART_SIZ_FULL,
94                 .offset         = MTDPART_OFS_APPEND,
95         }
96 };
97
98 static struct physmap_flash_data amlm5900_flash_data = {
99         .width          = 2,
100         .parts          = amlm5900_mtd_partitions,
101         .nr_parts       = ARRAY_SIZE(amlm5900_mtd_partitions),
102 };
103
104 static struct platform_device amlm5900_device_nor = {
105         .name           = "physmap-flash",
106         .id             = 0,
107         .dev = {
108                         .platform_data = &amlm5900_flash_data,
109                 },
110         .num_resources  = 1,
111         .resource       = &amlm5900_nor_resource,
112 };
113 #endif
114
115 static struct map_desc amlm5900_iodesc[] __initdata = {
116         {
117                 .virtual        = (u32)S3C24XX_VA_SPI,
118                 .pfn            = __phys_to_pfn(S3C2410_PA_SPI),
119                 .length         = SZ_1M,
120                 .type           = MT_DEVICE
121         }
122 };
123
124 #define UCON S3C2410_UCON_DEFAULT
125 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
126 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
127
128 static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
129         [0] = {
130                 .hwport      = 0,
131                 .flags       = 0,
132                 .ucon        = UCON,
133                 .ulcon       = ULCON,
134                 .ufcon       = UFCON,
135         },
136         [1] = {
137                 .hwport      = 1,
138                 .flags       = 0,
139                 .ucon        = UCON,
140                 .ulcon       = ULCON,
141                 .ufcon       = UFCON,
142         },
143         [2] = {
144                 .hwport      = 2,
145                 .flags       = 0,
146                 .ucon        = UCON,
147                 .ulcon       = ULCON,
148                 .ufcon       = UFCON,
149         }
150 };
151
152
153 static struct platform_device *amlm5900_devices[] __initdata = {
154 #ifdef CONFIG_FB_S3C2410
155         &s3c_device_lcd,
156 #endif
157         &s3c_device_adc,
158         &s3c_device_wdt,
159         &s3c_device_i2c,
160         &s3c_device_usb,
161         &s3c_device_rtc,
162         &s3c_device_usbgadget,
163         &s3c_device_sdi,
164 #ifdef CONFIG_MTD_PARTITIONS
165         &amlm5900_device_nor,
166 #endif
167 };
168
169 static struct s3c24xx_board amlm5900_board __initdata = {
170         .devices       = amlm5900_devices,
171         .devices_count = ARRAY_SIZE(amlm5900_devices)
172 };
173
174 void __init amlm5900_map_io(void)
175 {
176         s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
177         s3c24xx_init_clocks(0);
178         s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs));
179         s3c24xx_set_board(&amlm5900_board);
180 }
181
182 #ifdef CONFIG_FB_S3C2410
183 static struct s3c2410fb_mach_info __initdata amlm5900_lcd_info = {
184         .width          = 160,
185         .height         = 160,
186
187 /* commented out until stn patch is submitted
188 *       .type           = S3C2410_LCDCON1_STN4,
189 */
190         .gpccon =       0xaaaaaaaa,
191         .gpccon_mask =  0xffffffff,
192         .gpcup =        0x0000ffff,
193         .gpcup_mask =   0xffffffff,
194
195         .gpdcon =       0xaaaaaaaa,
196         .gpdcon_mask =  0xffffffff,
197         .gpdup =        0x0000ffff,
198         .gpdup_mask =   0xffffffff,
199
200         .xres           = {
201                 .min            = 160,
202                 .max            = 160,
203                 .defval         = 160,
204         },
205
206         .yres           = {
207                 .min            = 160,
208                 .max            = 160,
209                 .defval         = 160,
210         },
211
212         .bpp            = {
213                 .min            = 4,
214                 .max            = 4,
215                 .defval         = 4,
216         },
217
218         .regs           = {
219                 .lcdcon1        = 0x00008225,
220                 .lcdcon2        = 0x0027c000,
221                 .lcdcon3        = 0x00182708,
222                 .lcdcon4        = 0x00000002,
223                 .lcdcon5        = 0x00000001,
224         }
225 };
226 #endif
227
228 static irqreturn_t
229 amlm5900_wake_interrupt(int irq, void *ignored)
230 {
231         return IRQ_HANDLED;
232 }
233
234 static void amlm5900_init_pm(void)
235 {
236         int ret = 0;
237
238         ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
239                                 IRQF_TRIGGER_RISING | IRQF_SHARED,
240                                 "amlm5900_wakeup", &amlm5900_wake_interrupt);
241         if (ret != 0) {
242                 printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
243         } else {
244                 enable_irq_wake(IRQ_EINT9);
245                 /* configure the suspend/resume status pin */
246                 s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_OUTP);
247                 s3c2410_gpio_pullup(S3C2410_GPF2, 0);
248         }
249 }
250 static void __init amlm5900_init(void)
251 {
252         amlm5900_init_pm();
253 #ifdef CONFIG_FB_S3C2410
254         s3c24xx_fb_set_platdata(&amlm5900_lcd_info);
255 #endif
256 }
257
258 MACHINE_START(AML_M5900, "AML_M5900")
259         .phys_io        = S3C2410_PA_UART,
260         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
261         .boot_params    = S3C2410_SDRAM_PA + 0x100,
262         .map_io         = amlm5900_map_io,
263         .init_irq       = s3c24xx_init_irq,
264         .init_machine   = amlm5900_init,
265         .timer          = &s3c24xx_timer,
266 MACHINE_END