Commit eeb90cb2 authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Greg Kroah-Hartman

staging: octeon-usb: cvmx-usb: fix whitespace issues

Fix most of the whitespace issues reported by checkpatch:
	- use tabs for indentation
	- brace placement vs. newlines
	- (foo_t*) -> (foo_t *)
	- i=0 -> i = 0
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 95e67a7a
...@@ -213,8 +213,7 @@ typedef struct { ...@@ -213,8 +213,7 @@ typedef struct {
uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \ uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \
octeon_get_clock_rate() / 1000000; \ octeon_get_clock_rate() / 1000000; \
type c; \ type c; \
while (1) \ while (1) { \
{ \
c.u32 = __cvmx_usb_read_csr32(usb, address); \ c.u32 = __cvmx_usb_read_csr32(usb, address); \
if (c.s.field op (value)) { \ if (c.s.field op (value)) { \
result = 0; \ result = 0; \
...@@ -226,16 +225,16 @@ typedef struct { ...@@ -226,16 +225,16 @@ typedef struct {
cvmx_wait(100); \ cvmx_wait(100); \
} \ } \
} while (0); \ } while (0); \
result;}) 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 */
#define USB_SET_FIELD32(address, type, field, value)\ #define USB_SET_FIELD32(address, type, field, value) \
do { \ do { \
type c; \ type c; \
c.u32 = __cvmx_usb_read_csr32(usb, address);\ c.u32 = __cvmx_usb_read_csr32(usb, address); \
c.s.field = value; \ c.s.field = value; \
__cvmx_usb_write_csr32(usb, address, c.u32);\ __cvmx_usb_write_csr32(usb, address, c.u32); \
} while (0) } while (0)
/* Returns the IO address to push/pop stuff data from the FIFOs */ /* Returns the IO address to push/pop stuff data from the FIFOs */
...@@ -470,13 +469,11 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p ...@@ -470,13 +469,11 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p
list->head->prev = NULL; list->head->prev = NULL;
else else
list->tail = NULL; list->tail = NULL;
} } else if (list->tail == pipe) {
else if (list->tail == pipe) {
list->tail = pipe->prev; list->tail = pipe->prev;
list->tail->next = NULL; list->tail->next = NULL;
pipe->prev = NULL; pipe->prev = NULL;
} } else {
else {
pipe->prev->next = pipe->next; pipe->prev->next = pipe->next;
pipe->next->prev = pipe->prev; pipe->next->prev = pipe->prev;
pipe->prev = NULL; pipe->prev = NULL;
...@@ -507,7 +504,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, ...@@ -507,7 +504,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
{ {
cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usbnx_clk_ctl_t usbn_clk_ctl;
cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
usb->init_flags = flags; usb->init_flags = flags;
...@@ -559,9 +556,9 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, ...@@ -559,9 +556,9 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
/* Initialize the transaction double linked list */ /* Initialize the transaction double linked list */
usb->free_transaction_head = NULL; usb->free_transaction_head = NULL;
usb->free_transaction_tail = NULL; usb->free_transaction_tail = NULL;
for (i=0; i<MAX_TRANSACTIONS; i++) for (i = 0; i < MAX_TRANSACTIONS; i++)
__cvmx_usb_free_transaction(usb, usb->transaction + i); __cvmx_usb_free_transaction(usb, usb->transaction + i);
for (i=0; i<MAX_PIPES; i++) for (i = 0; i < MAX_PIPES; i++)
__cvmx_usb_append_pipe(&usb->free_pipes, usb->pipe + i); __cvmx_usb_append_pipe(&usb->free_pipes, usb->pipe + i);
} }
...@@ -585,8 +582,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, ...@@ -585,8 +582,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) {
usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */
usbn_clk_ctl.cn31xx.p_xenbn = 0; usbn_clk_ctl.cn31xx.p_xenbn = 0;
} } else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX))
else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX))
usbn_clk_ctl.cn56xx.p_rtype = 2; /* From CN56XX,CN50XX manual */ usbn_clk_ctl.cn56xx.p_rtype = 2; /* From CN56XX,CN50XX manual */
else else
usbn_clk_ctl.cn52xx.p_rtype = 1; /* From CN52XX manual */ usbn_clk_ctl.cn52xx.p_rtype = 1; /* From CN52XX manual */
...@@ -602,15 +598,13 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, ...@@ -602,15 +598,13 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
usbn_clk_ctl.s.p_c_sel = 2; usbn_clk_ctl.s.p_c_sel = 2;
break; break;
} }
} } else {
else {
/* The USB port uses a 12MHz crystal as clock source /* The USB port uses a 12MHz crystal as clock source
at USB_XO and USB_XI */ at USB_XO and USB_XI */
if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) {
usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */
usbn_clk_ctl.cn31xx.p_xenbn = 1; usbn_clk_ctl.cn31xx.p_xenbn = 1;
} } else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX))
else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX))
usbn_clk_ctl.cn56xx.p_rtype = 0; /* From CN56XX,CN50XX manual */ usbn_clk_ctl.cn56xx.p_rtype = 0; /* From CN56XX,CN50XX manual */
else else
usbn_clk_ctl.cn52xx.p_rtype = 0; /* From CN52XX manual */ usbn_clk_ctl.cn52xx.p_rtype = 0; /* From CN52XX manual */
...@@ -748,7 +742,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, ...@@ -748,7 +742,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
usbcx_gintmsk.u32); usbcx_gintmsk.u32);
/* Disable all channel interrupts. We'll enable them per channel later */ /* Disable all channel interrupts. We'll enable them per channel 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);
} }
...@@ -794,7 +788,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, ...@@ -794,7 +788,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number,
int cvmx_usb_shutdown(cvmx_usb_state_t *state) int cvmx_usb_shutdown(cvmx_usb_state_t *state)
{ {
cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usbnx_clk_ctl_t usbn_clk_ctl;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
/* Make sure all pipes are closed */ /* Make sure all pipes are closed */
if (usb->idle_pipes.head || if (usb->idle_pipes.head ||
...@@ -829,7 +823,7 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state) ...@@ -829,7 +823,7 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state)
int cvmx_usb_enable(cvmx_usb_state_t *state) int cvmx_usb_enable(cvmx_usb_state_t *state)
{ {
cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
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));
...@@ -911,7 +905,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) ...@@ -911,7 +905,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state)
*/ */
int cvmx_usb_disable(cvmx_usb_state_t *state) int cvmx_usb_disable(cvmx_usb_state_t *state)
{ {
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
/* Disable the port */ /* Disable the port */
USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1);
...@@ -937,7 +931,7 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) ...@@ -937,7 +931,7 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state)
{ {
cvmx_usbcx_hprt_t usbc_hprt; cvmx_usbcx_hprt_t usbc_hprt;
cvmx_usb_port_status_t result; cvmx_usb_port_status_t result;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
memset(&result, 0, sizeof(result)); memset(&result, 0, sizeof(result));
...@@ -967,7 +961,7 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) ...@@ -967,7 +961,7 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state)
*/ */
void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status) void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status)
{ {
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
usb->port_status = port_status; usb->port_status = port_status;
return; return;
} }
...@@ -1073,7 +1067,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, ...@@ -1073,7 +1067,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags,
int multi_count, int hub_device_addr, int hub_port) int multi_count, int hub_device_addr, int hub_port)
{ {
cvmx_usb_pipe_t *pipe; cvmx_usb_pipe_t *pipe;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS)))
return -EINVAL; return -EINVAL;
...@@ -1126,8 +1120,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, ...@@ -1126,8 +1120,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags,
pipe->interval = interval*8; pipe->interval = interval*8;
/* Force start splits to be schedule on uFrame 0 */ /* Force start splits to be schedule on uFrame 0 */
pipe->next_tx_frame = ((usb->frame_number+7)&~7) + pipe->interval; pipe->next_tx_frame = ((usb->frame_number+7)&~7) + pipe->interval;
} } else {
else {
pipe->interval = interval; pipe->interval = interval;
pipe->next_tx_frame = usb->frame_number + pipe->interval; pipe->next_tx_frame = usb->frame_number + pipe->interval;
} }
...@@ -1426,14 +1419,13 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, ...@@ -1426,14 +1419,13 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb,
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 restarted /* Limit to one packet when not using DMA. Channels must be restarted
between every packet for IN transactions, so there is no reason to between every packet for IN transactions, so there is no reason to
do multiple packets in a row */ do multiple 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 what the /* Limit the number of packet and data transferred to what the
hardware can handle */ hardware can handle */
packets_to_transfer = MAX_TRANSFER_PACKETS; packets_to_transfer = MAX_TRANSFER_PACKETS;
...@@ -1541,8 +1533,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, ...@@ -1541,8 +1533,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb,
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;
...@@ -1572,8 +1563,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, ...@@ -1572,8 +1563,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb,
usbc_hcsplt.s.xactpos = 3; /* Entire payload in one go */ usbc_hcsplt.s.xactpos = 3; /* Entire payload in one go */
else else
usbc_hcsplt.s.xactpos = 2; /* First part of payload */ usbc_hcsplt.s.xactpos = 2; /* First part of payload */
} } else {
else {
/* Continuing the previous data, we must either be /* Continuing the previous data, we must either be
in the middle or at the end */ in the middle or at the end */
if (bytes_to_transfer <= 188) if (bytes_to_transfer <= 188)
...@@ -1600,14 +1590,13 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, ...@@ -1600,14 +1590,13 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb,
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 restarted /* Limit to one packet when not using DMA. Channels must be restarted
between every packet for IN transactions, so there is no reason to between every packet for IN transactions, so there is no reason to
do multiple packets in a row */ do multiple 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 what the /* Limit the number of packet and data transferred to what the
hardware can handle */ hardware can handle */
packets_to_transfer = MAX_TRANSFER_PACKETS; packets_to_transfer = MAX_TRANSFER_PACKETS;
...@@ -1778,14 +1767,14 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) ...@@ -1778,14 +1767,14 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof)
/* Only enable SOF interrupts when we have transactions pending in the /* Only enable SOF interrupts when we have transactions pending in the
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++) {
pipe = usb->active_pipes[ttype].head; pipe = usb->active_pipes[ttype].head;
while (pipe) { while (pipe) {
if (pipe->next_tx_frame > usb->frame_number) { if (pipe->next_tx_frame > usb->frame_number) {
need_sof = 1; need_sof = 1;
break; break;
} }
pipe=pipe->next; pipe = pipe->next;
} }
} }
USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof); USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof);
...@@ -1852,7 +1841,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, ...@@ -1852,7 +1841,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb,
* @param complete_code * @param complete_code
* Completion code * Completion code
*/ */
static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb, static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb,
cvmx_usb_pipe_t *pipe, cvmx_usb_pipe_t *pipe,
cvmx_usb_transaction_t *transaction, cvmx_usb_transaction_t *transaction,
cvmx_usb_complete_t complete_code) cvmx_usb_complete_t complete_code)
...@@ -1977,8 +1966,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, ...@@ -1977,8 +1966,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb,
if (pipe->tail) { if (pipe->tail) {
transaction->prev = pipe->tail; transaction->prev = pipe->tail;
transaction->prev->next = transaction; transaction->prev->next = transaction;
} } else {
else {
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->interval -
(usb->frame_number - pipe->next_tx_frame) % pipe->interval; (usb->frame_number - pipe->next_tx_frame) % pipe->interval;
...@@ -2035,7 +2023,7 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, ...@@ -2035,7 +2023,7 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle,
void *user_data) void *user_data)
{ {
int submit_handle; int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
/* Pipe handle checking is done later in a common place */ /* Pipe handle checking is done later in a common place */
if (unlikely(!buffer)) if (unlikely(!buffer))
...@@ -2094,7 +2082,7 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, ...@@ -2094,7 +2082,7 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle,
void *user_data) void *user_data)
{ {
int submit_handle; int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
/* Pipe handle checking is done later in a common place */ /* Pipe handle checking is done later in a common place */
if (unlikely(!buffer)) if (unlikely(!buffer))
...@@ -2158,7 +2146,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, ...@@ -2158,7 +2146,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle,
void *user_data) void *user_data)
{ {
int submit_handle; int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header);
/* Pipe handle checking is done later in a common place */ /* Pipe handle checking is done later in a common place */
...@@ -2240,7 +2228,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, ...@@ -2240,7 +2228,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle,
void *user_data) void *user_data)
{ {
int submit_handle; int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
/* Pipe handle checking is done later in a common place */ /* Pipe handle checking is done later in a common place */
if (unlikely(start_frame < 0)) if (unlikely(start_frame < 0))
...@@ -2290,7 +2278,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, ...@@ -2290,7 +2278,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle,
int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle)
{ {
cvmx_usb_transaction_t *transaction; cvmx_usb_transaction_t *transaction;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
...@@ -2344,7 +2332,7 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) ...@@ -2344,7 +2332,7 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle)
*/ */
int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle)
{ {
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
...@@ -2378,7 +2366,7 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) ...@@ -2378,7 +2366,7 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle)
*/ */
int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle)
{ {
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
...@@ -2416,7 +2404,7 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, ...@@ -2416,7 +2404,7 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state,
cvmx_usb_callback_func_t callback, cvmx_usb_callback_func_t callback,
void *user_data) void *user_data)
{ {
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
if (unlikely(reason >= __CVMX_USB_CALLBACK_END)) if (unlikely(reason >= __CVMX_USB_CALLBACK_END))
return -EINVAL; return -EINVAL;
...@@ -2442,7 +2430,7 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, ...@@ -2442,7 +2430,7 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state,
int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) int cvmx_usb_get_frame_number(cvmx_usb_state_t *state)
{ {
int frame_number; int frame_number;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
cvmx_usbcx_hfnum_t usbc_hfnum; cvmx_usbcx_hfnum_t 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));
...@@ -2499,17 +2487,14 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2499,17 +2487,14 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
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) {
/* Successful IN/OUT with transfer complete. Channel halt isn't needed */ /* Successful IN/OUT with transfer complete. 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;
} }
} }
} } else {
else {
/* There is are no interrupts that we need to process when the channel is /* There is are no interrupts that we need to process when the channel is
still running */ still running */
if (!usbc_hcint.s.chhltd) if (!usbc_hcint.s.chhltd)
...@@ -2548,8 +2533,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2548,8 +2533,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
value of xfersize from its starting value and we know how many value of xfersize from its starting value and we know how many
bytes were written to the buffer */ 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
decremented on every successful packet send. The hardware does decremented on every successful packet send. The hardware does
this when it receives an ACK, or NYET. If it doesn't this when it receives an ACK, or NYET. If it doesn't
...@@ -2601,8 +2585,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2601,8 +2585,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
transferred */ 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. Reset the retry counter */ /* We know at least one packet worked if we get a ACK or NAK. Reset the retry counter */
if (usbc_hcint.s.nak || usbc_hcint.s.ack) if (usbc_hcint.s.nak || usbc_hcint.s.ack)
transaction->retries = 0; transaction->retries = 0;
...@@ -2611,8 +2594,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2611,8 +2594,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
/* XactErr as a response means the device signaled something wrong with /* XactErr as a response means the device signaled something wrong with
the transfer. For example, PID toggle errors cause these */ 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 {
else {
/* If this was a split then clear our split in progress marker */ /* If this was a split then clear our split in progress marker */
if (usb->active_split == transaction) if (usb->active_split == transaction)
usb->active_split = NULL; usb->active_split = NULL;
...@@ -2625,18 +2607,13 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2625,18 +2607,13 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
pipe->next_tx_frame = usb->frame_number + pipe->interval - pipe->next_tx_frame = usb->frame_number + pipe->interval -
(usb->frame_number - pipe->next_tx_frame) % 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++;
} } else if (usbc_hcint.s.nyet) {
else if (usbc_hcint.s.nyet) {
/* NYET as a response is only allowed in three cases: as a response to /* NYET as a response is only allowed in three cases: as a response to
a ping, as a response to a split transaction, and as a response to a ping, as a response to a split transaction, and as a response to
a bulk out. The ping case is handled by hardware, so we only have a bulk out. The ping case is handled by hardware, so we only have
...@@ -2647,8 +2624,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2647,8 +2624,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
this transaction is complete */ this transaction is 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))
__cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS);
} } else {
else {
/* Split transactions retry the split complete 4 times then rewind /* Split transactions retry the split complete 4 times then rewind
to the start split and do the entire transactions again */ to the start split and do the entire transactions again */
transaction->retries++; transaction->retries++;
...@@ -2659,8 +2635,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2659,8 +2635,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
pipe->split_sc_frame = -1; pipe->split_sc_frame = -1;
} }
} }
} } else if (usbc_hcint.s.ack) {
else if (usbc_hcint.s.ack) {
transaction->retries = 0; transaction->retries = 0;
/* The ACK bit can only be checked after the other error bits. This is /* The ACK bit can only be checked after the other error bits. This is
because a multi packet transfer may succeed in a number of packets because a multi packet transfer may succeed in a number of packets
...@@ -2673,11 +2648,9 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2673,11 +2648,9 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
pipe */ pipe */
pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_NEED_PING; pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_NEED_PING;
switch (transaction->type) switch (transaction->type) {
{
case CVMX_USB_TRANSFER_CONTROL: case CVMX_USB_TRANSFER_CONTROL:
switch (transaction->stage) switch (transaction->stage) {
{
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 */
...@@ -2716,8 +2689,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2716,8 +2689,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
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;
} }
...@@ -2726,8 +2698,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2726,8 +2698,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
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;
...@@ -2760,8 +2731,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2760,8 +2731,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
__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 ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) &&
(pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) &&
(pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) &&
...@@ -2788,8 +2758,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2788,8 +2758,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
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 phase. Keep getting /* We are in the incoming data phase. Keep getting
data until we run out of space or get a small data until we run out of space or get a small
...@@ -2798,19 +2767,16 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2798,19 +2767,16 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
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
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;
} }
} } else if (usbc_hcint.s.nak) {
else if (usbc_hcint.s.nak) {
/* If this was a split then clear our split in progress marker */ /* If this was a split then clear our split in progress marker */
if (usb->active_split == transaction) if (usb->active_split == transaction)
usb->active_split = NULL; usb->active_split = NULL;
...@@ -2824,17 +2790,13 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) ...@@ -2824,17 +2790,13 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel)
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->interval -
(usb->frame_number - pipe->next_tx_frame) % pipe->interval; (usb->frame_number - pipe->next_tx_frame) % pipe->interval;
} } else {
else {
cvmx_usb_port_status_t port; cvmx_usb_port_status_t port;
port = cvmx_usb_get_status((cvmx_usb_state_t *)usb); port = cvmx_usb_get_status((cvmx_usb_state_t *)usb);
if (port.port_enabled) if (port.port_enabled) {
{
/* We'll retry the exact same transaction again */ /* We'll retry the exact same transaction again */
transaction->retries++; transaction->retries++;
} } else {
else
{
/* We get channel halted interrupts with no result bits sets when the /* We get channel halted interrupts with no result bits sets when the
cable is unplugged */ 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);
...@@ -2859,7 +2821,7 @@ int cvmx_usb_poll(cvmx_usb_state_t *state) ...@@ -2859,7 +2821,7 @@ int cvmx_usb_poll(cvmx_usb_state_t *state)
{ {
cvmx_usbcx_hfnum_t usbc_hfnum; cvmx_usbcx_hfnum_t usbc_hfnum;
cvmx_usbcx_gintsts_t usbc_gintsts; cvmx_usbcx_gintsts_t usbc_gintsts;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state;
CVMX_PREFETCH(usb, 0); CVMX_PREFETCH(usb, 0);
CVMX_PREFETCH(usb, 1*128); CVMX_PREFETCH(usb, 1*128);
......
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