1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright (c) 2006 Simtec Electronics
4 //	Ben Dooks <ben@simtec.co.uk>
5 //
6 // Thanks to Dimity Andric (TomTom) and Steven Ryu (Samsung) for the
7 // loans of SMDK2413 to work with.
8 
9 #include <linux/kernel.h>
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/list.h>
13 #include <linux/timer.h>
14 #include <linux/init.h>
15 #include <linux/gpio/machine.h>
16 #include <linux/serial_core.h>
17 #include <linux/serial_s3c.h>
18 #include <linux/platform_device.h>
19 #include <linux/io.h>
20 #include <linux/memblock.h>
21 
22 #include <asm/mach/arch.h>
23 #include <asm/mach/map.h>
24 #include <asm/mach/irq.h>
25 
26 #include <asm/hardware/iomd.h>
27 #include <asm/setup.h>
28 #include <asm/irq.h>
29 #include <asm/mach-types.h>
30 
31 //#include <asm/debug-ll.h>
32 #include "hardware-s3c24xx.h"
33 #include "regs-gpio.h"
34 
35 #include <linux/platform_data/usb-s3c2410_udc.h>
36 #include <linux/platform_data/i2c-s3c2410.h>
37 #include <linux/platform_data/fb-s3c2410.h>
38 #include "gpio-samsung.h"
39 #include "gpio-cfg.h"
40 
41 #include "devs.h"
42 #include "cpu.h"
43 
44 #include "s3c24xx.h"
45 #include "common-smdk-s3c24xx.h"
46 
47 static struct map_desc smdk2413_iodesc[] __initdata = {
48 };
49 
50 static struct s3c2410_uartcfg smdk2413_uartcfgs[] __initdata = {
51 	[0] = {
52 		.hwport	     = 0,
53 		.flags	     = 0,
54 		.ucon	     = 0x3c5,
55 		.ulcon	     = 0x03,
56 		.ufcon	     = 0x51,
57 	},
58 	[1] = {
59 		.hwport	     = 1,
60 		.flags	     = 0,
61 		.ucon	     = 0x3c5,
62 		.ulcon	     = 0x03,
63 		.ufcon	     = 0x51,
64 	},
65 	/* IR port */
66 	[2] = {
67 		.hwport	     = 2,
68 		.flags	     = 0,
69 		.ucon	     = 0x3c5,
70 		.ulcon	     = 0x43,
71 		.ufcon	     = 0x51,
72 	}
73 };
74 
75 
76 static struct s3c2410_udc_mach_info smdk2413_udc_cfg __initdata = {
77 };
78 
79 static struct gpiod_lookup_table smdk2413_udc_gpio_table = {
80 	.dev_id = "s3c2410-usbgadget",
81 	.table = {
82 		GPIO_LOOKUP("GPIOF", 2, "pullup", GPIO_ACTIVE_HIGH),
83 		{ },
84 	},
85 };
86 
87 static struct platform_device *smdk2413_devices[] __initdata = {
88 	&s3c_device_ohci,
89 	&s3c_device_wdt,
90 	&s3c_device_i2c0,
91 	&s3c_device_iis,
92 	&s3c_device_usbgadget,
93 	&s3c2412_device_dma,
94 };
95 
smdk2413_fixup(struct tag * tags,char ** cmdline)96 static void __init smdk2413_fixup(struct tag *tags, char **cmdline)
97 {
98 	if (tags != phys_to_virt(S3C2410_SDRAM_PA + 0x100)) {
99 		memblock_add(0x30000000, SZ_64M);
100 	}
101 }
102 
smdk2413_map_io(void)103 static void __init smdk2413_map_io(void)
104 {
105 	s3c24xx_init_io(smdk2413_iodesc, ARRAY_SIZE(smdk2413_iodesc));
106 	s3c24xx_init_uarts(smdk2413_uartcfgs, ARRAY_SIZE(smdk2413_uartcfgs));
107 	s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
108 }
109 
smdk2413_init_time(void)110 static void __init smdk2413_init_time(void)
111 {
112 	s3c2412_init_clocks(12000000);
113 	s3c24xx_timer_init();
114 }
115 
smdk2413_machine_init(void)116 static void __init smdk2413_machine_init(void)
117 {	/* Turn off suspend on both USB ports, and switch the
118 	 * selectable USB port to USB device mode. */
119 
120 	s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
121 			      S3C2410_MISCCR_USBSUSPND0 |
122 			      S3C2410_MISCCR_USBSUSPND1, 0x0);
123 
124 	gpiod_add_lookup_table(&smdk2413_udc_gpio_table);
125  	s3c24xx_udc_set_platdata(&smdk2413_udc_cfg);
126 	s3c_i2c0_set_platdata(NULL);
127 	/* Configure the I2S pins (GPE0...GPE4) in correct mode */
128 	s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
129 			      S3C_GPIO_PULL_NONE);
130 
131 	platform_add_devices(smdk2413_devices, ARRAY_SIZE(smdk2413_devices));
132 	smdk_machine_init();
133 }
134 
135 MACHINE_START(S3C2413, "S3C2413")
136 	/* Maintainer: Ben Dooks <ben-linux@fluff.org> */
137 	.atag_offset	= 0x100,
138 	.nr_irqs	= NR_IRQS_S3C2412,
139 
140 	.fixup		= smdk2413_fixup,
141 	.init_irq	= s3c2412_init_irq,
142 	.map_io		= smdk2413_map_io,
143 	.init_machine	= smdk2413_machine_init,
144 	.init_time	= s3c24xx_timer_init,
145 MACHINE_END
146 
147 MACHINE_START(SMDK2412, "SMDK2412")
148 	/* Maintainer: Ben Dooks <ben-linux@fluff.org> */
149 	.atag_offset	= 0x100,
150 	.nr_irqs	= NR_IRQS_S3C2412,
151 
152 	.fixup		= smdk2413_fixup,
153 	.init_irq	= s3c2412_init_irq,
154 	.map_io		= smdk2413_map_io,
155 	.init_machine	= smdk2413_machine_init,
156 	.init_time	= s3c24xx_timer_init,
157 MACHINE_END
158 
159 MACHINE_START(SMDK2413, "SMDK2413")
160 	/* Maintainer: Ben Dooks <ben-linux@fluff.org> */
161 	.atag_offset	= 0x100,
162 	.nr_irqs	= NR_IRQS_S3C2412,
163 
164 	.fixup		= smdk2413_fixup,
165 	.init_irq	= s3c2412_init_irq,
166 	.map_io		= smdk2413_map_io,
167 	.init_machine	= smdk2413_machine_init,
168 	.init_time	= smdk2413_init_time,
169 MACHINE_END
170