From 1da69aa92b165bb06b6cd26d11d044c66bfa1c30 Mon Sep 17 00:00:00 2001 From: Raluca Oncioiu Date: Sat, 8 Mar 2014 00:32:05 +0200 Subject: [PATCH] Staging: octeon-usb: Break up long lines Break up long lines. Signed-off-by: Raluca Oncioiu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 638 ++++++++++++++++-------- 1 file changed, 436 insertions(+), 202 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 5a001d9b4252..ee38e08c07d0 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -605,7 +605,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, * 2a. Write USBN0/1_CLK_CTL[POR] = 1 and * USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0 */ - usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); + usbn_clk_ctl.u64 = + __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); usbn_clk_ctl.s.por = 1; usbn_clk_ctl.s.hrst = 0; usbn_clk_ctl.s.prst = 0; @@ -691,7 +692,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, * USBP control and status register: * USBN_USBP_CTL_STATUS[ATE_RESET] = 1 */ - usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index)); + usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, + CVMX_USBNX_USBP_CTL_STATUS(usb->index)); usbn_usbp_ctl_status.s.ate_reset = 1; __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), usbn_usbp_ctl_status.u64); @@ -758,7 +760,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, if (OCTEON_IS_MODEL(OCTEON_CN31XX)) usb->init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA; usbcx_gahbcfg.u32 = 0; - usbcx_gahbcfg.s.dmaen = !(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA); + usbcx_gahbcfg.s.dmaen = !(usb->init_flags & + CVMX_USB_INITIALIZE_FLAGS_NO_DMA); if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) /* Only use one channel with non DMA */ usb->idle_hardware_channels = 0x1; @@ -783,7 +786,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, */ { union cvmx_usbcx_gusbcfg usbcx_gusbcfg; - usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index)); + usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GUSBCFG(usb->index)); usbcx_gusbcfg.s.toutcal = 0; usbcx_gusbcfg.s.ddrsel = 0; usbcx_gusbcfg.s.usbtrdtim = 0x5; @@ -801,7 +805,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, union cvmx_usbcx_gintmsk usbcx_gintmsk; int channel; - usbcx_gintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTMSK(usb->index)); + usbcx_gintmsk.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GINTMSK(usb->index)); usbcx_gintmsk.s.otgintmsk = 1; usbcx_gintmsk.s.modemismsk = 1; usbcx_gintmsk.s.hchintmsk = 1; @@ -817,7 +822,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, * later. */ for (channel = 0; channel < 8; channel++) - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); } { @@ -827,26 +833,30 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, * 1. Program the host-port interrupt-mask field to unmask, * USBC_GINTMSK[PRTINT] = 1 */ - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, - prtintmsk, 1); - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, - disconnintmsk, 1); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, prtintmsk, 1); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, disconnintmsk, 1); /* * 2. Program the USBC_HCFG register to select full-speed host * or high-speed host. */ { union cvmx_usbcx_hcfg usbcx_hcfg; - usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index)); + usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCFG(usb->index)); usbcx_hcfg.s.fslssupp = 0; usbcx_hcfg.s.fslspclksel = 0; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCFG(usb->index), usbcx_hcfg.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCFG(usb->index), + usbcx_hcfg.u32); } /* * 3. Program the port power bit to drive VBUS on the USB, * USBC_HPRT[PRTPWR] = 1 */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtpwr, 1); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), + union cvmx_usbcx_hprt, prtpwr, 1); /* * Steps 4-15 from the manual are done later in the port enable @@ -879,7 +889,8 @@ static int cvmx_usb_shutdown(struct cvmx_usb_state *usb) return -EBUSY; /* Disable the clocks and put them in power on reset */ - usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); + usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, + CVMX_USBNX_CLK_CTL(usb->index)); usbn_clk_ctl.s.enable = 1; usbn_clk_ctl.s.por = 1; usbn_clk_ctl.s.hclk_rst = 1; @@ -903,7 +914,8 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) { union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3; - usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HPRT(usb->index)); /* * If the port is already enabled the just return. We don't need to do @@ -927,26 +939,30 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) mdelay(50); /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtrst, 0); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, + prtrst, 0); /* Wait for the USBC_HPRT[PRTENA]. */ - if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, - prtena, ==, 1, 100000)) + if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), + union cvmx_usbcx_hprt, prtena, ==, 1, 100000)) return -ETIMEDOUT; /* * Read the port speed field to get the enumerated speed, * USBC_HPRT[PRTSPD]. */ - usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GHWCFG3(usb->index)); + usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HPRT(usb->index)); + usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GHWCFG3(usb->index)); /* * 13. Program the USBC_GRXFSIZ register to select the size of the * receive FIFO (25%). */ - USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), union cvmx_usbcx_grxfsiz, - rxfdep, usbcx_ghwcfg3.s.dfifodepth / 4); + USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), + union cvmx_usbcx_grxfsiz, rxfdep, + usbcx_ghwcfg3.s.dfifodepth / 4); /* * 14. Program the USBC_GNPTXFSIZ register to select the size and the * start address of the non- periodic transmit FIFO for nonperiodic @@ -954,10 +970,12 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) */ { union cvmx_usbcx_gnptxfsiz siz; - siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index)); + siz.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GNPTXFSIZ(usb->index)); siz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2; siz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index), siz.u32); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index), + siz.u32); } /* * 15. Program the USBC_HPTXFSIZ register to select the size and start @@ -966,18 +984,25 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) */ { union cvmx_usbcx_hptxfsiz siz; - siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index)); + siz.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HPTXFSIZ(usb->index)); siz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4; siz.s.ptxfstaddr = 3 * usbcx_ghwcfg3.s.dfifodepth / 4; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index), siz.u32); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index), + siz.u32); } /* Flush all FIFOs */ - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, txfnum, 0x10); - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, txfflsh, 1); - CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), + union cvmx_usbcx_grstctl, txfnum, 0x10); + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), + union cvmx_usbcx_grstctl, txfflsh, 1); + CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), + union cvmx_usbcx_grstctl, txfflsh, ==, 0, 100); - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, rxfflsh, 1); - CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), + union cvmx_usbcx_grstctl, rxfflsh, 1); + CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), + union cvmx_usbcx_grstctl, rxfflsh, ==, 0, 100); return 0; @@ -997,7 +1022,8 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) static int cvmx_usb_disable(struct cvmx_usb_state *usb) { /* Disable the port */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtena, 1); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, + prtena, 1); return 0; } @@ -1013,20 +1039,23 @@ static int cvmx_usb_disable(struct cvmx_usb_state *usb) * * Returns: Port status information */ -static struct cvmx_usb_port_status cvmx_usb_get_status(struct cvmx_usb_state *usb) +static struct cvmx_usb_port_status cvmx_usb_get_status( + struct cvmx_usb_state *usb) { union cvmx_usbcx_hprt usbc_hprt; struct cvmx_usb_port_status result; memset(&result, 0, sizeof(result)); - usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HPRT(usb->index)); result.port_enabled = usbc_hprt.s.prtena; result.port_over_current = usbc_hprt.s.prtovrcurract; result.port_powered = usbc_hprt.s.prtpwr; result.port_speed = usbc_hprt.s.prtspd; result.connected = usbc_hprt.s.prtconnsts; - result.connect_change = (result.connected != usb->port_status.connected); + result.connect_change = + (result.connected != usb->port_status.connected); return result; } @@ -1121,7 +1150,8 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, if (unlikely((device_speed != CVMX_USB_SPEED_HIGH) && (multi_count != 0))) return NULL; - if (unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) + if (unlikely((hub_device_addr < 0) || + (hub_device_addr > MAX_USB_ADDRESS))) return NULL; if (unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) return NULL; @@ -1186,7 +1216,8 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb) uint64_t address; uint32_t *ptr; - rx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GRXSTSPH(usb->index)); + rx_status.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GRXSTSPH(usb->index)); /* Only read data if IN data is there */ if (rx_status.s.pktsts != 2) return; @@ -1236,7 +1267,8 @@ static int __cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb, while (available && (fifo->head != fifo->tail)) { int i = fifo->tail; const uint32_t *ptr = cvmx_phys_to_ptr(fifo->entry[i].address); - uint64_t csr_address = USB_FIFO_ADDRESS(fifo->entry[i].channel, usb->index) ^ 4; + uint64_t csr_address = USB_FIFO_ADDRESS(fifo->entry[i].channel, + usb->index) ^ 4; int words = available; /* Limit the amount of data to waht the SW fifo has */ @@ -1260,7 +1292,8 @@ static int __cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb, cvmx_write64_uint32(csr_address, *ptr++); cvmx_write64_uint32(csr_address, *ptr++); cvmx_write64_uint32(csr_address, *ptr++); - cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); + cvmx_read64_uint64( + CVMX_USBNX_DMA0_INB_CHN0(usb->index)); words -= 3; } cvmx_write64_uint32(csr_address, *ptr++); @@ -1284,20 +1317,32 @@ static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb) { if (usb->periodic.head != usb->periodic.tail) { union cvmx_usbcx_hptxsts tx_status; - tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index)); - if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic, tx_status.s.ptxfspcavail)) - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, ptxfempmsk, 1); + tx_status.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HPTXSTS(usb->index)); + if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic, + tx_status.s.ptxfspcavail)) + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, + ptxfempmsk, 1); else - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, ptxfempmsk, 0); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, + ptxfempmsk, 0); } if (usb->nonperiodic.head != usb->nonperiodic.tail) { union cvmx_usbcx_gnptxsts tx_status; - tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXSTS(usb->index)); - if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic, tx_status.s.nptxfspcavail)) - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, nptxfempmsk, 1); + tx_status.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GNPTXSTS(usb->index)); + if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic, + tx_status.s.nptxfspcavail)) + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, + nptxfempmsk, 1); else - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, nptxfempmsk, 0); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, + nptxfempmsk, 0); } return; @@ -1318,12 +1363,14 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) struct cvmx_usb_tx_fifo *fifo; /* We only need to fill data on outbound channels */ - hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); + hcchar.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCCHARX(channel, usb->index)); if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT) return; /* OUT Splits only have data on the start and not the complete */ - usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index)); + usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCSPLTX(channel, usb->index)); if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt) return; @@ -1331,7 +1378,8 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel) * Find out how many bytes we need to fill and convert it into 32bit * words. */ - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); + usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCTSIZX(channel, usb->index)); if (!usbc_hctsiz.s.xfersize) return; @@ -1371,11 +1419,13 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, node); union cvmx_usb_control_header *header = cvmx_phys_to_ptr(transaction->control_header); - int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; + int bytes_to_transfer = transaction->buffer_length - + transaction->actual_bytes; int packets_to_transfer; union cvmx_usbcx_hctsizx usbc_hctsiz; - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); + usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCTSIZX(channel, usb->index)); switch (transaction->stage) { case CVMX_USB_STAGE_NON_CONTROL: @@ -1423,12 +1473,14 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_IN : CVMX_USB_DIRECTION_OUT)); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), union cvmx_usbcx_hcspltx, compsplt, 1); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), + union cvmx_usbcx_hcspltx, compsplt, 1); break; case CVMX_USB_STAGE_STATUS: usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + union cvmx_usbcx_hccharx, epdir, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_OUT : CVMX_USB_DIRECTION_IN)); @@ -1436,11 +1488,13 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + union cvmx_usbcx_hccharx, epdir, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_OUT : CVMX_USB_DIRECTION_IN)); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), union cvmx_usbcx_hcspltx, compsplt, 1); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), + union cvmx_usbcx_hcspltx, compsplt, 1); break; } @@ -1458,10 +1512,12 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, * Calculate the number of packets to transfer. If the length is zero * we still need to transfer one packet */ - packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; + packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / + pipe->max_packet; if (packets_to_transfer == 0) packets_to_transfer = 1; - else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { + else if ((packets_to_transfer > 1) && + (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { /* * Limit to one packet when not using DMA. Channels must be * restarted between every packet for IN transactions, so there @@ -1481,7 +1537,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, usbc_hctsiz.s.xfersize = bytes_to_transfer; usbc_hctsiz.s.pktcnt = packets_to_transfer; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), + usbc_hctsiz.u32); return; } @@ -1519,8 +1576,11 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, union cvmx_usbcx_haintmsk usbc_haintmsk; /* Clear all channel status bits */ - usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index), usbc_hcint.u32); + usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCINTX(channel, usb->index)); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCINTX(channel, usb->index), + usbc_hcint.u32); usbc_hcintmsk.u32 = 0; usbc_hcintmsk.s.chhltdmsk = 1; @@ -1567,14 +1627,17 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, union cvmx_usbcx_hcspltx usbc_hcsplt = {.u32 = 0}; union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 = 0}; int packets_to_transfer; - int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; + int bytes_to_transfer = transaction->buffer_length - + transaction->actual_bytes; /* * ISOCHRONOUS transactions store each individual transfer size * in the packet structure, not the global buffer_length */ if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) - bytes_to_transfer = transaction->iso_packets[0].length - transaction->actual_bytes; + bytes_to_transfer = + transaction->iso_packets[0].length - + transaction->actual_bytes; /* * We need to do split transactions when we are talking to non @@ -1589,16 +1652,19 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, */ if ((transaction->stage&1) == 0) { if (transaction->type == CVMX_USB_TRANSFER_BULK) - pipe->split_sc_frame = (usb->frame_number + 1) & 0x7f; + pipe->split_sc_frame = + (usb->frame_number + 1) & 0x7f; else - pipe->split_sc_frame = (usb->frame_number + 2) & 0x7f; + pipe->split_sc_frame = + (usb->frame_number + 2) & 0x7f; } else pipe->split_sc_frame = -1; usbc_hcsplt.s.spltena = 1; usbc_hcsplt.s.hubaddr = pipe->hub_device_addr; usbc_hcsplt.s.prtaddr = pipe->hub_port; - usbc_hcsplt.s.compsplt = (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE); + usbc_hcsplt.s.compsplt = (transaction->stage == + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE); /* * SPLIT transactions can only ever transmit one data @@ -1614,8 +1680,10 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * begin/middle/end of the data or all */ if (!usbc_hcsplt.s.compsplt && - (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && - (pipe->transfer_type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { + (pipe->transfer_dir == + CVMX_USB_DIRECTION_OUT) && + (pipe->transfer_type == + CVMX_USB_TRANSFER_ISOCHRONOUS)) { /* * Clear the split complete frame number as * there isn't going to be a split complete @@ -1667,7 +1735,8 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * Round MAX_TRANSFER_BYTES to a multiple of out packet * size */ - bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; + bytes_to_transfer = MAX_TRANSFER_BYTES / + pipe->max_packet; bytes_to_transfer *= pipe->max_packet; } @@ -1675,10 +1744,14 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * Calculate the number of packets to transfer. If the length is * zero we still need to transfer one packet */ - packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; + packets_to_transfer = + (bytes_to_transfer + pipe->max_packet - 1) / + pipe->max_packet; if (packets_to_transfer == 0) packets_to_transfer = 1; - else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { + else if ((packets_to_transfer > 1) && + (usb->init_flags & + CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { /* * Limit to one packet when not using DMA. Channels must * be restarted between every packet for IN @@ -1686,14 +1759,16 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * packets in a row */ packets_to_transfer = 1; - bytes_to_transfer = packets_to_transfer * pipe->max_packet; + bytes_to_transfer = packets_to_transfer * + pipe->max_packet; } else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { /* * Limit the number of packet and data transferred to * what the hardware can handle */ packets_to_transfer = MAX_TRANSFER_PACKETS; - bytes_to_transfer = packets_to_transfer * pipe->max_packet; + bytes_to_transfer = packets_to_transfer * + pipe->max_packet; } usbc_hctsiz.s.xfersize = bytes_to_transfer; @@ -1707,8 +1782,11 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, if (pipe->flags & __CVMX_USB_PIPE_FLAGS_NEED_PING) usbc_hctsiz.s.dopng = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index), usbc_hcsplt.u32); - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCSPLTX(channel, usb->index), + usbc_hcsplt.u32); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, + usb->index), usbc_hctsiz.u32); } /* Setup the Host Channel Characteristics Register */ @@ -1739,11 +1817,14 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, /* Set the rest of the endpoint specific settings */ usbc_hcchar.s.devaddr = pipe->device_addr; usbc_hcchar.s.eptype = transaction->type; - usbc_hcchar.s.lspddev = (pipe->device_speed == CVMX_USB_SPEED_LOW); + usbc_hcchar.s.lspddev = + (pipe->device_speed == CVMX_USB_SPEED_LOW); usbc_hcchar.s.epdir = pipe->transfer_dir; usbc_hcchar.s.epnum = pipe->endpoint_num; usbc_hcchar.s.mps = pipe->max_packet; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCCHARX(channel, usb->index), + usbc_hcchar.u32); } /* Do transaction type specific fixups as needed */ @@ -1762,22 +1843,33 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, */ if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { if (pipe->multi_count < 2) /* Need DATA0 */ - USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), union cvmx_usbcx_hctsizx, pid, 0); + USB_SET_FIELD32( + CVMX_USBCX_HCTSIZX(channel, + usb->index), + union cvmx_usbcx_hctsizx, + pid, 0); else /* Need MDATA */ - USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), union cvmx_usbcx_hctsizx, pid, 3); + USB_SET_FIELD32( + CVMX_USBCX_HCTSIZX(channel, + usb->index), + union cvmx_usbcx_hctsizx, + pid, 3); } } break; } { - union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index))}; + union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 = + __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCTSIZX(channel, usb->index))}; transaction->xfersize = usbc_hctsiz.s.xfersize; transaction->pktcnt = usbc_hctsiz.s.pktcnt; } /* Remeber when we start a split transaction */ if (__cvmx_usb_pipe_needs_split(usb, pipe)) usb->active_split = transaction; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, chena, 1); + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + union cvmx_usbcx_hccharx, chena, 1); if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) __cvmx_usb_fill_tx_fifo(usb, channel); return; @@ -1793,16 +1885,22 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * * Returns: Pipe or NULL if none are ready */ -static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(struct cvmx_usb_state *usb, struct list_head *list, uint64_t current_frame) +static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe( + struct cvmx_usb_state *usb, + struct list_head *list, + uint64_t current_frame) { struct cvmx_usb_pipe *pipe; list_for_each_entry(pipe, list, node) { struct cvmx_usb_transaction *t = - list_first_entry(&pipe->transactions, typeof(*t), node); + list_first_entry(&pipe->transactions, typeof(*t), + node); if (!(pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED) && t && (pipe->next_tx_frame <= current_frame) && - ((pipe->split_sc_frame == -1) || ((((int)current_frame - (int)pipe->split_sc_frame) & 0x7f) < 0x40)) && + ((pipe->split_sc_frame == -1) || + ((((int)current_frame - (int)pipe->split_sc_frame) + & 0x7f) < 0x40)) && (!usb->active_split || (usb->active_split == t))) { CVMX_PREFETCH(pipe, 128); CVMX_PREFETCH(t, 0); @@ -1852,14 +1950,26 @@ static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof) * way we are sure that the periodic data is sent in the * beginning of the frame */ - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_ISOCHRONOUS, usb->frame_number); + pipe = __cvmx_usb_find_ready_pipe(usb, + usb->active_pipes + + CVMX_USB_TRANSFER_ISOCHRONOUS, + usb->frame_number); if (likely(!pipe)) - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_INTERRUPT, usb->frame_number); + pipe = __cvmx_usb_find_ready_pipe(usb, + usb->active_pipes + + CVMX_USB_TRANSFER_INTERRUPT, + usb->frame_number); } if (likely(!pipe)) { - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_CONTROL, usb->frame_number); + pipe = __cvmx_usb_find_ready_pipe(usb, + usb->active_pipes + + CVMX_USB_TRANSFER_CONTROL, + usb->frame_number); if (likely(!pipe)) - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_BULK, usb->frame_number); + pipe = __cvmx_usb_find_ready_pipe(usb, + usb->active_pipes + + CVMX_USB_TRANSFER_BULK, + usb->frame_number); } if (!pipe) break; @@ -1873,7 +1983,8 @@ done: * future that might need to be scheduled */ need_sof = 0; - for (ttype = CVMX_USB_TRANSFER_CONTROL; ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { + for (ttype = CVMX_USB_TRANSFER_CONTROL; + ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { list_for_each_entry(pipe, &usb->active_pipes[ttype], node) { if (pipe->next_tx_frame > usb->frame_number) { need_sof = 1; @@ -1881,7 +1992,8 @@ done: } } } - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, sofmsk, need_sof); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), + union cvmx_usbcx_gintmsk, sofmsk, need_sof); return; } @@ -1932,10 +2044,13 @@ static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, /* Recalculate the transfer size by adding up each packet */ urb->actual_length = 0; for (i = 0; i < urb->number_of_packets; i++) { - if (iso_packet[i].status == CVMX_USB_COMPLETE_SUCCESS) { + if (iso_packet[i].status == + CVMX_USB_COMPLETE_SUCCESS) { urb->iso_frame_desc[i].status = 0; - urb->iso_frame_desc[i].actual_length = iso_packet[i].length; - urb->actual_length += urb->iso_frame_desc[i].actual_length; + urb->iso_frame_desc[i].actual_length = + iso_packet[i].length; + urb->actual_length += + urb->iso_frame_desc[i].actual_length; } else { dev_dbg(dev, "ISOCHRONOUS packet=%d of %d status=%d pipe=%p transaction=%p size=%d\n", i, urb->number_of_packets, @@ -1997,10 +2112,11 @@ static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, * @complete_code: * Completion code */ -static void __cvmx_usb_perform_complete(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - struct cvmx_usb_transaction *transaction, - enum cvmx_usb_complete complete_code) +static void __cvmx_usb_perform_complete( + struct cvmx_usb_state *usb, + struct cvmx_usb_pipe *pipe, + struct cvmx_usb_transaction *transaction, + enum cvmx_usb_complete complete_code) { /* If this was a split then clear our split in progress marker */ if (usb->active_split == transaction) @@ -2019,7 +2135,8 @@ static void __cvmx_usb_perform_complete(struct cvmx_usb_state *usb, * If there are more ISOs pending and we succeeded, schedule the * next one */ - if ((transaction->iso_number_packets > 1) && (complete_code == CVMX_USB_COMPLETE_SUCCESS)) { + if ((transaction->iso_number_packets > 1) && + (complete_code == CVMX_USB_COMPLETE_SUCCESS)) { /* No bytes transferred for this packet as of yet */ transaction->actual_bytes = 0; /* One less ISO waiting to transfer */ @@ -2067,16 +2184,17 @@ done: * * Returns: Transaction or NULL on failure. */ -static struct cvmx_usb_transaction *__cvmx_usb_submit_transaction(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - enum cvmx_usb_transfer type, - uint64_t buffer, - int buffer_length, - uint64_t control_header, - int iso_start_frame, - int iso_number_packets, - struct cvmx_usb_iso_packet *iso_packets, - struct urb *urb) +static struct cvmx_usb_transaction *__cvmx_usb_submit_transaction( + struct cvmx_usb_state *usb, + struct cvmx_usb_pipe *pipe, + enum cvmx_usb_transfer type, + uint64_t buffer, + int buffer_length, + uint64_t control_header, + int iso_start_frame, + int iso_number_packets, + struct cvmx_usb_iso_packet *iso_packets, + struct urb *urb) { struct cvmx_usb_transaction *transaction; @@ -2128,9 +2246,10 @@ static struct cvmx_usb_transaction *__cvmx_usb_submit_transaction(struct cvmx_us * * Returns: A submitted transaction or NULL on failure. */ -static struct cvmx_usb_transaction *cvmx_usb_submit_bulk(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - struct urb *urb) +static struct cvmx_usb_transaction *cvmx_usb_submit_bulk( + struct cvmx_usb_state *usb, + struct cvmx_usb_pipe *pipe, + struct urb *urb) { return __cvmx_usb_submit_transaction(usb, pipe, CVMX_USB_TRANSFER_BULK, urb->transfer_dma, @@ -2152,9 +2271,10 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_bulk(struct cvmx_usb_state * * * Returns: A submitted transaction or NULL on failure. */ -static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - struct urb *urb) +static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt( + struct cvmx_usb_state *usb, + struct cvmx_usb_pipe *pipe, + struct urb *urb) { return __cvmx_usb_submit_transaction(usb, pipe, CVMX_USB_TRANSFER_INTERRUPT, @@ -2177,9 +2297,10 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt(struct cvmx_usb_st * * Returns: A submitted transaction or NULL on failure. */ -static struct cvmx_usb_transaction *cvmx_usb_submit_control(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - struct urb *urb) +static struct cvmx_usb_transaction *cvmx_usb_submit_control( + struct cvmx_usb_state *usb, + struct cvmx_usb_pipe *pipe, + struct urb *urb) { int buffer_length = urb->transfer_buffer_length; uint64_t control_header = urb->setup_dma; @@ -2209,9 +2330,10 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_control(struct cvmx_usb_stat * * Returns: A submitted transaction or NULL on failure. */ -static struct cvmx_usb_transaction *cvmx_usb_submit_isochronous(struct cvmx_usb_state *usb, - struct cvmx_usb_pipe *pipe, - struct urb *urb) +static struct cvmx_usb_transaction *cvmx_usb_submit_isochronous( + struct cvmx_usb_state *usb, + struct cvmx_usb_pipe *pipe, + struct urb *urb) { struct cvmx_usb_iso_packet *packets; @@ -2257,17 +2379,22 @@ static int cvmx_usb_cancel(struct cvmx_usb_state *usb, CVMX_SYNCW; - usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(pipe->channel, usb->index)); + usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCCHARX(pipe->channel, usb->index)); /* * If the channel isn't enabled then the transaction already * completed. */ if (usbc_hcchar.s.chena) { usbc_hcchar.s.chdis = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(pipe->channel, usb->index), usbc_hcchar.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCCHARX(pipe->channel, + usb->index), + usbc_hcchar.u32); } } - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_CANCEL); + __cvmx_usb_perform_complete(usb, pipe, transaction, + CVMX_USB_COMPLETE_CANCEL); return 0; } @@ -2331,7 +2458,8 @@ static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb) int frame_number; union cvmx_usbcx_hfnum usbc_hfnum; - usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); + usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HFNUM(usb->index)); frame_number = usbc_hfnum.s.frnum; return frame_number; @@ -2359,10 +2487,12 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) int buffer_space_left; /* Read the interrupt status bits for the channel */ - usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); + usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCINTX(channel, usb->index)); if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { - usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); + usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCCHARX(channel, usb->index)); if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) { /* @@ -2370,7 +2500,10 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * interrupt IN transfers to get stuck until we do a * write of HCCHARX without changing things */ - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCCHARX(channel, + usb->index), + usbc_hcchar.u32); return 0; } @@ -2384,9 +2517,15 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) /* Disable all interrupts except CHHLTD */ hcintmsk.u32 = 0; hcintmsk.s.chhltdmsk = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), hcintmsk.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCINTMSKX(channel, + usb->index), + hcintmsk.u32); usbc_hcchar.s.chdis = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCCHARX(channel, + usb->index), + usbc_hcchar.u32); return 0; } else if (usbc_hcint.s.xfercompl) { /* @@ -2394,7 +2533,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * Channel halt isn't needed. */ } else { - cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", usb->index, channel); + cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", + usb->index, channel); return 0; } } @@ -2417,7 +2557,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) CVMX_PREFETCH(pipe, 128); if (!pipe) return 0; - transaction = list_first_entry(&pipe->transactions, typeof(*transaction), + transaction = list_first_entry(&pipe->transactions, + typeof(*transaction), node); CVMX_PREFETCH(transaction, 0); @@ -2432,8 +2573,10 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * Read the channel config info so we can figure out how much data * transfered */ - usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); + usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCCHARX(channel, usb->index)); + usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HCTSIZX(channel, usb->index)); /* * Calculating the number of bytes successfully transferred is dependent @@ -2447,7 +2590,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * the current value of xfersize from its starting value and we * know how many bytes were written to the buffer */ - bytes_this_transfer = transaction->xfersize - usbc_hctsiz.s.xfersize; + bytes_this_transfer = transaction->xfersize - + usbc_hctsiz.s.xfersize; } else { /* * OUT transaction don't decrement xfersize. Instead pktcnt is @@ -2465,7 +2609,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) } /* Figure out how many bytes were in the last packet of the transfer */ if (packets_processed) - bytes_in_last_packet = bytes_this_transfer - (packets_processed-1) * usbc_hcchar.s.mps; + bytes_in_last_packet = bytes_this_transfer - + (packets_processed - 1) * usbc_hcchar.s.mps; else bytes_in_last_packet = bytes_this_transfer; @@ -2485,9 +2630,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) */ transaction->actual_bytes += bytes_this_transfer; if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) - buffer_space_left = transaction->iso_packets[0].length - transaction->actual_bytes; + buffer_space_left = transaction->iso_packets[0].length - + transaction->actual_bytes; else - buffer_space_left = transaction->buffer_length - transaction->actual_bytes; + buffer_space_left = transaction->buffer_length - + transaction->actual_bytes; /* * We need to remember the PID toggle state for the next transaction. @@ -2513,7 +2660,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * the actual bytes transferred */ pipe->pid_toggle = 0; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_STALL); + __cvmx_usb_perform_complete(usb, pipe, transaction, + CVMX_USB_COMPLETE_STALL); } else if (usbc_hcint.s.xacterr) { /* * We know at least one packet worked if we get a ACK or NAK. @@ -2528,7 +2676,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * something wrong with the transfer. For example, PID * toggle errors cause these */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_XACTERR); + __cvmx_usb_perform_complete(usb, pipe, transaction, + CVMX_USB_COMPLETE_XACTERR); } else { /* * If this was a split then clear our split in progress @@ -2544,12 +2693,15 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) pipe->split_sc_frame = -1; pipe->next_tx_frame += pipe->interval; if (pipe->next_tx_frame < usb->frame_number) - pipe->next_tx_frame = usb->frame_number + pipe->interval - - (usb->frame_number - pipe->next_tx_frame) % pipe->interval; + pipe->next_tx_frame = + usb->frame_number + pipe->interval - + (usb->frame_number - + pipe->next_tx_frame) % pipe->interval; } } else if (usbc_hcint.s.bblerr) { /* Babble Error (BblErr) */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_BABBLEERR); + __cvmx_usb_perform_complete(usb, pipe, transaction, + CVMX_USB_COMPLETE_BABBLEERR); } else if (usbc_hcint.s.datatglerr) { /* We'll retry the exact same transaction again */ transaction->retries++; @@ -2566,8 +2718,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * If there is more data to go then we need to try * again. Otherwise this transaction is complete */ - if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + if ((buffer_space_left == 0) || + (bytes_in_last_packet < pipe->max_packet)) + __cvmx_usb_perform_complete(usb, pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); } else { /* * Split transactions retry the split complete 4 times @@ -2605,12 +2760,14 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) case CVMX_USB_STAGE_NON_CONTROL: case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: /* This should be impossible */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); + __cvmx_usb_perform_complete(usb, pipe, + transaction, CVMX_USB_COMPLETE_ERROR); break; case CVMX_USB_STAGE_SETUP: pipe->pid_toggle = 1; if (__cvmx_usb_pipe_needs_split(usb, pipe)) - transaction->stage = CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; + transaction->stage = + CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; else { union cvmx_usb_control_header *header = cvmx_phys_to_ptr(transaction->control_header); @@ -2632,7 +2789,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) break; case CVMX_USB_STAGE_DATA: if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - transaction->stage = CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; + transaction->stage = + CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; /* * For setup OUT data that are splits, * the hardware doesn't appear to count @@ -2641,31 +2799,45 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) */ if (!usbc_hcchar.s.epdir) { if (buffer_space_left < pipe->max_packet) - transaction->actual_bytes += buffer_space_left; + transaction->actual_bytes += + buffer_space_left; else - transaction->actual_bytes += pipe->max_packet; + transaction->actual_bytes += + pipe->max_packet; } - } else if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { + } else if ((buffer_space_left == 0) || + (bytes_in_last_packet < + pipe->max_packet)) { pipe->pid_toggle = 1; - transaction->stage = CVMX_USB_STAGE_STATUS; + transaction->stage = + CVMX_USB_STAGE_STATUS; } break; case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: - if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { + if ((buffer_space_left == 0) || + (bytes_in_last_packet < + pipe->max_packet)) { pipe->pid_toggle = 1; - transaction->stage = CVMX_USB_STAGE_STATUS; + transaction->stage = + CVMX_USB_STAGE_STATUS; } else { - transaction->stage = CVMX_USB_STAGE_DATA; + transaction->stage = + CVMX_USB_STAGE_DATA; } break; case CVMX_USB_STAGE_STATUS: if (__cvmx_usb_pipe_needs_split(usb, pipe)) - transaction->stage = CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE; + transaction->stage = + CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE; else - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + __cvmx_usb_perform_complete(usb, pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); break; case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + __cvmx_usb_perform_complete(usb, pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); break; } break; @@ -2678,27 +2850,49 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * data is needed */ if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL) - transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + if (transaction->stage == + CVMX_USB_STAGE_NON_CONTROL) + transaction->stage = + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; else { - if (buffer_space_left && (bytes_in_last_packet == pipe->max_packet)) - transaction->stage = CVMX_USB_STAGE_NON_CONTROL; + if (buffer_space_left && + (bytes_in_last_packet == + pipe->max_packet)) + transaction->stage = + CVMX_USB_STAGE_NON_CONTROL; else { - if (transaction->type == CVMX_USB_TRANSFER_INTERRUPT) - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + if (transaction->type == + CVMX_USB_TRANSFER_INTERRUPT) + pipe->next_tx_frame += + pipe->interval; + __cvmx_usb_perform_complete( + usb, + pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); } } } else { - if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && - (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && - (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && + if ((pipe->device_speed == + CVMX_USB_SPEED_HIGH) && + (pipe->transfer_type == + CVMX_USB_TRANSFER_BULK) && + (pipe->transfer_dir == + CVMX_USB_DIRECTION_OUT) && (usbc_hcint.s.nak)) - pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; - if (!buffer_space_left || (bytes_in_last_packet < pipe->max_packet)) { - if (transaction->type == CVMX_USB_TRANSFER_INTERRUPT) - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + pipe->flags |= + __CVMX_USB_PIPE_FLAGS_NEED_PING; + if (!buffer_space_left || + (bytes_in_last_packet < + pipe->max_packet)) { + if (transaction->type == + CVMX_USB_TRANSFER_INTERRUPT) + pipe->next_tx_frame += + pipe->interval; + __cvmx_usb_perform_complete(usb, + pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); } } break; @@ -2719,28 +2913,45 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * complete. Otherwise start it again to * send the next 188 bytes */ - if (!buffer_space_left || (bytes_this_transfer < 188)) { + if (!buffer_space_left || + (bytes_this_transfer < 188)) { pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + __cvmx_usb_perform_complete( + usb, + pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); } } else { - if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { + if (transaction->stage == + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { /* * We are in the incoming data * phase. Keep getting data * until we run out of space or * get a small packet */ - if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + if ((buffer_space_left == 0) || + (bytes_in_last_packet < + pipe->max_packet)) { + pipe->next_tx_frame += + pipe->interval; + __cvmx_usb_perform_complete( + usb, + pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); } } else - transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + transaction->stage = + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; } } else { pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + __cvmx_usb_perform_complete(usb, + pipe, + transaction, + CVMX_USB_COMPLETE_SUCCESS); } break; } @@ -2760,8 +2971,10 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) transaction->stage &= ~1; pipe->next_tx_frame += pipe->interval; if (pipe->next_tx_frame < usb->frame_number) - pipe->next_tx_frame = usb->frame_number + pipe->interval - - (usb->frame_number - pipe->next_tx_frame) % pipe->interval; + pipe->next_tx_frame = usb->frame_number + + pipe->interval - + (usb->frame_number - pipe->next_tx_frame) % + pipe->interval; } else { struct cvmx_usb_port_status port; port = cvmx_usb_get_status(usb); @@ -2773,7 +2986,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) * We get channel halted interrupts with no result bits * sets when the cable is unplugged */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); + __cvmx_usb_perform_complete(usb, pipe, transaction, + CVMX_USB_COMPLETE_ERROR); } } return 0; @@ -2856,9 +3070,11 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) */ octeon_usb_port_callback(usb); /* Clear the port change bits */ - usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HPRT(usb->index)); usbc_hprt.s.prtena = 0; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index), usbc_hprt.u32); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index), + usbc_hprt.u32); } if (usbc_gintsts.s.hchint) { /* @@ -3002,13 +3218,15 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, } pipe = cvmx_usb_open_pipe(&priv->usb, usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe), speed, - le16_to_cpu(ep->desc.wMaxPacketSize) & 0x7ff, + le16_to_cpu(ep->desc.wMaxPacketSize) + & 0x7ff, transfer_type, usb_pipein(urb->pipe) ? CVMX_USB_DIRECTION_IN : CVMX_USB_DIRECTION_OUT, urb->interval, - (le16_to_cpu(ep->desc.wMaxPacketSize) >> 11) & 0x3, + (le16_to_cpu(ep->desc.wMaxPacketSize) + >> 11) & 0x3, split_device, split_port); if (!pipe) { spin_unlock_irqrestore(&priv->lock, flags); @@ -3023,7 +3241,8 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, switch (usb_pipetype(urb->pipe)) { case PIPE_ISOCHRONOUS: dev_dbg(dev, "Submit isochronous to %d.%d\n", - usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); + usb_pipedevice(urb->pipe), + usb_pipeendpoint(urb->pipe)); /* * Allocate a structure to use for our private list of * isochronous packets. @@ -3035,9 +3254,12 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, int i; /* Fill the list with the data from the URB */ for (i = 0; i < urb->number_of_packets; i++) { - iso_packet[i].offset = urb->iso_frame_desc[i].offset; - iso_packet[i].length = urb->iso_frame_desc[i].length; - iso_packet[i].status = CVMX_USB_COMPLETE_ERROR; + iso_packet[i].offset = + urb->iso_frame_desc[i].offset; + iso_packet[i].length = + urb->iso_frame_desc[i].length; + iso_packet[i].status = + CVMX_USB_COMPLETE_ERROR; } /* * Store a pointer to the list in the URB setup_packet @@ -3059,17 +3281,20 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, break; case PIPE_INTERRUPT: dev_dbg(dev, "Submit interrupt to %d.%d\n", - usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); + usb_pipedevice(urb->pipe), + usb_pipeendpoint(urb->pipe)); transaction = cvmx_usb_submit_interrupt(&priv->usb, pipe, urb); break; case PIPE_CONTROL: dev_dbg(dev, "Submit control to %d.%d\n", - usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); + usb_pipedevice(urb->pipe), + usb_pipeendpoint(urb->pipe)); transaction = cvmx_usb_submit_control(&priv->usb, pipe, urb); break; case PIPE_BULK: dev_dbg(dev, "Submit bulk to %d.%d\n", - usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe)); + usb_pipedevice(urb->pipe), + usb_pipeendpoint(urb->pipe)); transaction = cvmx_usb_submit_bulk(&priv->usb, pipe, urb); break; } @@ -3100,7 +3325,9 @@ static void octeon_usb_urb_dequeue_work(unsigned long arg) spin_unlock_irqrestore(&priv->lock, flags); } -static int octeon_usb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) +static int octeon_usb_urb_dequeue(struct usb_hcd *hcd, + struct urb *urb, + int status) { struct octeon_hcd *priv = hcd_to_octeon(hcd); unsigned long flags; @@ -3120,7 +3347,8 @@ static int octeon_usb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int stat return 0; } -static void octeon_usb_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) +static void octeon_usb_endpoint_disable(struct usb_hcd *hcd, + struct usb_host_endpoint *ep) { struct device *dev = hcd->self.controller; @@ -3203,7 +3431,8 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, dev_dbg(dev, " C_CONNECTION\n"); /* Clears drivers internal connect status change flag */ spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = cvmx_usb_get_status(&priv->usb); + priv->usb.port_status = + cvmx_usb_get_status(&priv->usb); spin_unlock_irqrestore(&priv->lock, flags); break; case USB_PORT_FEAT_C_RESET: @@ -3212,7 +3441,8 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * Clears the driver's internal Port Reset Change flag. */ spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = cvmx_usb_get_status(&priv->usb); + priv->usb.port_status = + cvmx_usb_get_status(&priv->usb); spin_unlock_irqrestore(&priv->lock, flags); break; case USB_PORT_FEAT_C_ENABLE: @@ -3222,7 +3452,8 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, * Change flag. */ spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = cvmx_usb_get_status(&priv->usb); + priv->usb.port_status = + cvmx_usb_get_status(&priv->usb); spin_unlock_irqrestore(&priv->lock, flags); break; case USB_PORT_FEAT_C_SUSPEND: @@ -3237,7 +3468,8 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, dev_dbg(dev, " C_OVER_CURRENT\n"); /* Clears the driver's overcurrent Change flag */ spin_lock_irqsave(&priv->lock, flags); - priv->usb.port_status = cvmx_usb_get_status(&priv->usb); + priv->usb.port_status = + cvmx_usb_get_status(&priv->usb); spin_unlock_irqrestore(&priv->lock, flags); break; default: @@ -3411,7 +3643,8 @@ static int octeon_usb_probe(struct platform_device *pdev) initialize_flags = CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ; break; default: - dev_err(dev, "Illebal USBN \"refclk-frequency\" %u\n", clock_rate); + dev_err(dev, "Illebal USBN \"refclk-frequency\" %u\n", + clock_rate); return -ENXIO; } @@ -3477,7 +3710,8 @@ static int octeon_usb_probe(struct platform_device *pdev) spin_lock_init(&priv->lock); - tasklet_init(&priv->dequeue_tasklet, octeon_usb_urb_dequeue_work, (unsigned long)priv); + tasklet_init(&priv->dequeue_tasklet, octeon_usb_urb_dequeue_work, + (unsigned long)priv); INIT_LIST_HEAD(&priv->dequeue_list); status = cvmx_usb_initialize(&priv->usb, usb_num, initialize_flags); -- 2.34.1