Merge tag 'v3.10.77' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-s3c24xx / mach-amlm5900.c
CommitLineData
a21765a7 1/* linux/arch/arm/mach-s3c2410/mach-amlm5900.c
da56c949
DA
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>
ec976d6e 35#include <linux/gpio.h>
da56c949
DA
36#include <linux/device.h>
37#include <linux/platform_device.h>
38#include <linux/proc_fs.h>
1b8fc188 39#include <linux/serial_core.h>
fced80c7 40#include <linux/io.h>
da56c949
DA
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
a09e64fb 47#include <mach/hardware.h>
da56c949
DA
48#include <asm/irq.h>
49#include <asm/mach-types.h>
a09e64fb 50#include <mach/fb.h>
da56c949 51
a2b7ba9c 52#include <plat/regs-serial.h>
a09e64fb
RK
53#include <mach/regs-lcd.h>
54#include <mach/regs-gpio.h>
da56c949 55
436d42c6 56#include <linux/platform_data/i2c-s3c2410.h>
a2b7ba9c
BD
57#include <plat/devs.h>
58#include <plat/cpu.h>
40b956f0 59#include <plat/gpio-cfg.h>
da56c949 60
da56c949
DA
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
7f78b6eb
RN
66#include <plat/samsung-time.h>
67
b27b0727
KK
68#include "common.h"
69
7d4aa909
TB
70static struct resource amlm5900_nor_resource =
71 DEFINE_RES_MEM(0x00000000, SZ_16M);
da56c949
DA
72
73static 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
98static 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
104static 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};
da56c949
DA
113
114static struct map_desc amlm5900_iodesc[] __initdata = {
da56c949
DA
115};
116
117#define UCON S3C2410_UCON_DEFAULT
118#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
119#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
120
121static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
122 [0] = {
123 .hwport = 0,
124 .flags = 0,
125 .ucon = UCON,
126 .ulcon = ULCON,
127 .ufcon = UFCON,
128 },
129 [1] = {
130 .hwport = 1,
131 .flags = 0,
132 .ucon = UCON,
133 .ulcon = ULCON,
134 .ufcon = UFCON,
135 },
136 [2] = {
137 .hwport = 2,
138 .flags = 0,
139 .ucon = UCON,
140 .ulcon = ULCON,
141 .ufcon = UFCON,
142 }
143};
144
145
146static struct platform_device *amlm5900_devices[] __initdata = {
147#ifdef CONFIG_FB_S3C2410
148 &s3c_device_lcd,
149#endif
150 &s3c_device_adc,
151 &s3c_device_wdt,
3e1b776c 152 &s3c_device_i2c0,
b813248c 153 &s3c_device_ohci,
da56c949
DA
154 &s3c_device_rtc,
155 &s3c_device_usbgadget,
156 &s3c_device_sdi,
da56c949 157 &amlm5900_device_nor,
da56c949
DA
158};
159
e078761a 160static void __init amlm5900_map_io(void)
da56c949
DA
161{
162 s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
163 s3c24xx_init_clocks(0);
164 s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs));
7f78b6eb 165 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
da56c949
DA
166}
167
168#ifdef CONFIG_FB_S3C2410
09fe75f6 169static struct s3c2410fb_display __initdata amlm5900_lcd_info = {
da56c949
DA
170 .width = 160,
171 .height = 160,
172
1f411537
KH
173 .type = S3C2410_LCDCON1_STN4,
174
69816699 175 .pixclock = 680000, /* HCLK = 100MHz */
09fe75f6
KH
176 .xres = 160,
177 .yres = 160,
178 .bpp = 4,
1f411537
KH
179 .left_margin = 1 << (4 + 3),
180 .right_margin = 8 << 3,
93d11f5a 181 .hsync_len = 48,
5f20f69b
KH
182 .upper_margin = 0,
183 .lower_margin = 0,
09fe75f6 184
f28ef573 185 .lcdcon5 = 0x00000001,
09fe75f6
KH
186};
187
188static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = {
189
190 .displays = &amlm5900_lcd_info,
191 .num_displays = 1,
192 .default_display = 0,
193
da56c949
DA
194 .gpccon = 0xaaaaaaaa,
195 .gpccon_mask = 0xffffffff,
196 .gpcup = 0x0000ffff,
197 .gpcup_mask = 0xffffffff,
198
199 .gpdcon = 0xaaaaaaaa,
200 .gpdcon_mask = 0xffffffff,
201 .gpdup = 0x0000ffff,
202 .gpdup_mask = 0xffffffff,
da56c949
DA
203};
204#endif
205
26f90818 206static irqreturn_t
0cd61b68 207amlm5900_wake_interrupt(int irq, void *ignored)
da56c949 208{
26f90818
DA
209 return IRQ_HANDLED;
210}
da56c949 211
26f90818
DA
212static void amlm5900_init_pm(void)
213{
214 int ret = 0;
215
216 ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
217 IRQF_TRIGGER_RISING | IRQF_SHARED,
218 "amlm5900_wakeup", &amlm5900_wake_interrupt);
219 if (ret != 0) {
220 printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
221 } else {
222 enable_irq_wake(IRQ_EINT9);
223 /* configure the suspend/resume status pin */
40b956f0 224 s3c_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT);
fb378747 225 s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_UP);
26f90818
DA
226 }
227}
228static void __init amlm5900_init(void)
229{
230 amlm5900_init_pm();
da56c949 231#ifdef CONFIG_FB_S3C2410
09fe75f6 232 s3c24xx_fb_set_platdata(&amlm5900_fb_info);
da56c949 233#endif
3e1b776c 234 s3c_i2c0_set_platdata(NULL);
57e5171c 235 platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices));
da56c949
DA
236}
237
238MACHINE_START(AML_M5900, "AML_M5900")
69d50710 239 .atag_offset = 0x100,
da56c949 240 .map_io = amlm5900_map_io,
f182aa1d 241 .init_irq = s3c2410_init_irq,
da56c949 242 .init_machine = amlm5900_init,
7f78b6eb 243 .init_time = samsung_timer_init,
b27b0727 244 .restart = s3c2410_restart,
da56c949 245MACHINE_END