4220cc60de3c6df3b4887b0fcb5a8018c577b542
[sfrench/cifs-2.6.git] / arch / arm / mach-s3c24xx / mach-amlm5900.c
1 /* linux/arch/arm/mach-s3c2410/mach-amlm5900.c
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/gpio.h>
36 #include <linux/device.h>
37 #include <linux/platform_device.h>
38 #include <linux/proc_fs.h>
39 #include <linux/serial_core.h>
40 #include <linux/io.h>
41
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
45 #include <asm/mach/flash.h>
46
47 #include <mach/hardware.h>
48 #include <asm/irq.h>
49 #include <asm/mach-types.h>
50 #include <mach/fb.h>
51
52 #include <plat/regs-serial.h>
53 #include <mach/regs-lcd.h>
54 #include <mach/regs-gpio.h>
55
56 #include <plat/iic.h>
57 #include <plat/devs.h>
58 #include <plat/cpu.h>
59 #include <plat/gpio-cfg.h>
60
61 #include <linux/mtd/mtd.h>
62 #include <linux/mtd/partitions.h>
63 #include <linux/mtd/map.h>
64 #include <linux/mtd/physmap.h>
65
66 #include "common.h"
67
68 static struct resource amlm5900_nor_resource = {
69                 .start = 0x00000000,
70                 .end   = 0x01000000 - 1,
71                 .flags = IORESOURCE_MEM,
72 };
73
74
75
76 static struct mtd_partition amlm5900_mtd_partitions[] = {
77         {
78                 .name           = "System",
79                 .size           = 0x240000,
80                 .offset         = 0,
81                 .mask_flags     = MTD_WRITEABLE,  /* force read-only */
82         }, {
83                 .name           = "Kernel",
84                 .size           = 0x100000,
85                 .offset         = MTDPART_OFS_APPEND,
86         }, {
87                 .name           = "Ramdisk",
88                 .size           = 0x300000,
89                 .offset         = MTDPART_OFS_APPEND,
90         }, {
91                 .name           = "JFFS2",
92                 .size           = 0x9A0000,
93                 .offset         = MTDPART_OFS_APPEND,
94         }, {
95                 .name           = "Settings",
96                 .size           = MTDPART_SIZ_FULL,
97                 .offset         = MTDPART_OFS_APPEND,
98         }
99 };
100
101 static struct physmap_flash_data amlm5900_flash_data = {
102         .width          = 2,
103         .parts          = amlm5900_mtd_partitions,
104         .nr_parts       = ARRAY_SIZE(amlm5900_mtd_partitions),
105 };
106
107 static struct platform_device amlm5900_device_nor = {
108         .name           = "physmap-flash",
109         .id             = 0,
110         .dev = {
111                         .platform_data = &amlm5900_flash_data,
112                 },
113         .num_resources  = 1,
114         .resource       = &amlm5900_nor_resource,
115 };
116
117 static struct map_desc amlm5900_iodesc[] __initdata = {
118 };
119
120 #define UCON S3C2410_UCON_DEFAULT
121 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
122 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
123
124 static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
125         [0] = {
126                 .hwport      = 0,
127                 .flags       = 0,
128                 .ucon        = UCON,
129                 .ulcon       = ULCON,
130                 .ufcon       = UFCON,
131         },
132         [1] = {
133                 .hwport      = 1,
134                 .flags       = 0,
135                 .ucon        = UCON,
136                 .ulcon       = ULCON,
137                 .ufcon       = UFCON,
138         },
139         [2] = {
140                 .hwport      = 2,
141                 .flags       = 0,
142                 .ucon        = UCON,
143                 .ulcon       = ULCON,
144                 .ufcon       = UFCON,
145         }
146 };
147
148
149 static struct platform_device *amlm5900_devices[] __initdata = {
150 #ifdef CONFIG_FB_S3C2410
151         &s3c_device_lcd,
152 #endif
153         &s3c_device_adc,
154         &s3c_device_wdt,
155         &s3c_device_i2c0,
156         &s3c_device_ohci,
157         &s3c_device_rtc,
158         &s3c_device_usbgadget,
159         &s3c_device_sdi,
160         &amlm5900_device_nor,
161 };
162
163 static void __init amlm5900_map_io(void)
164 {
165         s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
166         s3c24xx_init_clocks(0);
167         s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs));
168 }
169
170 #ifdef CONFIG_FB_S3C2410
171 static struct s3c2410fb_display __initdata amlm5900_lcd_info = {
172         .width          = 160,
173         .height         = 160,
174
175         .type           = S3C2410_LCDCON1_STN4,
176
177         .pixclock       = 680000, /* HCLK = 100MHz */
178         .xres           = 160,
179         .yres           = 160,
180         .bpp            = 4,
181         .left_margin    = 1 << (4 + 3),
182         .right_margin   = 8 << 3,
183         .hsync_len      = 48,
184         .upper_margin   = 0,
185         .lower_margin   = 0,
186
187         .lcdcon5        = 0x00000001,
188 };
189
190 static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = {
191
192         .displays = &amlm5900_lcd_info,
193         .num_displays = 1,
194         .default_display = 0,
195
196         .gpccon =       0xaaaaaaaa,
197         .gpccon_mask =  0xffffffff,
198         .gpcup =        0x0000ffff,
199         .gpcup_mask =   0xffffffff,
200
201         .gpdcon =       0xaaaaaaaa,
202         .gpdcon_mask =  0xffffffff,
203         .gpdup =        0x0000ffff,
204         .gpdup_mask =   0xffffffff,
205 };
206 #endif
207
208 static irqreturn_t
209 amlm5900_wake_interrupt(int irq, void *ignored)
210 {
211         return IRQ_HANDLED;
212 }
213
214 static void amlm5900_init_pm(void)
215 {
216         int ret = 0;
217
218         ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
219                                 IRQF_TRIGGER_RISING | IRQF_SHARED,
220                                 "amlm5900_wakeup", &amlm5900_wake_interrupt);
221         if (ret != 0) {
222                 printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
223         } else {
224                 enable_irq_wake(IRQ_EINT9);
225                 /* configure the suspend/resume status pin */
226                 s3c_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT);
227                 s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_UP);
228         }
229 }
230 static void __init amlm5900_init(void)
231 {
232         amlm5900_init_pm();
233 #ifdef CONFIG_FB_S3C2410
234         s3c24xx_fb_set_platdata(&amlm5900_fb_info);
235 #endif
236         s3c_i2c0_set_platdata(NULL);
237         platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices));
238 }
239
240 MACHINE_START(AML_M5900, "AML_M5900")
241         .atag_offset    = 0x100,
242         .map_io         = amlm5900_map_io,
243         .init_irq       = s3c24xx_init_irq,
244         .init_machine   = amlm5900_init,
245         .timer          = &s3c24xx_timer,
246         .restart        = s3c2410_restart,
247 MACHINE_END