Commit 1da69aa9 authored by Raluca Oncioiu's avatar Raluca Oncioiu Committed by Greg Kroah-Hartman

Staging: octeon-usb: Break up long lines

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