hh.org updates
[hh.org.git] / arch / arm / mach-pxa / htcuniversal / htcuniversal.c
blob34820c1a08eaa75f05ab89d6e545dd051c1ad7ac
1 /*
2 * Hardware definitions for HTC Universal
4 * Copyright (c) 2006 Oleg Gusev
6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/irq.h>
17 #include <asm/mach-types.h>
18 #include <asm/hardware.h>
19 #include <asm/setup.h>
21 #include <asm/mach/irq.h>
22 #include <asm/mach/arch.h>
24 #include <asm/arch/bitfield.h>
25 #include <asm/arch/pxa-regs.h>
26 #include <asm/arch/serial.h>
27 #include <asm/arch/pxa27x_keyboard.h>
28 #include <asm/arch/pxafb.h>
29 #include <asm/arch/irda.h>
30 #include <asm/arch/ohci.h>
32 #include <linux/soc/asic3_base.h>
33 #include <asm/arch/htcuniversal-gpio.h>
34 #include <asm/arch/htcuniversal-init.h>
35 #include <asm/arch/htcuniversal-asic.h>
37 #include <asm/hardware/gpio_keys.h>
38 #include <asm/hardware/ipaq-asic3.h>
40 #include "../generic.h"
42 #include "htcuniversal_bt.h"
43 #include "htcuniversal_phone.h"
44 #include "tsc2046_ts.h"
47 * IRDA
50 static void htcuniversal_irda_transceiver_mode(struct device *dev, int mode)
52 /* */
55 static struct pxaficp_platform_data htcuniversal_ficp_platform_data = {
56 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
57 .transceiver_mode = htcuniversal_irda_transceiver_mode,
61 * Bluetooth - Relies on other loadable modules, like ASIC3 and Core,
62 * so make the calls indirectly through pointers. Requires that the
63 * hx4700 bluetooth module be loaded before any attempt to use
64 * bluetooth (obviously).
67 static struct htcuniversal_bt_funcs bt_funcs;
69 static void
70 htcuniversal_bt_configure( int state )
72 if (bt_funcs.configure != NULL)
73 bt_funcs.configure( state );
76 static struct htcuniversal_phone_funcs phone_funcs;
78 static void
79 htcuniversal_phone_configure( int state )
81 if (phone_funcs.configure != NULL)
82 phone_funcs.configure( state );
85 //void htcuniversal_ll_pm_init(void);
87 extern struct platform_device htcuniversal_bl;
88 static struct platform_device htcuniversal_lcd = { .name = "htcuniversal_lcd", };
89 //static struct platform_device htcuniversal_kbd = { .name = "htcuniversal_kbd", };
90 static struct platform_device htcuniversal_buttons = { .name = "htcuniversal_buttons", };
91 //static struct platform_device htcuniversal_ts = { .name = "htcuniversal_ts", };
92 //static struct platform_device htcuniversal_bt = { .name = "htcuniversal_bt", };
93 //static struct platform_device htcuniversal_phone = { .name = "htcuniversal_phone", };
94 static struct platform_device htcuniversal_power = { .name = "htcuniversal_power", };
95 static struct platform_device htcuniversal_udc = { .name = "htcuniversal_udc", };
97 static struct tsc2046_mach_info htcuniversal_ts_platform_data = {
98 .port = 1,
99 .clock = CKEN23_SSP1,
100 .pwrbit_X = 1,
101 .pwrbit_Y = 1,
102 .irq = 0 /* asic3 irq */
105 static struct platform_device htcuniversal_ts = {
106 .name = "htcuniversal_ts",
107 .dev = {
108 .platform_data = &htcuniversal_ts_platform_data,
113 /* Bluetooth */
115 static struct platform_device htcuniversal_bt = {
116 .name = "htcuniversal_bt",
117 .id = -1,
118 .dev = {
119 .platform_data = &bt_funcs,
123 static struct platform_device htcuniversal_phone = {
124 .name = "htcuniversal_phone",
125 .id = -1,
126 .dev = {
127 .platform_data = &phone_funcs,
131 /* PXA2xx Keys */
133 static struct gpio_keys_button htcuniversal_button_table[] = {
134 { KEY_POWER, GPIO_NR_HTCUNIVERSAL_KEY_ON_N, 1 },
137 static struct gpio_keys_platform_data htcuniversal_pxa_keys_data = {
138 .buttons = htcuniversal_button_table,
139 .nbuttons = ARRAY_SIZE(htcuniversal_button_table),
142 static struct platform_device htcuniversal_pxa_keys = {
143 .name = "gpio-keys",
144 .dev = {
145 .platform_data = &htcuniversal_pxa_keys_data,
147 .id = -1,
150 /****************************************************************
151 * Keyboard
152 ****************************************************************/
154 static struct pxa27x_keyboard_platform_data htcuniversal_kbd = {
155 .nr_rows = 8,
156 .nr_cols = 8,
157 .keycodes = {
159 /* row 0 */
160 KEY_ENTER,
161 KEY_MINUS,
162 KEY_ESC,
163 KEY_1,
164 KEY_TAB,
165 KEY_CAPSLOCK,
166 KEY_LEFTSHIFT,
167 KEY_RIGHTALT, /* Fn */
168 }, { /* row 1 */
169 KEY_COMMA,
170 KEY_EQUAL,
171 KEY_F1,
172 KEY_2,
173 KEY_Q,
174 KEY_A,
175 KEY_Z,
176 KEY_LEFTCTRL,
177 }, { /* row 2 */
178 KEY_UP,
179 KEY_I,
180 KEY_F2,
181 KEY_3,
182 KEY_W,
183 KEY_S,
184 KEY_X,
185 KEY_F6,
186 }, { /* row 3 */
187 KEY_DOT,
188 KEY_O,
189 KEY_F3,
190 KEY_4,
191 KEY_E,
192 KEY_D,
193 KEY_C,
194 KEY_LEFTALT,
195 }, { /* row 4 */
196 KEY_F9,
197 KEY_P,
198 KEY_F4,
199 KEY_5,
200 KEY_R,
201 KEY_F,
202 KEY_V,
203 KEY_SPACE,
204 }, { /* row 5 */
205 KEY_RIGHT,
206 KEY_BACKSPACE,
207 KEY_F5,
208 KEY_6,
209 KEY_T,
210 KEY_G,
211 KEY_B,
212 KEY_F7,
213 }, { /* row 6 */
214 KEY_F9,
215 KEY_K,
216 KEY_9,
217 KEY_7,
218 KEY_Y,
219 KEY_H,
220 KEY_N,
221 KEY_LEFT,
222 }, { /* row 7 */
223 KEY_F10,
224 KEY_L,
225 KEY_0,
226 KEY_8,
227 KEY_U,
228 KEY_J,
229 KEY_M,
230 KEY_DOWN,
233 .gpio_modes = {
234 GPIO_NR_HTCUNIVERSAL_KP_MKIN0_MD,
235 GPIO_NR_HTCUNIVERSAL_KP_MKIN1_MD,
236 GPIO_NR_HTCUNIVERSAL_KP_MKIN2_MD,
237 GPIO_NR_HTCUNIVERSAL_KP_MKIN3_MD,
238 GPIO_NR_HTCUNIVERSAL_KP_MKIN4_MD,
239 GPIO_NR_HTCUNIVERSAL_KP_MKIN5_MD,
240 GPIO_NR_HTCUNIVERSAL_KP_MKIN6_MD,
241 GPIO_NR_HTCUNIVERSAL_KP_MKIN7_MD,
242 GPIO_NR_HTCUNIVERSAL_KP_MKOUT0_MD,
243 GPIO_NR_HTCUNIVERSAL_KP_MKOUT1_MD,
244 GPIO_NR_HTCUNIVERSAL_KP_MKOUT2_MD,
245 GPIO_NR_HTCUNIVERSAL_KP_MKOUT3_MD,
246 GPIO_NR_HTCUNIVERSAL_KP_MKOUT4_MD,
247 GPIO_NR_HTCUNIVERSAL_KP_MKOUT5_MD,
248 GPIO_NR_HTCUNIVERSAL_KP_MKOUT6_MD,
249 GPIO_NR_HTCUNIVERSAL_KP_MKOUT7_MD,
253 static struct platform_device htcuniversal_pxa_keyboard = {
254 .name = "pxa27x-keyboard",
255 .id = -1,
256 .dev = {
257 .platform_data = &htcuniversal_kbd,
260 /* Core Hardware Functions */
262 struct platform_device htcuniversal_core = {
263 .name = "htcuniversal_core",
264 .id = 0,
265 .dev = {
266 .platform_data = NULL,
270 static struct platform_device *devices[] __initdata = {
271 &htcuniversal_core,
272 // &htcuniversal_flash,
273 &htcuniversal_pxa_keyboard,
274 &htcuniversal_pxa_keys,
277 static struct platform_device *htcuniversal_asic3_devices[] __initdata = {
278 &htcuniversal_lcd,
279 #ifdef CONFIG_HTCUNIVERSAL_BACKLIGHT
280 &htcuniversal_bl,
281 #endif
282 &htcuniversal_buttons,
283 &htcuniversal_ts,
284 &htcuniversal_bt,
285 &htcuniversal_phone,
286 &htcuniversal_power,
287 &htcuniversal_udc,
290 static struct asic3_platform_data htcuniversal_asic3_platform_data = {
292 /* Setting ASIC3 GPIO registers to the below initialization states
293 * HTC Universal asic3 information:
294 * http://wiki.xda-developers.com/index.php?pagename=UniversalASIC3
295 * http://wiki.xda-developers.com/index.php?pagename=ASIC3
297 * dir: Direction of the GPIO pin. 0: input, 1: output.
298 * If unknown, set as output to avoid power consuming floating input nodes
299 * init: Initial state of the GPIO bits
301 * These registers are configured as they are on Wince.
303 .gpio_a = {
304 .dir = (1<<GPIOA_LCD_PWR5_ON) |
305 (1<<GPIOA_FLASHLIGHT) |
306 (1<<GPIOA_UNKNOWN9) |
307 (1<<GPIOA_SPK_PWR2_ON) |
308 (1<<GPIOA_UNKNOWN4) |
309 (1<<GPIOA_EARPHONE_PWR_ON)|
310 (1<<GPIOA_AUDIO_PWR_ON) |
311 (1<<GPIOA_SPK_PWR1_ON) |
312 (1<<GPIOA_I2C_EN),
313 .init = (1<<GPIOA_LCD_PWR5_ON) |
314 (1<<GPIOA_I2C_EN),
315 .sleep_out = 0x0000,
316 .batt_fault_out = 0x0000,
317 .alt_function = 0x0000,
318 .sleep_conf = 0x000c,
320 .gpio_b = {
321 .dir = 0xc142,
322 .init = 0x8842, // TODO: 0x0900
323 .sleep_out = 0x0000,
324 .batt_fault_out = 0x0000,
325 .alt_function = 0x0000,
326 .sleep_conf = 0x000c,
328 .gpio_c = {
329 .dir = 0xc7e7,
330 .init = 0xc6e0, // TODO: 0x8000
331 .sleep_out = 0x0000,
332 .batt_fault_out = 0x0000,
333 .alt_function = 0x0007, // GPIOC_LED_RED | GPIOC_LED_GREEN | GPIOC_LED_BLUE
334 .sleep_conf = 0x000c,
336 .gpio_d = {
337 .dir = 0xffc0,
338 .init = 0x7840, // TODO: 0x0000
339 .sleep_out = 0x0000,
340 .batt_fault_out = 0x0000,
341 .alt_function = 0x0000,
342 .sleep_conf = 0x0008,
344 .bus_shift = 1,
346 .child_platform_devs = htcuniversal_asic3_devices,
347 .num_child_platform_devs = ARRAY_SIZE(htcuniversal_asic3_devices),
350 static struct resource htcuniversal_asic3_resources[] = {
351 [0] = {
352 .start = HTCUNIVERSAL_ASIC3_GPIO_PHYS,
353 .end = HTCUNIVERSAL_ASIC3_GPIO_PHYS + IPAQ_ASIC3_MAP_SIZE,
354 .flags = IORESOURCE_MEM,
356 [1] = {
357 .start = HTCUNIVERSAL_IRQ(ASIC3_EXT_INT),
358 .end = HTCUNIVERSAL_IRQ(ASIC3_EXT_INT),
359 .flags = IORESOURCE_IRQ,
361 [2] = {
362 .start = HTCUNIVERSAL_ASIC3_MMC_PHYS,
363 .end = HTCUNIVERSAL_ASIC3_MMC_PHYS + IPAQ_ASIC3_MAP_SIZE,
364 .flags = IORESOURCE_MEM,
366 [3] = {
367 .start = HTCUNIVERSAL_IRQ(ASIC3_SDIO_INT_N),
368 .flags = IORESOURCE_IRQ,
372 struct platform_device htcuniversal_asic3 = {
373 .name = "asic3",
374 .id = 0,
375 .num_resources = ARRAY_SIZE(htcuniversal_asic3_resources),
376 .resource = htcuniversal_asic3_resources,
377 .dev = { .platform_data = &htcuniversal_asic3_platform_data, },
379 EXPORT_SYMBOL(htcuniversal_asic3);
381 static struct pxafb_mode_info htcuniversal_lcd_modes[] __initdata = {
383 .pixclock = 96153,
384 .xres = 480,
385 .yres = 640,
386 .bpp = 16,
387 .hsync_len = 4,
388 .vsync_len = 1,
389 .left_margin = 20,
390 .right_margin = 8,
391 .upper_margin = 7,
392 .lower_margin = 8,
394 // .sync = FB_SYNC_HOR_LOW_ACT|FB_SYNC_VERT_LOW_ACT,
399 static struct pxafb_mach_info sony_acx526akm __initdata= {
400 .modes = htcuniversal_lcd_modes,
401 .num_modes = ARRAY_SIZE(htcuniversal_lcd_modes),
403 /* fixme: use constants defined in pxafb.h */
404 .lccr0 = 0x00000080,
405 .lccr3 = 0x00400000,
406 // .lccr4 = 0x80000000,
409 static void __init htcuniversal_init_irq(void)
411 pxa_init_irq();
414 static struct platform_pxa_serial_funcs htcuniversal_pxa_bt_funcs = {
415 .configure = htcuniversal_bt_configure,
417 static struct platform_pxa_serial_funcs htcuniversal_pxa_phone_funcs = {
418 .configure = htcuniversal_phone_configure,
421 /* USB OHCI */
423 static int htcuniversal_ohci_init(struct device *dev)
425 /* missing GPIO setup here */
427 /* no idea what this does, got the values from magician */
428 UHCHR = (UHCHR | UHCHR_SSEP2 | UHCHR_PCPL | UHCHR_CGR) &
429 ~(UHCHR_SSEP1 | UHCHR_SSEP3 | UHCHR_SSE);
431 return 0;
434 static struct pxaohci_platform_data htcuniversal_ohci_platform_data = {
435 .port_mode = PMM_PERPORT_MODE,
436 .init = htcuniversal_ohci_init,
439 static void __init htcuniversal_map_io(void)
441 pxa_map_io();
443 btuart_device.dev.platform_data = &htcuniversal_pxa_bt_funcs;
444 ffuart_device.dev.platform_data = &htcuniversal_pxa_phone_funcs;
447 static void __init htcuniversal_init(void)
449 set_pxa_fb_info(&sony_acx526akm);
451 platform_device_register(&htcuniversal_asic3);
452 platform_add_devices(devices, ARRAY_SIZE(devices) );
453 pxa_set_ficp_info(&htcuniversal_ficp_platform_data);
454 pxa_set_ohci_info(&htcuniversal_ohci_platform_data);
457 MACHINE_START(HTCUNIVERSAL, "HTC Universal")
458 /* Maintainer xanadux.org */
459 .phys_io = 0x40000000,
460 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
461 .boot_params = 0xa0000100,
462 .map_io = htcuniversal_map_io,
463 .init_irq = htcuniversal_init_irq,
464 .init_machine = htcuniversal_init,
465 .timer = &pxa_timer,
466 MACHINE_END