Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/:drivers/usb/host/fusbh200-hcd.c b/:drivers/usb/host/fotg210-hcd.c
- index 3536515..000ed80 100644
- --- a/:drivers/usb/host/fusbh200-hcd.c
- +++ b/:drivers/usb/host/fotg210-hcd.c
- @@ -44,9 +44,9 @@
- #include <linux/slab.h>
- #include <linux/uaccess.h>
- #include <linux/platform_device.h>
- +#include <linux/io.h>
- #include <asm/byteorder.h>
- -#include <asm/io.h>
- #include <asm/irq.h>
- #include <asm/unaligned.h>
- @@ -58,6 +58,8 @@ static const char hcd_name[] = "fotg210_hcd";
- #undef FOTG210_URB_TRACE
- +#define FOTG210_STATS
- +
- /* magic numbers that can affect system performance */
- #define FOTG210_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
- #define FOTG210_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
- @@ -73,12 +75,12 @@ static const char hcd_name[] = "fotg210_hcd";
- #define FOTG210_TUNE_FLS 1 /* (medium) 512-frame schedule */
- /* Initial IRQ latency: faster than hw default */
- -static int log2_irq_thresh = 0; /* 0 to 6 */
- +static int log2_irq_thresh; /* 0 to 6 */
- module_param(log2_irq_thresh, int, S_IRUGO);
- MODULE_PARM_DESC(log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
- /* initial park setting: slower than hw default */
- -static unsigned park = 0;
- +static unsigned park;
- module_param(park, uint, S_IRUGO);
- MODULE_PARM_DESC(park, "park setting; 1-3 back-to-back async packets");
- @@ -245,8 +247,8 @@ dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
- );
- }
- -static int
- -dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
- +static char
- +*dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
- {
- char *sig;
- @@ -266,7 +268,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
- break;
- }
- - return scnprintf(buf, len,
- + scnprintf(buf, len,
- "%s%sport:%d status %06x %d "
- "sig=%s%s%s%s%s%s%s%s",
- label, label[0] ? " " : "", port, status,
- @@ -279,6 +281,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
- (status & PORT_PE) ? " PE" : "",
- (status & PORT_CSC) ? " CSC" : "",
- (status & PORT_CONNECT) ? " CONNECT" : "");
- + return buf;
- }
- /* functions have the "wrong" filename when they're output... */
- @@ -296,8 +299,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
- #define dbg_port(fotg210, label, port, status) { \
- char _buf[80]; \
- - dbg_port_buf(_buf, sizeof(_buf), label, port, status); \
- - fotg210_dbg(fotg210, "%s\n", _buf); \
- + fotg210_dbg(fotg210, "%s\n", dbg_port_buf(_buf, sizeof(_buf), label, port, status) ); \
- }
- /*-------------------------------------------------------------------------*/
- @@ -666,8 +668,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
- unsigned long flags;
- unsigned temp, size, i;
- char *next, scratch[80];
- - static char fmt[] = "%*s\n";
- - static char label[] = "";
- + static const char fmt[] = "%*s\n";
- + static const char label[] = "";
- hcd = bus_to_hcd(buf->bus);
- fotg210 = hcd_to_fotg210(hcd);
- @@ -743,6 +745,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
- next += temp;
- }
- +#ifdef FOTG210_STATS
- temp = scnprintf(next, size,
- "irq normal %ld err %ld iaa %ld(lost %ld)\n",
- fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa,
- @@ -754,6 +757,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
- fotg210->stats.complete, fotg210->stats.unlink);
- size -= temp;
- next += temp;
- +#endif
- done:
- spin_unlock_irqrestore(&fotg210->lock, flags);
- @@ -1588,6 +1592,7 @@ static int fotg210_hub_control(
- if ((temp & PORT_PE) == 0)
- goto error;
- + /* resume signaling for 20 msec */
- fotg210_writel(fotg210, temp | PORT_RESUME, status_reg);
- fotg210->reset_done[wIndex] = jiffies
- + msecs_to_jiffies(USB_RESUME_TIMEOUT);
- @@ -1599,8 +1604,8 @@ static int fotg210_hub_control(
- fotg210_writel(fotg210, temp | PORT_CSC, status_reg);
- break;
- case USB_PORT_FEAT_C_OVER_CURRENT:
- - fotg210_writel(fotg210, temp | BMISR_OVC,
- - &fotg210->regs->bmisr);
- + fotg210_writel(fotg210, temp | OTGISR_OVC,
- + &fotg210->regs->otgisr);
- break;
- case USB_PORT_FEAT_C_RESET:
- /* GetPortStatus clears reset */
- @@ -1632,8 +1637,8 @@ static int fotg210_hub_control(
- if (temp & PORT_PEC)
- status |= USB_PORT_STAT_C_ENABLE << 16;
- - temp1 = fotg210_readl(fotg210, &fotg210->regs->bmisr);
- - if (temp1 & BMISR_OVC)
- + temp1 = fotg210_readl(fotg210, &fotg210->regs->otgisr);
- + if (temp1 & OTGISR_OVC)
- status |= USB_PORT_STAT_C_OVERCURRENT << 16;
- /* whoever resumes must GetPortStatus to complete it!! */
- @@ -1741,8 +1746,8 @@ static int fotg210_hub_control(
- set_bit(wIndex, &fotg210->port_c_suspend);
- }
- - temp1 = fotg210_readl(fotg210, &fotg210->regs->bmisr);
- - if (temp1 & BMISR_OVC)
- + temp1 = fotg210_readl(fotg210, &fotg210->regs->otgisr);
- + if (temp1 & OTGISR_OVC)
- status |= USB_PORT_STAT_OVERCURRENT;
- if (temp & PORT_RESET)
- status |= USB_PORT_STAT_RESET;
- @@ -5111,11 +5116,13 @@ static void fotg210_stop(struct usb_hcd *hcd)
- spin_unlock_irq(&fotg210->lock);
- fotg210_mem_cleanup(fotg210);
- +#ifdef FOTG210_STATS
- fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
- fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa,
- fotg210->stats.lost_iaa);
- fotg210_dbg(fotg210, "complete %ld unlink %ld\n",
- fotg210->stats.complete, fotg210->stats.unlink);
- +#endif
- dbg_status(fotg210, "fotg210_stop completed",
- fotg210_readl(fotg210, &fotg210->regs->status));
- @@ -5209,7 +5216,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
- * make problems: throughput reduction (!), data errors...
- */
- if (park) {
- - park = min(park,(unsigned) 3);
- + park = min_t(unsigned, park, 3);
- temp |= CMD_PARK;
- temp |= park << 8;
- }
- @@ -5376,6 +5383,11 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
- cmd = fotg210_readl(fotg210, &fotg210->regs->command);
- bh = 0;
- + /* unrequested/ignored: Frame List Rollover */
- + dbg_status(fotg210, "irq", status);
- +
- + /* INT, ERR, and IAA interrupt rates can be throttled */
- +
- /* normal [4.15.1.2] or error [4.15.1.1] completion */
- if (likely((status & (STS_INT|STS_ERR)) != 0)) {
- if (likely((status & STS_ERR) == 0))
- @@ -5776,16 +5788,15 @@ static const struct hc_driver fotg210_fotg210_hc_driver = {
- static void fotg210_init(struct fotg210_hcd *fotg210)
- {
- - u32 reg;
- + u32 value;
- - reg = fotg210_readl(fotg210, &fotg210->regs->bmcsr);
- - reg |= BMCSR_INT_POLARITY;
- - reg &= ~BMCSR_VBUS_OFF;
- - fotg210_writel(fotg210, reg, &fotg210->regs->bmcsr);
- + iowrite32(GMIR_MDEV_INT | GMIR_MOTG_INT | GMIR_INT_POLARITY,
- + &fotg210->regs->gmir);
- - reg = fotg210_readl(fotg210, &fotg210->regs->bmier);
- - fotg210_writel(fotg210, reg | BMIER_OVC_EN | BMIER_VBUS_ERR_EN,
- - &fotg210->regs->bmier);
- + value = ioread32(&fotg210->regs->otgcsr);
- + value &= ~OTGCSR_A_BUS_DROP;
- + value |= OTGCSR_A_BUS_REQ;
- + iowrite32(value, &fotg210->regs->otgcsr);
- }
- /**
- @@ -5827,41 +5838,17 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
- goto fail_create_hcd;
- }
- + hcd->has_tt = 1;
- +
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- - if (!res) {
- - dev_err(dev,
- - "Found HC with no register addr. Check %s setup!\n",
- - dev_name(dev));
- - retval = -ENODEV;
- - goto fail_request_resource;
- + hcd->regs = devm_ioremap_resource(&pdev->dev, res);
- + if (IS_ERR(hcd->regs)) {
- + retval = PTR_ERR(hcd->regs);
- + goto failed;
- }
- hcd->rsrc_start = res->start;
- hcd->rsrc_len = resource_size(res);
- - hcd->has_tt = 1;
- -
- - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
- - fotg210_fotg210_hc_driver.description)) {
- - dev_dbg(dev, "controller already in use\n");
- - retval = -EBUSY;
- - goto fail_request_resource;
- - }
- -
- - res = platform_get_resource(pdev, IORESOURCE_IO, 0);
- - if (!res) {
- - dev_err(dev,
- - "Found HC with no register addr. Check %s setup!\n",
- - dev_name(dev));
- - retval = -ENODEV;
- - goto fail_request_resource;
- - }
- -
- - hcd->regs = ioremap_nocache(res->start, resource_size(res));
- - if (hcd->regs == NULL) {
- - dev_dbg(dev, "error mapping memory\n");
- - retval = -EFAULT;
- - goto fail_ioremap;
- - }
- fotg210 = hcd_to_fotg210(hcd);
- @@ -5869,24 +5856,20 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
- retval = fotg210_setup(hcd);
- if (retval)
- - goto fail_add_hcd;
- + goto failed;
- fotg210_init(fotg210);
- retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
- if (retval) {
- dev_err(dev, "failed to add hcd with err %d\n", retval);
- - goto fail_add_hcd;
- + goto failed;
- }
- device_wakeup_enable(hcd->self.controller);
- return retval;
- -fail_add_hcd:
- - iounmap(hcd->regs);
- -fail_ioremap:
- - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
- -fail_request_resource:
- +failed:
- usb_put_hcd(hcd);
- fail_create_hcd:
- dev_err(dev, "init %s fail, %d\n", dev_name(dev), retval);
- @@ -5897,9 +5880,6 @@ fail_create_hcd:
- * fotg210_hcd_remove - shutdown processing for EHCI HCDs
- * @dev: USB Host Controller being removed
- *
- - * Reverses the effect of fotg2xx_usb_hcd_probe(), first invoking
- - * the HCD's stop() method. It is always called from a thread
- - * context, normally "rmmod", "apmd", or something similar.
- */
- static int fotg210_hcd_remove(struct platform_device *pdev)
- {
- @@ -5910,8 +5890,6 @@ static int fotg210_hcd_remove(struct platform_device *pdev)
- return 0;
- usb_remove_hcd(hcd);
- - iounmap(hcd->regs);
- - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
- usb_put_hcd(hcd);
- return 0;
- diff --git a/:drivers/usb/host/fusbh200.h b/:drivers/usb/host/fotg210.h
- index 54efa22..3bad178 100644
- --- a/:drivers/usb/host/fusbh200.h
- +++ b/:drivers/usb/host/fotg210.h
- @@ -168,8 +168,12 @@ struct fotg210_hcd { /* one per controller */
- u8 sbrn; /* packed release number */
- /* irq statistics */
- +#ifdef FOTG210_STATS
- struct fotg210_stats stats;
- -# define COUNT(x) do { (x)++; } while (0)
- +# define COUNT(x) ((x)++)
- +#else
- +# define COUNT(x)
- +#endif
- /* debug files */
- struct dentry *debug_dir;
- @@ -269,22 +273,26 @@ struct fotg210_regs {
- #define PORT_CSC (1<<1) /* connect status change */
- #define PORT_CONNECT (1<<0) /* device connected */
- #define PORT_RWC_BITS (PORT_CSC | PORT_PEC)
- - u32 reserved2[3];
- -
- - /* BMCSR: offset 0x30 */
- - u32 bmcsr; /* Bus Moniter Control/Status Register */
- -#define BMCSR_HOST_SPD_TYP (3<<9)
- -#define BMCSR_VBUS_OFF (1<<4)
- -#define BMCSR_INT_POLARITY (1<<3)
- -
- - /* BMISR: offset 0x34 */
- - u32 bmisr; /* Bus Moniter Interrupt Status Register*/
- -#define BMISR_OVC (1<<1)
- -
- - /* BMIER: offset 0x38 */
- - u32 bmier; /* Bus Moniter Interrupt Enable Register */
- -#define BMIER_OVC_EN (1<<1)
- -#define BMIER_VBUS_ERR_EN (1<<0)
- + u32 reserved2[19];
- +
- + /* OTGCSR: offet 0x70 */
- + u32 otgcsr;
- +#define OTGCSR_HOST_SPD_TYP (3 << 22)
- +#define OTGCSR_A_BUS_DROP (1 << 5)
- +#define OTGCSR_A_BUS_REQ (1 << 4)
- +
- + /* OTGISR: offset 0x74 */
- + u32 otgisr;
- +#define OTGISR_OVC (1 << 10)
- +
- + u32 reserved3[15];
- +
- + /* GMIR: offset 0xB4 */
- + u32 gmir;
- +#define GMIR_INT_POLARITY (1 << 3) /*Active High*/
- +#define GMIR_MHC_INT (1 << 2)
- +#define GMIR_MOTG_INT (1 << 1)
- +#define GMIR_MDEV_INT (1 << 0)
- };
- /*-------------------------------------------------------------------------*/
- @@ -330,7 +338,7 @@ struct fotg210_qtd {
- struct list_head qtd_list; /* sw qtd list */
- struct urb *urb; /* qtd's urb */
- size_t length; /* length of buffer */
- -} __attribute__ ((aligned(32)));
- +} __aligned(32);
- /* mask NakCnt+T in qh->hw_alt_next */
- #define QTD_MASK(fotg210) cpu_to_hc32(fotg210, ~0x1f)
- @@ -414,7 +422,7 @@ struct fotg210_qh_hw {
- __hc32 hw_token;
- __hc32 hw_buf[5];
- __hc32 hw_buf_hi[5];
- -} __attribute__ ((aligned(32)));
- +} __aligned(32);
- struct fotg210_qh {
- struct fotg210_qh_hw *hw; /* Must come first */
- @@ -550,7 +558,7 @@ struct fotg210_itd {
- unsigned frame; /* where scheduled */
- unsigned pg;
- unsigned index[8]; /* in urb->iso_frame_desc */
- -} __attribute__ ((aligned(32)));
- +} __aligned(32);
- /*-------------------------------------------------------------------------*/
- @@ -570,7 +578,7 @@ struct fotg210_fstn {
- /* the rest is HCD-private */
- dma_addr_t fstn_dma;
- union fotg210_shadow fstn_next; /* ptr to periodic q entry */
- -} __attribute__ ((aligned (32)));
- +} __aligned(32);
- /*-------------------------------------------------------------------------*/
- @@ -594,8 +602,8 @@ struct fotg210_fstn {
- static inline unsigned int
- fotg210_get_speed(struct fotg210_hcd *fotg210, unsigned int portsc)
- {
- - return (readl(&fotg210->regs->bmcsr)
- - & BMCSR_HOST_SPD_TYP) >> 9;
- + return (readl(&fotg210->regs->otgcsr)
- + & OTGCSR_HOST_SPD_TYP) >> 22;
- }
- /* Returns the speed of a device attached to a port on the root hub. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement