Commit | Line | Data |
---|---|---|
196a0475 | 1 | /* Machine specific code for the Acer n30 PDA. |
1da177e4 LT |
2 | * |
3 | * Copyright (c) 2003-2005 Simtec Electronics | |
4 | * Ben Dooks <ben@simtec.co.uk> | |
5 | * | |
196a0475 | 6 | * Copyright (c) 2005-2008 Christer Weinigel <christer@weinigel.se> |
1da177e4 LT |
7 | * |
8 | * There is a wiki with more information about the n30 port at | |
9 | * http://handhelds.org/moin/moin.cgi/AcerN30Documentation . | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License version 2 as | |
13 | * published by the Free Software Foundation. | |
14 | */ | |
15 | ||
16 | #include <linux/kernel.h> | |
17 | #include <linux/types.h> | |
196a0475 | 18 | |
1da177e4 | 19 | #include <linux/delay.h> |
62065750 | 20 | #include <linux/gpio_keys.h> |
196a0475 | 21 | #include <linux/init.h> |
62065750 | 22 | #include <linux/input.h> |
196a0475 | 23 | #include <linux/interrupt.h> |
d052d1be | 24 | #include <linux/platform_device.h> |
196a0475 CW |
25 | #include <linux/serial_core.h> |
26 | #include <linux/timer.h> | |
1da177e4 LT |
27 | |
28 | #include <asm/hardware.h> | |
1da177e4 LT |
29 | #include <asm/io.h> |
30 | #include <asm/irq.h> | |
31 | #include <asm/mach-types.h> | |
32 | ||
1da177e4 | 33 | #include <asm/arch/regs-gpio.h> |
196a0475 CW |
34 | |
35 | #include <asm/mach/arch.h> | |
36 | #include <asm/mach/irq.h> | |
37 | #include <asm/mach/map.h> | |
38 | ||
531b617c | 39 | #include <asm/plat-s3c/iic.h> |
196a0475 | 40 | #include <asm/plat-s3c/regs-serial.h> |
1da177e4 | 41 | |
a21765a7 | 42 | #include <asm/plat-s3c24xx/clock.h> |
a21765a7 | 43 | #include <asm/plat-s3c24xx/cpu.h> |
196a0475 CW |
44 | #include <asm/plat-s3c24xx/devs.h> |
45 | #include <asm/plat-s3c24xx/s3c2410.h> | |
d088e5fe | 46 | #include <asm/plat-s3c24xx/udc.h> |
1da177e4 LT |
47 | |
48 | static struct map_desc n30_iodesc[] __initdata = { | |
49 | /* nothing here yet */ | |
50 | }; | |
51 | ||
52 | static struct s3c2410_uartcfg n30_uartcfgs[] = { | |
53 | /* Normal serial port */ | |
54 | [0] = { | |
55 | .hwport = 0, | |
56 | .flags = 0, | |
57 | .ucon = 0x2c5, | |
58 | .ulcon = 0x03, | |
59 | .ufcon = 0x51, | |
60 | }, | |
61 | /* IR port */ | |
62 | [1] = { | |
63 | .hwport = 1, | |
64 | .flags = 0, | |
65 | .uart_flags = UPF_CONS_FLOW, | |
66 | .ucon = 0x2c5, | |
67 | .ulcon = 0x43, | |
68 | .ufcon = 0x51, | |
69 | }, | |
70 | /* The BlueTooth controller is connected to port 2 */ | |
71 | [2] = { | |
72 | .hwport = 2, | |
73 | .flags = 0, | |
74 | .ucon = 0x2c5, | |
75 | .ulcon = 0x03, | |
76 | .ufcon = 0x51, | |
77 | }, | |
78 | }; | |
79 | ||
d088e5fe CW |
80 | static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd) |
81 | { | |
82 | switch (cmd) | |
83 | { | |
84 | case S3C2410_UDC_P_ENABLE : | |
85 | s3c2410_gpio_setpin(S3C2410_GPB3, 1); | |
86 | break; | |
87 | case S3C2410_UDC_P_DISABLE : | |
88 | s3c2410_gpio_setpin(S3C2410_GPB3, 0); | |
89 | break; | |
90 | case S3C2410_UDC_P_RESET : | |
91 | break; | |
92 | default: | |
93 | break; | |
94 | } | |
95 | } | |
96 | ||
97 | static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = { | |
98 | .udc_command = n30_udc_pullup, | |
99 | .vbus_pin = S3C2410_GPG1, | |
100 | .vbus_pin_inverted = 0, | |
101 | }; | |
102 | ||
62065750 CW |
103 | static struct gpio_keys_button n30_buttons[] = { |
104 | { | |
105 | .gpio = S3C2410_GPF0, | |
106 | .code = KEY_POWER, | |
107 | .desc = "Power", | |
108 | .active_low = 0, | |
109 | }, | |
110 | { | |
111 | .gpio = S3C2410_GPG9, | |
112 | .code = KEY_UP, | |
113 | .desc = "Thumbwheel Up", | |
114 | .active_low = 0, | |
115 | }, | |
116 | { | |
117 | .gpio = S3C2410_GPG8, | |
118 | .code = KEY_DOWN, | |
119 | .desc = "Thumbwheel Down", | |
120 | .active_low = 0, | |
121 | }, | |
122 | { | |
123 | .gpio = S3C2410_GPG7, | |
124 | .code = KEY_ENTER, | |
125 | .desc = "Thumbwheel Press", | |
126 | .active_low = 0, | |
127 | }, | |
128 | { | |
129 | .gpio = S3C2410_GPF7, | |
130 | .code = KEY_HOMEPAGE, | |
131 | .desc = "Home", | |
132 | .active_low = 0, | |
133 | }, | |
134 | { | |
135 | .gpio = S3C2410_GPF6, | |
136 | .code = KEY_CALENDAR, | |
137 | .desc = "Calendar", | |
138 | .active_low = 0, | |
139 | }, | |
140 | { | |
141 | .gpio = S3C2410_GPF5, | |
142 | .code = KEY_ADDRESSBOOK, | |
143 | .desc = "Contacts", | |
144 | .active_low = 0, | |
145 | }, | |
146 | { | |
147 | .gpio = S3C2410_GPF4, | |
148 | .code = KEY_MAIL, | |
149 | .desc = "Mail", | |
150 | .active_low = 0, | |
151 | }, | |
152 | }; | |
153 | ||
154 | static struct gpio_keys_platform_data n30_button_data = { | |
155 | .buttons = n30_buttons, | |
156 | .nbuttons = ARRAY_SIZE(n30_buttons), | |
157 | }; | |
158 | ||
159 | static struct platform_device n30_button_device = { | |
160 | .name = "gpio-keys", | |
161 | .id = -1, | |
162 | .dev = { | |
163 | .platform_data = &n30_button_data, | |
164 | } | |
165 | }; | |
166 | ||
1da177e4 | 167 | static struct platform_device *n30_devices[] __initdata = { |
1da177e4 LT |
168 | &s3c_device_lcd, |
169 | &s3c_device_wdt, | |
170 | &s3c_device_i2c, | |
171 | &s3c_device_iis, | |
196a0475 | 172 | &s3c_device_usb, |
1da177e4 | 173 | &s3c_device_usbgadget, |
62065750 | 174 | &n30_button_device, |
1da177e4 LT |
175 | }; |
176 | ||
177 | static struct s3c2410_platform_i2c n30_i2ccfg = { | |
178 | .flags = 0, | |
179 | .slave_addr = 0x10, | |
180 | .bus_freq = 10*1000, | |
181 | .max_freq = 10*1000, | |
182 | }; | |
183 | ||
5fe10ab1 | 184 | static void __init n30_map_io(void) |
1da177e4 LT |
185 | { |
186 | s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc)); | |
187 | s3c24xx_init_clocks(0); | |
188 | s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs)); | |
1da177e4 LT |
189 | } |
190 | ||
5fe10ab1 | 191 | static void __init n30_init_irq(void) |
1da177e4 LT |
192 | { |
193 | s3c24xx_init_irq(); | |
194 | } | |
195 | ||
027da01d | 196 | /* GPB3 is the line that controls the pull-up for the USB D+ line */ |
1da177e4 | 197 | |
5fe10ab1 | 198 | static void __init n30_init(void) |
1da177e4 LT |
199 | { |
200 | s3c_device_i2c.dev.platform_data = &n30_i2ccfg; | |
d088e5fe | 201 | s3c24xx_udc_set_platdata(&n30_udc_cfg); |
1da177e4 | 202 | |
027da01d BD |
203 | /* Turn off suspend on both USB ports, and switch the |
204 | * selectable USB port to USB device mode. */ | |
205 | ||
206 | s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST | | |
207 | S3C2410_MISCCR_USBSUSPND0 | | |
208 | S3C2410_MISCCR_USBSUSPND1, 0x0); | |
57e5171c BD |
209 | |
210 | platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices)); | |
1da177e4 LT |
211 | } |
212 | ||
213 | MACHINE_START(N30, "Acer-N30") | |
027da01d BD |
214 | /* Maintainer: Christer Weinigel <christer@weinigel.se>, |
215 | Ben Dooks <ben-linux@fluff.org> | |
216 | */ | |
e9dea0c6 RK |
217 | .phys_io = S3C2410_PA_UART, |
218 | .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, | |
219 | .boot_params = S3C2410_SDRAM_PA + 0x100, | |
1da177e4 LT |
220 | .timer = &s3c24xx_timer, |
221 | .init_machine = n30_init, | |
222 | .init_irq = n30_init_irq, | |
223 | .map_io = n30_map_io, | |
224 | MACHINE_END |