1 Index: linux-2.6.20.7/arch/arm/mach-pxa/ezx-emu.c
2 ===================================================================
3 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4 +++ linux-2.6.20.7/arch/arm/mach-pxa/ezx-emu.c 2007-04-21 12:33:22.000000000 -0300
7 + * EMU Driver for Motorola EZX phones
9 + * Copyright (c) 2007 Daniel Ribeiro <drwyrm@gmail.com>
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.
17 +#include <linux/kernel.h>
18 +#include <linux/interrupt.h>
19 +#include <linux/module.h>
20 +#include <linux/platform_device.h>
22 +#include <asm/arch/hardware.h>
23 +#include <asm/arch/pxa-regs.h>
24 +#include <asm/arch/ezx.h>
25 +#include <asm/arch/ezx-pcap.h>
26 +#include <asm/arch/udc.h>
28 +static struct pxa2xx_udc_mach_info ezx_udc_info;
29 +extern int ezx_pcap_bit_set(u_int32_t, u_int8_t);
30 +extern int ezx_pcap_read_bit(u_int32_t);
32 +void emu_switch_to_usb(void)
34 + pxa_gpio_mode(GPIO34_USB_P2_2_MD);
35 + pxa_gpio_mode(GPIO35_USB_P2_1_MD);
36 + pxa_gpio_mode(GPIO36_USB_P2_4_MD);
37 + pxa_gpio_mode(GPIO39_USB_P2_6_MD);
38 + pxa_gpio_mode(GPIO40_USB_P2_5_MD);
39 + pxa_gpio_mode(GPIO53_USB_P2_3_MD);
40 + UP2OCR = 0x02000000;
41 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_RS232ENB, 1);
42 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_FSENB, 0);
43 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_VUSB_EN, 1);
44 + clr_GPIO(GPIO_EMU_MUX1);
45 + clr_GPIO(GPIO_EMU_MUX2);
47 +EXPORT_SYMBOL(emu_switch_to_usb);
49 +void emu_switch_to_uart(void)
51 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_VUSB_EN,0);
52 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_RS232ENB, 0);
53 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_RS232_DIR, 1);
54 + set_GPIO(GPIO39_FFTXD);
55 + pxa_gpio_mode(GPIO34_TXENB | GPIO_OUT);
56 + set_GPIO(GPIO34_TXENB);
57 + pxa_gpio_mode(GPIO35_XRXD | GPIO_IN);
58 + pxa_gpio_mode(GPIO36_VMOUT | GPIO_IN);
59 + pxa_gpio_mode(GPIO40_VPIN | GPIO_IN);
60 + pxa_gpio_mode(GPIO39_FFTXD_MD);
61 + pxa_gpio_mode(GPIO53_FFRXD_MD);
62 + CKEN |= CKEN6_FFUART;
63 + clr_GPIO(GPIO_EMU_MUX1);
64 + clr_GPIO(GPIO_EMU_MUX2);
67 +EXPORT_SYMBOL(emu_switch_to_uart);
69 +void emu_switch_to_audio(int stereo)
71 + clr_GPIO(GPIO39_VPOUT);
73 + pxa_gpio_mode(GPIO34_USB_P2_2 | GPIO_IN);
74 + clr_GPIO(GPIO39_VPOUT);
76 + pxa_gpio_mode(GPIO34_TXENB | GPIO_OUT);
77 + set_GPIO(GPIO34_TXENB);
80 + pxa_gpio_mode(GPIO35_XRXD | GPIO_IN);
81 + pxa_gpio_mode(GPIO36_VMOUT | GPIO_IN);
82 + pxa_gpio_mode(GPIO39_VPOUT | GPIO_IN);
83 + pxa_gpio_mode(GPIO40_VPIN | GPIO_IN);
84 + pxa_gpio_mode(GPIO53_VMIN | GPIO_IN);
85 + set_GPIO(GPIO_EMU_MUX1);
87 + set_GPIO(GPIO_EMU_MUX2);
89 + clr_GPIO(GPIO_EMU_MUX2);
92 +void emu_switch_to_nothing(void)
94 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_VUSB_EN, 0);
95 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_RS232ENB, 1);
96 + pxa_gpio_mode(GPIO34_TXENB | GPIO_OUT);
97 + set_GPIO(GPIO34_TXENB);
98 + pxa_gpio_mode(GPIO35_XRXD | GPIO_IN);
99 + pxa_gpio_mode(GPIO36_VMOUT | GPIO_IN);
100 + pxa_gpio_mode(GPIO39_VPOUT | GPIO_IN);
101 + pxa_gpio_mode(GPIO40_VPIN | GPIO_IN);
102 + pxa_gpio_mode(GPIO53_VMIN | GPIO_IN);
106 +static irqreturn_t emu_irq(int irq, void *data)
108 + printk("emu_irq(%u) entered: ", irq);
111 + case EZX_IRQ_USB4V:
112 + printk("usb 4v\n");
113 + if(ezx_pcap_read_bit(SSP_PCAP_ADJ_BIT_PSTAT_USBDET_4V))
114 +#if defined CONFIG_PXA_EZX_EMU_USB
115 + emu_switch_to_usb();
116 +#elif defined CONFIG_PXA_EZX_EMU_UART
117 + emu_switch_to_uart();
119 + emu_switch_to_nothing();
122 + emu_switch_to_nothing();
124 + case EZX_IRQ_USB1V:
125 + printk("usb 1v\n");
128 + printk("unknown\n");
132 + return IRQ_HANDLED;
135 +static int __init ezx_emu_probe(struct platform_device *dev)
137 + printk("ezx_emu_probe entered!\n");
138 + pxa_gpio_mode(GPIO_SNP_INT_IN | GPIO_IN);
139 + pxa_gpio_mode(GPIO_EMU_MUX1 | GPIO_OUT);
140 + pxa_gpio_mode(GPIO_EMU_MUX2 | GPIO_OUT);
142 + request_irq(EZX_IRQ_USB4V, &emu_irq, SA_INTERRUPT, "usb 4v", NULL);
143 + request_irq(EZX_IRQ_USB1V, &emu_irq, SA_INTERRUPT, "usb 1v", NULL);
145 + pxa_set_udc_info(&ezx_udc_info);
147 +#if defined CONFIG_PXA_EZX_EMU_USB
148 + emu_switch_to_usb();
149 +#elif defined CONFIG_PXA_EZX_EMU_UART
150 + emu_switch_to_uart();
152 + emu_switch_to_nothing();
158 +static int ezx_emu_remove(struct platform_device *dev)
160 + free_irq(EZX_IRQ_USB4V, NULL);
161 + free_irq(EZX_IRQ_USB1V, NULL);
166 +/* USB Device Controller */
167 +static int udc_connected_status;
168 +static void ezx_udc_command(int cmd)
171 + case PXA2XX_UDC_CMD_DISCONNECT:
172 + printk(KERN_NOTICE "USB cmd disconnect\n");
173 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_USB_PU,0);
174 + udc_connected_status = 0;
176 + case PXA2XX_UDC_CMD_CONNECT:
177 + printk(KERN_NOTICE "USB cmd connect\n");
178 + ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_BUSCTRL_USB_PU,1);
179 + udc_connected_status = 1;
184 +static int ezx_udc_is_connected(void)
186 + return udc_connected_status;
189 +static struct pxa2xx_udc_mach_info ezx_udc_info __initdata = {
190 + .udc_is_connected = ezx_udc_is_connected,
191 + .udc_command = ezx_udc_command,
194 +static struct platform_driver ezxemu_driver = {
195 + .probe = ezx_emu_probe,
196 + .remove = ezx_emu_remove,
197 + //.suspend = ezx_emu_suspend,
198 + //.resume = ezx_emu_resume,
201 + .owner = THIS_MODULE,
205 +int __init ezx_emu_init(void)
207 + return platform_driver_register(&ezxemu_driver);
210 +void ezx_emu_fini(void)
212 + return platform_driver_unregister(&ezxemu_driver);
215 +module_init(ezx_emu_init);
216 +module_exit(ezx_emu_fini);
218 +MODULE_DESCRIPTION("Motorola Enchanced Mini Usb driver");
219 +MODULE_AUTHOR("Daniel Ribeiro <drwyrm@gmail.com>");
220 +MODULE_LICENSE("GPL");
221 Index: linux-2.6.20.7/arch/arm/mach-pxa/Kconfig
222 ===================================================================
223 --- linux-2.6.20.7.orig/arch/arm/mach-pxa/Kconfig 2007-04-21 12:32:50.000000000 -0300
224 +++ linux-2.6.20.7/arch/arm/mach-pxa/Kconfig 2007-04-21 12:32:54.000000000 -0300
230 + bool "Motorola Enchanced Mini Usb"
235 + prompt "Select default EMU mode"
237 +config PXA_EZX_EMU_USB
240 +config PXA_EZX_EMU_UART
243 +config PXA_EZX_EMU_NOTHING
253 Index: linux-2.6.20.7/arch/arm/mach-pxa/Makefile
254 ===================================================================
255 --- linux-2.6.20.7.orig/arch/arm/mach-pxa/Makefile 2007-04-21 12:32:50.000000000 -0300
256 +++ linux-2.6.20.7/arch/arm/mach-pxa/Makefile 2007-04-21 12:32:54.000000000 -0300
258 obj-$(CONFIG_MACH_POODLE) += poodle.o corgi_ssp.o
259 obj-$(CONFIG_MACH_TOSA) += tosa.o
260 obj-$(CONFIG_PXA_EZX) += ezx.o ezx_lcd.o ezx_ssp.o ezx-pcap.o ezx-mci.o
261 +obj-$(CONFIG_PXA_EZX_EMU) += ezx-emu.o
263 # Support for blinky lights
265 Index: linux-2.6.20.7/arch/arm/mach-pxa/ezx.c
266 ===================================================================
267 --- linux-2.6.20.7.orig/arch/arm/mach-pxa/ezx.c 2007-04-21 12:32:50.000000000 -0300
268 +++ linux-2.6.20.7/arch/arm/mach-pxa/ezx.c 2007-04-21 12:32:54.000000000 -0300
270 #include <asm/arch/ohci.h>
271 #include <asm/arch/pxa-regs.h>
276 #include <linux/tty.h>
278 .resource = ezxpcap_resources,
282 +static struct resource ezxemu_resources[] = {
284 + .start = EZX_IRQ_USB4V,
285 + .end = EZX_IRQ_USB4V,
286 + .flags = IORESOURCE_IRQ,
289 + .start = EZX_IRQ_USB1V,
290 + .end = EZX_IRQ_USB1V,
291 + .flags = IORESOURCE_IRQ,
295 +struct platform_device ezxemu_device = {
299 +// .parent = &ezxpcap_device.dev,
301 + .num_resources = ARRAY_SIZE(ezxemu_resources),
302 + .resource = ezxemu_resources,
305 /* OHCI Controller */
307 static int ezx_ohci_init(struct device *dev)
315 static void __init a780_init(void)
317 pxa_set_ohci_info(&ezx_ohci_platform_data);
319 platform_add_devices(devices, ARRAY_SIZE(devices));
322 +#if defined CONFIG_PXA_EZX_EMU_USB
323 + emu_switch_to_usb();
324 +#elif defined CONFIG_PXA_EZX_EMU_UART
325 + emu_switch_to_uart();
327 + emu_switch_to_nothing();
332 MACHINE_START(EZX, "Motorola Ezx Platform")