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"
50 static void htcuniversal_irda_transceiver_mode(struct device
*dev
, int mode
)
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
;
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
;
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
= {
102 .irq
= 0 /* asic3 irq */
105 static struct platform_device htcuniversal_ts
= {
106 .name
= "htcuniversal_ts",
108 .platform_data
= &htcuniversal_ts_platform_data
,
115 static struct platform_device htcuniversal_bt
= {
116 .name
= "htcuniversal_bt",
119 .platform_data
= &bt_funcs
,
123 static struct platform_device htcuniversal_phone
= {
124 .name
= "htcuniversal_phone",
127 .platform_data
= &phone_funcs
,
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
= {
145 .platform_data
= &htcuniversal_pxa_keys_data
,
150 /****************************************************************
152 ****************************************************************/
154 static struct pxa27x_keyboard_platform_data htcuniversal_kbd
= {
167 KEY_RIGHTALT
, /* Fn */
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",
257 .platform_data
= &htcuniversal_kbd
,
260 /* Core Hardware Functions */
262 struct platform_device htcuniversal_core
= {
263 .name
= "htcuniversal_core",
266 .platform_data
= NULL
,
270 static struct platform_device
*devices
[] __initdata
= {
272 // &htcuniversal_flash,
273 &htcuniversal_pxa_keyboard
,
274 &htcuniversal_pxa_keys
,
277 static struct platform_device
*htcuniversal_asic3_devices
[] __initdata
= {
279 #ifdef CONFIG_HTCUNIVERSAL_BACKLIGHT
282 &htcuniversal_buttons
,
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.
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
) |
313 .init
= (1<<GPIOA_LCD_PWR5_ON
) |
316 .batt_fault_out
= 0x0000,
317 .alt_function
= 0x0000,
318 .sleep_conf
= 0x000c,
322 .init
= 0x8842, // TODO: 0x0900
324 .batt_fault_out
= 0x0000,
325 .alt_function
= 0x0000,
326 .sleep_conf
= 0x000c,
330 .init
= 0xc6e0, // TODO: 0x8000
332 .batt_fault_out
= 0x0000,
333 .alt_function
= 0x0007, // GPIOC_LED_RED | GPIOC_LED_GREEN | GPIOC_LED_BLUE
334 .sleep_conf
= 0x000c,
338 .init
= 0x7840, // TODO: 0x0000
340 .batt_fault_out
= 0x0000,
341 .alt_function
= 0x0000,
342 .sleep_conf
= 0x0008,
346 .child_platform_devs
= htcuniversal_asic3_devices
,
347 .num_child_platform_devs
= ARRAY_SIZE(htcuniversal_asic3_devices
),
350 static struct resource htcuniversal_asic3_resources
[] = {
352 .start
= HTCUNIVERSAL_ASIC3_GPIO_PHYS
,
353 .end
= HTCUNIVERSAL_ASIC3_GPIO_PHYS
+ IPAQ_ASIC3_MAP_SIZE
,
354 .flags
= IORESOURCE_MEM
,
357 .start
= HTCUNIVERSAL_IRQ(ASIC3_EXT_INT
),
358 .end
= HTCUNIVERSAL_IRQ(ASIC3_EXT_INT
),
359 .flags
= IORESOURCE_IRQ
,
362 .start
= HTCUNIVERSAL_ASIC3_MMC_PHYS
,
363 .end
= HTCUNIVERSAL_ASIC3_MMC_PHYS
+ IPAQ_ASIC3_MAP_SIZE
,
364 .flags
= IORESOURCE_MEM
,
367 .start
= HTCUNIVERSAL_IRQ(ASIC3_SDIO_INT_N
),
368 .flags
= IORESOURCE_IRQ
,
372 struct platform_device htcuniversal_asic3
= {
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
= {
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 */
406 // .lccr4 = 0x80000000,
409 static void __init
htcuniversal_init_irq(void)
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
,
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
);
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)
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
,