ARM: s3c24xx: move s3cmci pinctrl handling into board files
[linux-2.6-microblaze.git] / arch / arm / mach-s3c24xx / mach-amlm5900.c
1 // SPDX-License-Identifier: GPL-2.0+
2 //
3 // Copyright (c) 2006 American Microsystems Limited
4 //      David Anders <danders@amltd.com>
5 //
6 // @History:
7 // derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by
8 // Ben Dooks <ben@simtec.co.uk>
9
10 #include <linux/kernel.h>
11 #include <linux/types.h>
12 #include <linux/interrupt.h>
13 #include <linux/list.h>
14 #include <linux/timer.h>
15 #include <linux/init.h>
16 #include <linux/gpio/machine.h>
17 #include <linux/gpio.h>
18 #include <linux/device.h>
19 #include <linux/platform_device.h>
20 #include <linux/proc_fs.h>
21 #include <linux/serial_core.h>
22 #include <linux/serial_s3c.h>
23 #include <linux/io.h>
24
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/irq.h>
28 #include <asm/mach/flash.h>
29
30 #include <asm/irq.h>
31 #include <asm/mach-types.h>
32 #include <mach/fb.h>
33
34 #include <mach/regs-lcd.h>
35 #include <mach/regs-gpio.h>
36 #include <mach/gpio-samsung.h>
37
38 #include <linux/platform_data/i2c-s3c2410.h>
39 #include <plat/devs.h>
40 #include <plat/cpu.h>
41 #include <plat/gpio-cfg.h>
42
43 #include <linux/mtd/mtd.h>
44 #include <linux/mtd/partitions.h>
45 #include <linux/mtd/map.h>
46 #include <linux/mtd/physmap.h>
47
48 #include "common.h"
49
50 static struct resource amlm5900_nor_resource =
51                         DEFINE_RES_MEM(0x00000000, SZ_16M);
52
53 static struct mtd_partition amlm5900_mtd_partitions[] = {
54         {
55                 .name           = "System",
56                 .size           = 0x240000,
57                 .offset         = 0,
58                 .mask_flags     = MTD_WRITEABLE,  /* force read-only */
59         }, {
60                 .name           = "Kernel",
61                 .size           = 0x100000,
62                 .offset         = MTDPART_OFS_APPEND,
63         }, {
64                 .name           = "Ramdisk",
65                 .size           = 0x300000,
66                 .offset         = MTDPART_OFS_APPEND,
67         }, {
68                 .name           = "JFFS2",
69                 .size           = 0x9A0000,
70                 .offset         = MTDPART_OFS_APPEND,
71         }, {
72                 .name           = "Settings",
73                 .size           = MTDPART_SIZ_FULL,
74                 .offset         = MTDPART_OFS_APPEND,
75         }
76 };
77
78 static struct physmap_flash_data amlm5900_flash_data = {
79         .width          = 2,
80         .parts          = amlm5900_mtd_partitions,
81         .nr_parts       = ARRAY_SIZE(amlm5900_mtd_partitions),
82 };
83
84 static struct platform_device amlm5900_device_nor = {
85         .name           = "physmap-flash",
86         .id             = 0,
87         .dev = {
88                         .platform_data = &amlm5900_flash_data,
89                 },
90         .num_resources  = 1,
91         .resource       = &amlm5900_nor_resource,
92 };
93
94 static struct map_desc amlm5900_iodesc[] __initdata = {
95 };
96
97 #define UCON S3C2410_UCON_DEFAULT
98 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
99 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
100
101 static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
102         [0] = {
103                 .hwport      = 0,
104                 .flags       = 0,
105                 .ucon        = UCON,
106                 .ulcon       = ULCON,
107                 .ufcon       = UFCON,
108         },
109         [1] = {
110                 .hwport      = 1,
111                 .flags       = 0,
112                 .ucon        = UCON,
113                 .ulcon       = ULCON,
114                 .ufcon       = UFCON,
115         },
116         [2] = {
117                 .hwport      = 2,
118                 .flags       = 0,
119                 .ucon        = UCON,
120                 .ulcon       = ULCON,
121                 .ufcon       = UFCON,
122         }
123 };
124
125 static struct gpiod_lookup_table amlm5900_mmc_gpio_table = {
126         .dev_id = "s3c2410-sdi",
127         .table = {
128                 /* bus pins */
129                 GPIO_LOOKUP_IDX("GPIOE",  5, "bus", 0, GPIO_ACTIVE_HIGH),
130                 GPIO_LOOKUP_IDX("GPIOE",  6, "bus", 1, GPIO_ACTIVE_HIGH),
131                 GPIO_LOOKUP_IDX("GPIOE",  7, "bus", 2, GPIO_ACTIVE_HIGH),
132                 GPIO_LOOKUP_IDX("GPIOE",  8, "bus", 3, GPIO_ACTIVE_HIGH),
133                 GPIO_LOOKUP_IDX("GPIOE",  9, "bus", 4, GPIO_ACTIVE_HIGH),
134                 GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
135                 { },
136         },
137 };
138
139 static struct platform_device *amlm5900_devices[] __initdata = {
140 #ifdef CONFIG_FB_S3C2410
141         &s3c_device_lcd,
142 #endif
143         &s3c_device_adc,
144         &s3c_device_wdt,
145         &s3c_device_i2c0,
146         &s3c_device_ohci,
147         &s3c_device_rtc,
148         &s3c_device_usbgadget,
149         &s3c_device_sdi,
150         &amlm5900_device_nor,
151 };
152
153 static void __init amlm5900_map_io(void)
154 {
155         s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
156         s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs));
157         samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
158 }
159
160 static void __init amlm5900_init_time(void)
161 {
162         s3c2410_init_clocks(12000000);
163         samsung_timer_init();
164 }
165
166 #ifdef CONFIG_FB_S3C2410
167 static struct s3c2410fb_display __initdata amlm5900_lcd_info = {
168         .width          = 160,
169         .height         = 160,
170
171         .type           = S3C2410_LCDCON1_STN4,
172
173         .pixclock       = 680000, /* HCLK = 100MHz */
174         .xres           = 160,
175         .yres           = 160,
176         .bpp            = 4,
177         .left_margin    = 1 << (4 + 3),
178         .right_margin   = 8 << 3,
179         .hsync_len      = 48,
180         .upper_margin   = 0,
181         .lower_margin   = 0,
182
183         .lcdcon5        = 0x00000001,
184 };
185
186 static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = {
187
188         .displays = &amlm5900_lcd_info,
189         .num_displays = 1,
190         .default_display = 0,
191
192         .gpccon =       0xaaaaaaaa,
193         .gpccon_mask =  0xffffffff,
194         .gpcup =        0x0000ffff,
195         .gpcup_mask =   0xffffffff,
196
197         .gpdcon =       0xaaaaaaaa,
198         .gpdcon_mask =  0xffffffff,
199         .gpdup =        0x0000ffff,
200         .gpdup_mask =   0xffffffff,
201 };
202 #endif
203
204 static irqreturn_t
205 amlm5900_wake_interrupt(int irq, void *ignored)
206 {
207         return IRQ_HANDLED;
208 }
209
210 static void amlm5900_init_pm(void)
211 {
212         int ret = 0;
213
214         ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
215                                 IRQF_TRIGGER_RISING | IRQF_SHARED,
216                                 "amlm5900_wakeup", &amlm5900_wake_interrupt);
217         if (ret != 0) {
218                 printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
219         } else {
220                 enable_irq_wake(IRQ_EINT9);
221                 /* configure the suspend/resume status pin */
222                 s3c_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT);
223                 s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_UP);
224         }
225 }
226 static void __init amlm5900_init(void)
227 {
228         amlm5900_init_pm();
229 #ifdef CONFIG_FB_S3C2410
230         s3c24xx_fb_set_platdata(&amlm5900_fb_info);
231 #endif
232         s3c_i2c0_set_platdata(NULL);
233         gpiod_add_lookup_table(&amlm5900_mmc_gpio_table);
234         platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices));
235 }
236
237 MACHINE_START(AML_M5900, "AML_M5900")
238         .atag_offset    = 0x100,
239         .map_io         = amlm5900_map_io,
240         .init_irq       = s3c2410_init_irq,
241         .init_machine   = amlm5900_init,
242         .init_time      = amlm5900_init_time,
243 MACHINE_END