1 Index: linux-2.6.30-rc6/drivers/usb/gadget/s3c2410_udc.c
2 ===================================================================
3 --- linux-2.6.30-rc6.orig/drivers/usb/gadget/s3c2410_udc.c 2009-05-16 06:12:57.000000000 +0200
4 +++ linux-2.6.30-rc6/drivers/usb/gadget/s3c2410_udc.c 2009-05-18 19:08:35.000000000 +0200
8 static struct dentry *s3c2410_udc_debugfs_root;
9 +static struct timer_list vbus_poll_timer;
11 static inline u32 udc_read(u32 reg)
18 +#ifdef CONFIG_USB_GADGET_DEBUG_FS
19 static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p)
21 u32 addr_reg,pwr_reg,ep_int_reg,usb_int_reg;
23 .release = single_release,
35 if (likely (!list_empty(&ep->queue)))
36 req = list_entry(ep->queue.next,
37 struct s3c2410_request, queue);
40 if ((ep_csr1 & S3C2410_UDC_OCSR1_PKTRDY) && req) {
41 s3c2410_udc_read_fifo(ep,req);
42 + if (s3c2410_udc_fifo_count_out())
43 + goto handle_ep_again;
47 @@ -1520,6 +1527,20 @@
51 +static void s3c2410_udc_vbus_poll(unsigned long _data)
53 + struct s3c2410_udc *data = (struct s3c2410_udc *)_data;
56 + dprintk(DEBUG_NORMAL, "%s()\n", __func__);
57 + if (udc_info && udc_info->get_vbus_status) {
58 + v = udc_info->get_vbus_status();
59 + if ((v > -1) && (v != data->vbus))
60 + s3c2410_udc_vbus_session(&data->gadget, v);
61 + mod_timer(&vbus_poll_timer, jiffies + msecs_to_jiffies(900));
65 static int s3c2410_vbus_draw(struct usb_gadget *_gadget, unsigned ma)
67 dprintk(DEBUG_NORMAL, "%s()\n", __func__);
68 @@ -1677,6 +1698,11 @@
72 + if (udc_info && udc_info->get_vbus_status && !udc_info->vbus_pin) {
73 + mod_timer(&vbus_poll_timer, jiffies + msecs_to_jiffies(50));
74 + return 0; /* just return, vbus change will enable udc */
78 s3c2410_udc_enable(udc);
81 if (driver->disconnect)
82 driver->disconnect(&udc->gadget);
84 + driver->unbind(&udc->gadget);
85 device_del(&udc->gadget.dev);
88 @@ -1893,10 +1920,16 @@
91 dev_dbg(dev, "got irq %i\n", irq);
92 + } else if (udc_info && udc_info->get_vbus_status) {
94 + init_timer(&vbus_poll_timer);
95 + vbus_poll_timer.function = s3c2410_udc_vbus_poll;
96 + vbus_poll_timer.data = (unsigned long) udc;
101 +#ifdef CONFIG_USB_GADGET_DEBUG_FS
102 if (s3c2410_udc_debugfs_root) {
103 udc->regs_info = debugfs_create_file("registers", S_IRUGO,
104 s3c2410_udc_debugfs_root,
105 @@ -1904,6 +1937,7 @@
107 dev_warn(dev, "debugfs file creation failed\n");
111 dev_dbg(dev, "probe ok\n");
113 @@ -1939,6 +1973,8 @@
114 if (udc_info && udc_info->vbus_pin > 0) {
115 irq = gpio_to_irq(udc_info->vbus_pin);
117 + } else if (udc_info && udc_info->get_vbus_status) {
118 + del_timer_sync(&vbus_poll_timer);
121 free_irq(IRQ_USBD, udc);
122 @@ -2013,12 +2049,14 @@
124 dprintk(DEBUG_NORMAL, "%s: version %s\n", gadget_name, DRIVER_VERSION);
126 +#ifdef CONFIG_USB_GADGET_DEBUG_FS
127 s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, NULL);
128 if (IS_ERR(s3c2410_udc_debugfs_root)) {
129 printk(KERN_ERR "%s: debugfs dir creation failed %ld\n",
130 gadget_name, PTR_ERR(s3c2410_udc_debugfs_root));
131 s3c2410_udc_debugfs_root = NULL;
135 retval = platform_driver_register(&udc_driver_2410);
137 Index: linux-2.6.30-rc6/drivers/usb/host/ohci-s3c2410.c
138 ===================================================================
139 --- linux-2.6.30-rc6.orig/drivers/usb/host/ohci-s3c2410.c 2009-05-16 06:12:57.000000000 +0200
140 +++ linux-2.6.30-rc6/drivers/usb/host/ohci-s3c2410.c 2009-05-18 19:08:35.000000000 +0200
143 #include <linux/platform_device.h>
144 #include <linux/clk.h>
145 +#include <mach/hardware.h>
146 +#include <mach/regs-gpio.h>
147 #include <plat/usb-control.h>
149 #define valid_port(idx) ((idx) == 1 || (idx) == 2)
151 local_irq_restore(flags);
154 +/* switching of USB pads */
155 +static ssize_t show_usb_mode(struct device *dev, struct device_attribute *attr,
158 + if (__raw_readl(S3C24XX_MISCCR) & S3C2410_MISCCR_USBHOST)
159 + return sprintf(buf, "host\n");
161 + return sprintf(buf, "device\n");
164 +static ssize_t set_usb_mode(struct device *dev, struct device_attribute *attr,
165 + const char *buf, size_t count)
167 + if (!strncmp(buf, "host", 4)) {
168 + printk(KERN_WARNING "s3c2410: changing usb to host\n");
169 + s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST,
170 + S3C2410_MISCCR_USBHOST);
172 + * - call machine-specific disable-pullup function i
173 + * - enable +Vbus (if hardware supports it)
175 + s3c2410_gpio_setpin(S3C2410_GPB9, 0);
176 + } else if (!strncmp(buf, "device", 6)) {
177 + printk(KERN_WARNING "s3c2410: changing usb to device\n");
178 + s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST, 0);
179 + s3c2410_gpio_setpin(S3C2410_GPB9, 1);
181 + printk(KERN_WARNING "s3c2410: unknown mode\n");
188 +static DEVICE_ATTR(usb_mode, S_IRUGO | S_IWUSR, show_usb_mode, set_usb_mode);
190 /* may be called without controller electrically present */
191 /* may be called with controller, bus, and devices active */
193 @@ -486,15 +524,23 @@
197 +static int ohci_hcd_s3c2410_drv_resume(struct platform_device *pdev)
199 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
201 + ohci_finish_controller_resume(hcd);
205 static struct platform_driver ohci_hcd_s3c2410_driver = {
206 .probe = ohci_hcd_s3c2410_drv_probe,
207 .remove = ohci_hcd_s3c2410_drv_remove,
208 .shutdown = usb_hcd_platform_shutdown,
209 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */
210 - /*.resume = ohci_hcd_s3c2410_drv_resume, */
211 + .resume = ohci_hcd_s3c2410_drv_resume,
213 .owner = THIS_MODULE,
214 - .name = "s3c2410-ohci",
215 + .name = "s3c-ohci",
219 Index: linux-2.6.30-rc6/arch/arm/plat-s3c24xx/include/plat/udc.h
220 ===================================================================
221 --- linux-2.6.30-rc6.orig/arch/arm/plat-s3c24xx/include/plat/udc.h 2009-05-16 06:12:57.000000000 +0200
222 +++ linux-2.6.30-rc6/arch/arm/plat-s3c24xx/include/plat/udc.h 2009-05-18 19:08:35.000000000 +0200
224 struct s3c2410_udc_mach_info {
225 void (*udc_command)(enum s3c2410_udc_cmd_e);
226 void (*vbus_draw)(unsigned int ma);
227 + int (*get_vbus_status)(void);
228 unsigned int vbus_pin;
229 unsigned char vbus_pin_inverted;