mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Staging: octeon-usb: Replaces CVMX_WAIT_FOR_FIELD32 macro with a function
Replaces CVMX_WAIT_FOR_FIELD32 macro with equivalent function. Signed-off-by: Georgios Tsotsos <tsotsos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c28b6699ac
commit
3e195a80e0
|
|
@ -377,29 +377,6 @@ struct octeon_hcd {
|
||||||
struct cvmx_usb_tx_fifo nonperiodic;
|
struct cvmx_usb_tx_fifo nonperiodic;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This macro spins on a register waiting for it to reach a condition. */
|
|
||||||
#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \
|
|
||||||
({int result; \
|
|
||||||
do { \
|
|
||||||
u64 done = cvmx_get_cycle() + (u64)timeout_usec * \
|
|
||||||
octeon_get_clock_rate() / 1000000; \
|
|
||||||
union _union c; \
|
|
||||||
\
|
|
||||||
while (1) { \
|
|
||||||
c.u32 = cvmx_usb_read_csr32(usb, address); \
|
|
||||||
\
|
|
||||||
if (cond) { \
|
|
||||||
result = 0; \
|
|
||||||
break; \
|
|
||||||
} else if (cvmx_get_cycle() > done) { \
|
|
||||||
result = -1; \
|
|
||||||
break; \
|
|
||||||
} else \
|
|
||||||
__delay(100); \
|
|
||||||
} \
|
|
||||||
} while (0); \
|
|
||||||
result; })
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This macro logically sets a single field in a CSR. It does the sequence
|
* This macro logically sets a single field in a CSR. It does the sequence
|
||||||
* read, modify, and write
|
* read, modify, and write
|
||||||
|
|
@ -593,6 +570,33 @@ static inline int cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe)
|
||||||
return 0; /* Data0 */
|
return 0; /* Data0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Loops through register until txfflsh or rxfflsh become zero.*/
|
||||||
|
static int cvmx_wait_tx_rx(struct octeon_hcd *usb, int fflsh_type)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
u64 address = CVMX_USBCX_GRSTCTL(usb->index);
|
||||||
|
u64 done = cvmx_get_cycle() + 100 *
|
||||||
|
(u64)octeon_get_clock_rate / 1000000;
|
||||||
|
union cvmx_usbcx_grstctl c;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
c.u32 = cvmx_usb_read_csr32(usb, address);
|
||||||
|
if (fflsh_type == 0 && c.s.txfflsh == 0) {
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
} else if (fflsh_type == 1 && c.s.rxfflsh == 0) {
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
} else if (cvmx_get_cycle() > done) {
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
__delay(100);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void cvmx_fifo_setup(struct octeon_hcd *usb)
|
static void cvmx_fifo_setup(struct octeon_hcd *usb)
|
||||||
{
|
{
|
||||||
union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3;
|
union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3;
|
||||||
|
|
@ -634,12 +638,10 @@ static void cvmx_fifo_setup(struct octeon_hcd *usb)
|
||||||
cvmx_usbcx_grstctl, txfnum, 0x10);
|
cvmx_usbcx_grstctl, txfnum, 0x10);
|
||||||
USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
|
USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
|
||||||
cvmx_usbcx_grstctl, txfflsh, 1);
|
cvmx_usbcx_grstctl, txfflsh, 1);
|
||||||
CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
|
cvmx_wait_tx_rx(usb, 0);
|
||||||
cvmx_usbcx_grstctl, c.s.txfflsh == 0, 100);
|
|
||||||
USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
|
USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
|
||||||
cvmx_usbcx_grstctl, rxfflsh, 1);
|
cvmx_usbcx_grstctl, rxfflsh, 1);
|
||||||
CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
|
cvmx_wait_tx_rx(usb, 1);
|
||||||
cvmx_usbcx_grstctl, c.s.rxfflsh == 0, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user