Loading drivers/usb/gadget/omap_udc.c +121 −80 Original line number Diff line number Diff line Loading @@ -36,9 +36,9 @@ #include <linux/dma-mapping.h> #include <linux/clk.h> #include <linux/prefetch.h> #include <linux/io.h> #include <asm/byteorder.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/unaligned.h> #include <asm/mach-types.h> Loading Loading @@ -84,7 +84,7 @@ #ifdef USE_ISO static unsigned fifo_mode = 3; #else static unsigned fifo_mode = 0; static unsigned fifo_mode; #endif /* "modprobe omap_udc fifo_mode=42", or else as a kernel Loading Loading @@ -361,10 +361,10 @@ write_packet(u8 *buf, struct omap_req *req, unsigned max) return len; } // FIXME change r/w fifo calling convention /* FIXME change r/w fifo calling convention */ // return: 0 = still running, 1 = completed, negative = errno /* return: 0 = still running, 1 = completed, negative = errno */ static int write_fifo(struct omap_ep *ep, struct omap_req *req) { u8 *buf; Loading Loading @@ -426,7 +426,7 @@ read_packet(u8 *buf, struct omap_req *req, unsigned avail) return len; } // return: 0 = still running, 1 = queue empty, negative = errno /* return: 0 = still running, 1 = queue empty, negative = errno */ static int read_fifo(struct omap_ep *ep, struct omap_req *req) { u8 *buf; Loading Loading @@ -981,7 +981,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) * always an IN ... even for IN transfers, * a weird case which seem to stall OMAP. */ omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); omap_writew(UDC_CLR_EP, UDC_CTRL); omap_writew(UDC_SET_FIFO_EN, UDC_CTRL); omap_writew(UDC_EP_DIR, UDC_EP_NUM); Loading @@ -993,7 +994,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) /* non-empty DATA stage */ } else if (is_in) { omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); } else { if (udc->ep0_setup) goto irq_wait; Loading Loading @@ -1148,8 +1150,8 @@ static struct usb_ep_ops omap_ep_ops = { .dequeue = omap_ep_dequeue, .set_halt = omap_ep_set_halt, // fifo_status ... report bytes in fifo // fifo_flush ... flush fifo /* fifo_status ... report bytes in fifo */ /* fifo_flush ... flush fifo */ }; /*-------------------------------------------------------------------------*/ Loading Loading @@ -1495,7 +1497,8 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src) /* read next OUT packet of request, maybe * reactiviting the fifo; stall on errors. */ if (!req || (stat = read_fifo(ep0, req)) < 0) { stat = read_fifo(ep0, req); if (!req || stat < 0) { omap_writew(UDC_STALL_CMD, UDC_SYSCON2); udc->ep0_pending = 0; stat = 0; Loading Loading @@ -1764,7 +1767,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) VDBG("connect\n"); if (!udc->transceiver) pullup_enable(udc); // if (driver->connect) call it /* if (driver->connect) call it */ } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { udc->gadget.speed = USB_SPEED_UNKNOWN; if (!udc->transceiver) Loading Loading @@ -1796,7 +1799,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) } if (change & UDC_SUS) { if (udc->gadget.speed != USB_SPEED_UNKNOWN) { // FIXME tell isp1301 to suspend/resume (?) /* FIXME tell isp1301 to suspend/resume (?) */ if (devstat & UDC_SUS) { VDBG("suspend\n"); update_otg(udc); Loading Loading @@ -2058,11 +2061,11 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev) static inline int machine_without_vbus_sense(void) { return (machine_is_omap_innovator() return machine_is_omap_innovator() || machine_is_omap_osk() || machine_is_sx1() || cpu_is_omap7xx() /* No known omap7xx boards with vbus sense */ ); /* No known omap7xx boards with vbus sense */ || cpu_is_omap7xx(); } static int omap_udc_start(struct usb_gadget_driver *driver, Loading @@ -2076,7 +2079,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, if (!udc) return -ENODEV; if (!driver // FIXME if otg, check: driver->is_otg /* FIXME if otg, check: driver->is_otg */ || driver->max_speed < USB_SPEED_FULL || !bind || !driver->setup) return -EINVAL; Loading Loading @@ -2195,7 +2198,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) static const char proc_filename[] = "driver/udc"; #define FOURBITS "%s%s%s%s" #define EIGHTBITS FOURBITS FOURBITS #define EIGHTBITS "%s%s%s%s%s%s%s%s" static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) { Loading @@ -2217,11 +2220,20 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) "\n%s %s%s%sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n", ep->name, buf, ep->double_buf ? "dbuf " : "", ({char *s; switch(ep->ackwait){ case 0: s = ""; break; case 1: s = "(ackw) "; break; case 2: s = "(ackw2) "; break; default: s = "(?) "; break; ({ char *s; switch (ep->ackwait) { case 0: s = ""; break; case 1: s = "(ackw) "; break; case 2: s = "(ackw2) "; break; default: s = "(?) "; break; } s; }), ep->irqs, stat_flg, (stat_flg & UDC_NO_RXPACKET) ? "no_rxpacket " : "", Loading Loading @@ -2259,11 +2271,16 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) static char *trx_mode(unsigned m, int enabled) { switch (m) { case 0: return enabled ? "*6wire" : "unused"; case 1: return "4wire"; case 2: return "3wire"; case 3: return "6wire"; default: return "unknown"; case 0: return enabled ? "*6wire" : "unused"; case 1: return "4wire"; case 2: return "3wire"; case 3: return "6wire"; default: return "unknown"; } } Loading Loading @@ -2295,7 +2312,7 @@ static int proc_otg_show(struct seq_file *s) " b_ase_brst=%d hmc=%d\n", tmp, (tmp & OTG_EN) ? " otg_en" : "", (tmp & USBX_SYNCHRO) ? " synchro" : "", // much more SRP stuff /* much more SRP stuff */ (tmp & SRP_DATA) ? " srp_data" : "", (tmp & SRP_VBUS) ? " srp_vbus" : "", (tmp & OTG_PADEN) ? " otg_paden" : "", Loading Loading @@ -2383,7 +2400,7 @@ static int proc_udc_show(struct seq_file *s, void *_) (tmp & UDC_SELF_PWR) ? " self_pwr" : "", (tmp & UDC_SOFF_DIS) ? " soff_dis" : "", (tmp & UDC_PULLUP_EN) ? " PULLUP" : ""); // syscon2 is write-only /* syscon2 is write-only */ /* UDC controller registers */ if (!(tmp & UDC_PULLUP_EN)) { Loading Loading @@ -2536,14 +2553,29 @@ omap_ep_setup(char *name, u8 addr, u8 type, /* chip setup ... bit values are same for IN, OUT */ if (type == USB_ENDPOINT_XFER_ISOC) { switch (maxp) { case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; case 128: epn_rxtx = 4 << 12; break; case 256: epn_rxtx = 5 << 12; break; case 512: epn_rxtx = 6 << 12; break; default: BUG(); case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; case 128: epn_rxtx = 4 << 12; break; case 256: epn_rxtx = 5 << 12; break; case 512: epn_rxtx = 6 << 12; break; default: BUG(); } epn_rxtx |= UDC_EPN_RX_ISO; dbuf = 1; Loading @@ -2556,11 +2588,20 @@ omap_ep_setup(char *name, u8 addr, u8 type, dbuf = 0; switch (maxp) { case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; default: BUG(); case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; default: BUG(); } if (dbuf && addr) epn_rxtx |= UDC_EPN_RX_DB; Loading Loading @@ -2626,7 +2667,7 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) omap_writew(0, UDC_TXDMA_CFG); /* UDC_PULLUP_EN gates the chip clock */ // OTG_SYSCON_1 |= DEV_IDLE_EN; /* OTG_SYSCON_1 |= DEV_IDLE_EN; */ udc = kzalloc(sizeof(*udc), GFP_KERNEL); if (!udc) Loading Loading @@ -2869,11 +2910,11 @@ static int __init omap_udc_probe(struct platform_device *pdev) /* a "gadget" abstracts/virtualizes the controller */ status = omap_udc_setup(pdev, xceiv); if (status) { if (status) goto cleanup0; } xceiv = NULL; // "udc" is now valid /* "udc" is now valid */ pullup_disable(udc); #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) udc->gadget.is_otg = (config->otg != 0); Loading @@ -2887,7 +2928,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) /* USB general purpose IRQ: ep0, state changes, dma, etc */ status = request_irq(pdev->resource[1].start, omap_udc_irq, IRQF_SAMPLE_RANDOM, driver_name, udc); 0, driver_name, udc); if (status != 0) { ERR("can't get irq %d, err %d\n", (int) pdev->resource[1].start, status); Loading @@ -2896,7 +2937,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) /* USB "non-iso" IRQ (PIO for all but ep0) */ status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, IRQF_SAMPLE_RANDOM, "omap_udc pio", udc); 0, "omap_udc pio", udc); if (status != 0) { ERR("can't get irq %d, err %d\n", (int) pdev->resource[2].start, status); Loading Loading
drivers/usb/gadget/omap_udc.c +121 −80 Original line number Diff line number Diff line Loading @@ -36,9 +36,9 @@ #include <linux/dma-mapping.h> #include <linux/clk.h> #include <linux/prefetch.h> #include <linux/io.h> #include <asm/byteorder.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/unaligned.h> #include <asm/mach-types.h> Loading Loading @@ -84,7 +84,7 @@ #ifdef USE_ISO static unsigned fifo_mode = 3; #else static unsigned fifo_mode = 0; static unsigned fifo_mode; #endif /* "modprobe omap_udc fifo_mode=42", or else as a kernel Loading Loading @@ -361,10 +361,10 @@ write_packet(u8 *buf, struct omap_req *req, unsigned max) return len; } // FIXME change r/w fifo calling convention /* FIXME change r/w fifo calling convention */ // return: 0 = still running, 1 = completed, negative = errno /* return: 0 = still running, 1 = completed, negative = errno */ static int write_fifo(struct omap_ep *ep, struct omap_req *req) { u8 *buf; Loading Loading @@ -426,7 +426,7 @@ read_packet(u8 *buf, struct omap_req *req, unsigned avail) return len; } // return: 0 = still running, 1 = queue empty, negative = errno /* return: 0 = still running, 1 = queue empty, negative = errno */ static int read_fifo(struct omap_ep *ep, struct omap_req *req) { u8 *buf; Loading Loading @@ -981,7 +981,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) * always an IN ... even for IN transfers, * a weird case which seem to stall OMAP. */ omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); omap_writew(UDC_CLR_EP, UDC_CTRL); omap_writew(UDC_SET_FIFO_EN, UDC_CTRL); omap_writew(UDC_EP_DIR, UDC_EP_NUM); Loading @@ -993,7 +994,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) /* non-empty DATA stage */ } else if (is_in) { omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); } else { if (udc->ep0_setup) goto irq_wait; Loading Loading @@ -1148,8 +1150,8 @@ static struct usb_ep_ops omap_ep_ops = { .dequeue = omap_ep_dequeue, .set_halt = omap_ep_set_halt, // fifo_status ... report bytes in fifo // fifo_flush ... flush fifo /* fifo_status ... report bytes in fifo */ /* fifo_flush ... flush fifo */ }; /*-------------------------------------------------------------------------*/ Loading Loading @@ -1495,7 +1497,8 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src) /* read next OUT packet of request, maybe * reactiviting the fifo; stall on errors. */ if (!req || (stat = read_fifo(ep0, req)) < 0) { stat = read_fifo(ep0, req); if (!req || stat < 0) { omap_writew(UDC_STALL_CMD, UDC_SYSCON2); udc->ep0_pending = 0; stat = 0; Loading Loading @@ -1764,7 +1767,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) VDBG("connect\n"); if (!udc->transceiver) pullup_enable(udc); // if (driver->connect) call it /* if (driver->connect) call it */ } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { udc->gadget.speed = USB_SPEED_UNKNOWN; if (!udc->transceiver) Loading Loading @@ -1796,7 +1799,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) } if (change & UDC_SUS) { if (udc->gadget.speed != USB_SPEED_UNKNOWN) { // FIXME tell isp1301 to suspend/resume (?) /* FIXME tell isp1301 to suspend/resume (?) */ if (devstat & UDC_SUS) { VDBG("suspend\n"); update_otg(udc); Loading Loading @@ -2058,11 +2061,11 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev) static inline int machine_without_vbus_sense(void) { return (machine_is_omap_innovator() return machine_is_omap_innovator() || machine_is_omap_osk() || machine_is_sx1() || cpu_is_omap7xx() /* No known omap7xx boards with vbus sense */ ); /* No known omap7xx boards with vbus sense */ || cpu_is_omap7xx(); } static int omap_udc_start(struct usb_gadget_driver *driver, Loading @@ -2076,7 +2079,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, if (!udc) return -ENODEV; if (!driver // FIXME if otg, check: driver->is_otg /* FIXME if otg, check: driver->is_otg */ || driver->max_speed < USB_SPEED_FULL || !bind || !driver->setup) return -EINVAL; Loading Loading @@ -2195,7 +2198,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) static const char proc_filename[] = "driver/udc"; #define FOURBITS "%s%s%s%s" #define EIGHTBITS FOURBITS FOURBITS #define EIGHTBITS "%s%s%s%s%s%s%s%s" static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) { Loading @@ -2217,11 +2220,20 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) "\n%s %s%s%sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n", ep->name, buf, ep->double_buf ? "dbuf " : "", ({char *s; switch(ep->ackwait){ case 0: s = ""; break; case 1: s = "(ackw) "; break; case 2: s = "(ackw2) "; break; default: s = "(?) "; break; ({ char *s; switch (ep->ackwait) { case 0: s = ""; break; case 1: s = "(ackw) "; break; case 2: s = "(ackw2) "; break; default: s = "(?) "; break; } s; }), ep->irqs, stat_flg, (stat_flg & UDC_NO_RXPACKET) ? "no_rxpacket " : "", Loading Loading @@ -2259,11 +2271,16 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) static char *trx_mode(unsigned m, int enabled) { switch (m) { case 0: return enabled ? "*6wire" : "unused"; case 1: return "4wire"; case 2: return "3wire"; case 3: return "6wire"; default: return "unknown"; case 0: return enabled ? "*6wire" : "unused"; case 1: return "4wire"; case 2: return "3wire"; case 3: return "6wire"; default: return "unknown"; } } Loading Loading @@ -2295,7 +2312,7 @@ static int proc_otg_show(struct seq_file *s) " b_ase_brst=%d hmc=%d\n", tmp, (tmp & OTG_EN) ? " otg_en" : "", (tmp & USBX_SYNCHRO) ? " synchro" : "", // much more SRP stuff /* much more SRP stuff */ (tmp & SRP_DATA) ? " srp_data" : "", (tmp & SRP_VBUS) ? " srp_vbus" : "", (tmp & OTG_PADEN) ? " otg_paden" : "", Loading Loading @@ -2383,7 +2400,7 @@ static int proc_udc_show(struct seq_file *s, void *_) (tmp & UDC_SELF_PWR) ? " self_pwr" : "", (tmp & UDC_SOFF_DIS) ? " soff_dis" : "", (tmp & UDC_PULLUP_EN) ? " PULLUP" : ""); // syscon2 is write-only /* syscon2 is write-only */ /* UDC controller registers */ if (!(tmp & UDC_PULLUP_EN)) { Loading Loading @@ -2536,14 +2553,29 @@ omap_ep_setup(char *name, u8 addr, u8 type, /* chip setup ... bit values are same for IN, OUT */ if (type == USB_ENDPOINT_XFER_ISOC) { switch (maxp) { case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; case 128: epn_rxtx = 4 << 12; break; case 256: epn_rxtx = 5 << 12; break; case 512: epn_rxtx = 6 << 12; break; default: BUG(); case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; case 128: epn_rxtx = 4 << 12; break; case 256: epn_rxtx = 5 << 12; break; case 512: epn_rxtx = 6 << 12; break; default: BUG(); } epn_rxtx |= UDC_EPN_RX_ISO; dbuf = 1; Loading @@ -2556,11 +2588,20 @@ omap_ep_setup(char *name, u8 addr, u8 type, dbuf = 0; switch (maxp) { case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; default: BUG(); case 8: epn_rxtx = 0 << 12; break; case 16: epn_rxtx = 1 << 12; break; case 32: epn_rxtx = 2 << 12; break; case 64: epn_rxtx = 3 << 12; break; default: BUG(); } if (dbuf && addr) epn_rxtx |= UDC_EPN_RX_DB; Loading Loading @@ -2626,7 +2667,7 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) omap_writew(0, UDC_TXDMA_CFG); /* UDC_PULLUP_EN gates the chip clock */ // OTG_SYSCON_1 |= DEV_IDLE_EN; /* OTG_SYSCON_1 |= DEV_IDLE_EN; */ udc = kzalloc(sizeof(*udc), GFP_KERNEL); if (!udc) Loading Loading @@ -2869,11 +2910,11 @@ static int __init omap_udc_probe(struct platform_device *pdev) /* a "gadget" abstracts/virtualizes the controller */ status = omap_udc_setup(pdev, xceiv); if (status) { if (status) goto cleanup0; } xceiv = NULL; // "udc" is now valid /* "udc" is now valid */ pullup_disable(udc); #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) udc->gadget.is_otg = (config->otg != 0); Loading @@ -2887,7 +2928,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) /* USB general purpose IRQ: ep0, state changes, dma, etc */ status = request_irq(pdev->resource[1].start, omap_udc_irq, IRQF_SAMPLE_RANDOM, driver_name, udc); 0, driver_name, udc); if (status != 0) { ERR("can't get irq %d, err %d\n", (int) pdev->resource[1].start, status); Loading @@ -2896,7 +2937,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) /* USB "non-iso" IRQ (PIO for all but ep0) */ status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, IRQF_SAMPLE_RANDOM, "omap_udc pio", udc); 0, "omap_udc pio", udc); if (status != 0) { ERR("can't get irq %d, err %d\n", (int) pdev->resource[2].start, status); Loading