cvmx_usb_tx_fifo_t nonperiodic;
} cvmx_usb_internal_state_t;
-/* This macro logs out whenever a function is called if debugging is on */
-#define CVMX_USB_LOG_CALLED() \
- if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \
- cvmx_dprintf("%*s%s: called\n", 2*usb->indent++, "", __FUNCTION__);
-
-/* This macro logs out each function parameter if debugging is on */
-#define CVMX_USB_LOG_PARAM(format, param) \
- if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \
- cvmx_dprintf("%*s%s: param %s = " format "\n", 2*usb->indent, "", __FUNCTION__, #param, param);
-
-/* This macro logs out when a function returns a value */
-#define CVMX_USB_RETURN(v) \
- do { \
- typeof(v) r = v; \
- if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \
- cvmx_dprintf("%*s%s: returned %s(%d)\n", 2*--usb->indent, "", __FUNCTION__, #v, r); \
- return r; \
- } while (0);
-
-/* This macro logs out when a function doesn't return a value */
-#define CVMX_USB_RETURN_NOTHING() \
- do { \
- if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \
- cvmx_dprintf("%*s%s: returned\n", 2*--usb->indent, "", __FUNCTION__); \
- return; \
- } while (0);
-
/* This macro spins on a field waiting for it to reach a value */
#define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\
({int result; \
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
usb->init_flags = flags;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", usb_port_number);
- CVMX_USB_LOG_PARAM("0x%x", flags);
/* Make sure that state is large enough to store the internal state */
if (sizeof(*state) < sizeof(*usb))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* At first allow 0-1 for the usb port number */
if ((usb_port_number < 0) || (usb_port_number > 1))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* For all chips except 52XX there is only one port */
if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Try to determine clock type automatically */
if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI |
CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) {
flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ;
break;
default:
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
break;
}
}
/* Steps 4-15 from the manual are done later in the port enable */
}
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
cvmx_usbnx_clk_ctl_t usbn_clk_ctl;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
-
/* Make sure all pipes are closed */
if (usb->idle_pipes.head ||
usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS].head ||
usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head ||
usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head ||
usb->active_pipes[CVMX_USB_TRANSFER_BULK].head)
- CVMX_USB_RETURN(CVMX_USB_BUSY);
+ return CVMX_USB_BUSY;
/* 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.s.hrst = 0;
__cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
usbn_clk_ctl.u64);
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
-
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
anything */
if (usb->usbcx_hprt.s.prtena)
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
/* If there is nothing plugged into the port then fail immediately */
if (!usb->usbcx_hprt.s.prtconnsts) {
if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
cvmx_dprintf("%s: USB%d Nothing plugged into the port\n", __FUNCTION__, usb->index);
- CVMX_USB_RETURN(CVMX_USB_TIMEOUT);
+ return CVMX_USB_TIMEOUT;
}
/* Program the port reset bit to start the reset process */
if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO))
cvmx_dprintf("%s: Timeout waiting for the port to finish reset\n",
__FUNCTION__);
- CVMX_USB_RETURN(CVMX_USB_TIMEOUT);
+ return CVMX_USB_TIMEOUT;
}
/* Read the port speed field to get the enumerated speed, USBC_HPRT[PRTSPD]. */
CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t,
rxfflsh, ==, 0, 100);
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
{
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
-
/* Disable the port */
USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1);
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
memset(&result, 0, sizeof(result));
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
-
usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index));
result.port_enabled = usbc_hprt.s.prtena;
result.port_over_current = usbc_hprt.s.prtovrcurract;
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_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
usb->port_status = port_status;
- CVMX_USB_RETURN_NOTHING();
+ return;
}
cvmx_usb_pipe_t *pipe;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("0x%x", flags);
- CVMX_USB_LOG_PARAM("%d", device_addr);
- CVMX_USB_LOG_PARAM("%d", endpoint_num);
- CVMX_USB_LOG_PARAM("%d", device_speed);
- CVMX_USB_LOG_PARAM("%d", max_packet);
- CVMX_USB_LOG_PARAM("%d", transfer_type);
- CVMX_USB_LOG_PARAM("%d", transfer_dir);
- CVMX_USB_LOG_PARAM("%d", interval);
- CVMX_USB_LOG_PARAM("%d", multi_count);
- CVMX_USB_LOG_PARAM("%d", hub_device_addr);
- CVMX_USB_LOG_PARAM("%d", hub_port);
-
if (cvmx_unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(device_speed > CVMX_USB_SPEED_LOW))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((max_packet <= 0) || (max_packet > 1024)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) &&
(transfer_dir != CVMX_USB_DIRECTION_IN)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(interval < 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(multi_count < 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((device_speed != CVMX_USB_SPEED_HIGH) &&
(multi_count != 0)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Find a free pipe */
pipe = usb->free_pipes.head;
if (!pipe)
- CVMX_USB_RETURN(CVMX_USB_NO_MEMORY);
+ return CVMX_USB_NO_MEMORY;
__cvmx_usb_remove_pipe(&usb->free_pipes, pipe);
pipe->flags = flags | __CVMX_USB_PIPE_FLAGS_OPEN;
if ((device_speed == CVMX_USB_SPEED_HIGH) &&
/* We don't need to tell the hardware about this pipe yet since
it doesn't have any submitted requests */
- CVMX_USB_RETURN(__cvmx_usb_get_pipe_handle(usb, pipe));
+ return __cvmx_usb_get_pipe_handle(usb, pipe);
}
uint64_t address;
uint32_t *ptr;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
-
rx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GRXSTSPH(usb->index));
/* Only read data if IN data is there */
if (rx_status.s.pktsts != 2)
- CVMX_USB_RETURN_NOTHING();
+ return;
/* Check if no data is available */
if (!rx_status.s.bcnt)
- CVMX_USB_RETURN_NOTHING();
+ return;
channel = rx_status.s.chnum;
bytes = rx_status.s.bcnt;
if (!bytes)
- CVMX_USB_RETURN_NOTHING();
+ return;
/* Get where the DMA engine would have written this data */
address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8);
}
CVMX_SYNCW;
- CVMX_USB_RETURN_NOTHING();
+ return;
}
*/
static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fifo_t *fifo, int available)
{
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
- CVMX_USB_LOG_PARAM("%p", fifo);
- CVMX_USB_LOG_PARAM("%d", available);
-
/* We're done either when there isn't anymore space or the software FIFO
is empty */
while (available && (fifo->head != fifo->tail)) {
}
cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index));
}
- CVMX_USB_RETURN(fifo->head != fifo->tail);
+ return fifo->head != fifo->tail;
}
*/
static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb)
{
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
-
if (usb->periodic.head != usb->periodic.tail) {
cvmx_usbcx_hptxsts_t tx_status;
tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index));
USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 0);
}
- CVMX_USB_RETURN_NOTHING();
+ return;
}
cvmx_usbcx_hctsizx_t usbc_hctsiz;
cvmx_usb_tx_fifo_t *fifo;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
- CVMX_USB_LOG_PARAM("%d", channel);
-
/* We only need to fill data on outbound channels */
hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index));
if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT)
- CVMX_USB_RETURN_NOTHING();
+ return;
/* OUT Splits only have data on the start and not the complete */
usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index));
if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt)
- CVMX_USB_RETURN_NOTHING();
+ return;
/* Find out how many bytes we need to fill and convert it into 32bit words */
usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index));
if (!usbc_hctsiz.s.xfersize)
- CVMX_USB_RETURN_NOTHING();
+ return;
if ((hcchar.s.eptype == CVMX_USB_TRANSFER_INTERRUPT) ||
(hcchar.s.eptype == CVMX_USB_TRANSFER_ISOCHRONOUS))
__cvmx_usb_poll_tx_fifo(usb);
- CVMX_USB_RETURN_NOTHING();
+ return;
}
/**
int packets_to_transfer;
cvmx_usbcx_hctsizx_t usbc_hctsiz;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
- CVMX_USB_LOG_PARAM("%d", channel);
- CVMX_USB_LOG_PARAM("%p", pipe);
-
usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index));
switch (transaction->stage) {
usbc_hctsiz.s.pktcnt = packets_to_transfer;
__cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32);
- CVMX_USB_RETURN_NOTHING();
+ return;
}
{
cvmx_usb_transaction_t *transaction = pipe->head;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
- CVMX_USB_LOG_PARAM("%d", channel);
- CVMX_USB_LOG_PARAM("%p", pipe);
-
if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) ||
(pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS)))
cvmx_dprintf("%s: Channel %d started. Pipe %d transaction %d stage %d\n",
USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, chena, 1);
if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
__cvmx_usb_fill_tx_fifo(usb, channel);
- CVMX_USB_RETURN_NOTHING();
+ return;
}
int need_sof;
cvmx_usb_transfer_t ttype;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
-
if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) {
/* Without DMA we need to be careful to not schedule something at the end of a frame and cause an overrun */
cvmx_usbcx_hfnum_t hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))};
if (!pipe)
break;
- CVMX_USB_LOG_PARAM("%d", channel);
- CVMX_USB_LOG_PARAM("%p", pipe);
-
if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) ||
(pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS))) {
cvmx_usb_transaction_t *transaction = pipe->head;
}
}
USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof);
- CVMX_USB_RETURN_NOTHING();
+ return;
}
cvmx_usb_transaction_t *transaction,
cvmx_usb_complete_t complete_code)
{
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
- CVMX_USB_LOG_PARAM("%p", pipe);
- CVMX_USB_LOG_PARAM("%p", transaction);
- CVMX_USB_LOG_PARAM("%d", complete_code);
-
/* If this was a split then clear our split in progress marker */
if (usb->active_split == transaction)
usb->active_split = NULL;
complete_code);
__cvmx_usb_free_transaction(usb, transaction);
done:
- CVMX_USB_RETURN_NOTHING();
+ return;
}
cvmx_usb_transaction_t *transaction;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
- CVMX_USB_LOG_CALLED();
if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Fail if the pipe isn't open */
if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(pipe->transfer_type != type))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
transaction = __cvmx_usb_alloc_transaction(usb);
if (cvmx_unlikely(!transaction))
- CVMX_USB_RETURN(CVMX_USB_NO_MEMORY);
+ return CVMX_USB_NO_MEMORY;
transaction->type = type;
transaction->flags |= flags;
if (!transaction->prev)
__cvmx_usb_schedule(usb, 0);
- CVMX_USB_RETURN(submit_handle);
+ return submit_handle;
}
int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
- CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer);
- CVMX_USB_LOG_PARAM("%d", buffer_length);
-
/* Pipe handle checking is done later in a common place */
if (cvmx_unlikely(!buffer))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(buffer_length < 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle,
CVMX_USB_TRANSFER_BULK,
NULL, /* iso_packets */
callback,
user_data);
- CVMX_USB_RETURN(submit_handle);
+ return submit_handle;
}
int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
- CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer);
- CVMX_USB_LOG_PARAM("%d", buffer_length);
-
/* Pipe handle checking is done later in a common place */
if (cvmx_unlikely(!buffer))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(buffer_length < 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle,
CVMX_USB_TRANSFER_INTERRUPT,
NULL, /* iso_packets */
callback,
user_data);
- CVMX_USB_RETURN(submit_handle);
+ return submit_handle;
}
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_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
- CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)control_header);
- CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer);
- CVMX_USB_LOG_PARAM("%d", buffer_length);
-
/* Pipe handle checking is done later in a common place */
if (cvmx_unlikely(!control_header))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Some drivers send a buffer with a zero length. God only knows why */
if (cvmx_unlikely(buffer && (buffer_length < 0)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(!buffer && (buffer_length != 0)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if ((header->s.request_type & 0x80) == 0)
buffer_length = cvmx_le16_to_cpu(header->s.length);
NULL, /* iso_packets */
callback,
user_data);
- CVMX_USB_RETURN(submit_handle);
+ return submit_handle;
}
int submit_handle;
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
- CVMX_USB_LOG_PARAM("%d", start_frame);
- CVMX_USB_LOG_PARAM("0x%x", flags);
- CVMX_USB_LOG_PARAM("%d", number_packets);
- CVMX_USB_LOG_PARAM("%p", packets);
- CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer);
- CVMX_USB_LOG_PARAM("%d", buffer_length);
-
/* Pipe handle checking is done later in a common place */
if (cvmx_unlikely(start_frame < 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(number_packets < 1))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(!packets))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(!buffer))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(buffer_length < 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle,
CVMX_USB_TRANSFER_ISOCHRONOUS,
packets,
callback,
user_data);
- CVMX_USB_RETURN(submit_handle);
+ return submit_handle;
}
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
- CVMX_USB_LOG_PARAM("%d", submit_handle);
-
if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Fail if the pipe isn't open */
if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
transaction = usb->transaction + submit_handle;
/* Fail if this transaction already completed */
if (cvmx_unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* If the transaction is the HEAD of the queue and scheduled. We need to
treat it special */
}
}
__cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_CANCEL);
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Fail if the pipe isn't open */
if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Simply loop through and attempt to cancel each transaction */
while (pipe->head) {
cvmx_usb_status_t result = cvmx_usb_cancel(state, pipe_handle,
__cvmx_usb_get_submit_handle(usb, pipe->head));
if (cvmx_unlikely(result != CVMX_USB_SUCCESS))
- CVMX_USB_RETURN(result);
+ return result;
}
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", pipe_handle);
if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES)))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Fail if the pipe isn't open */
if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
/* Fail if the pipe has pending transactions */
if (cvmx_unlikely(pipe->head))
- CVMX_USB_RETURN(CVMX_USB_BUSY);
+ return CVMX_USB_BUSY;
pipe->flags = 0;
__cvmx_usb_remove_pipe(&usb->idle_pipes, pipe);
__cvmx_usb_append_pipe(&usb->free_pipes, pipe);
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
{
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
- CVMX_USB_LOG_PARAM("%d", reason);
- CVMX_USB_LOG_PARAM("%p", callback);
- CVMX_USB_LOG_PARAM("%p", user_data);
if (cvmx_unlikely(reason >= __CVMX_USB_CALLBACK_END))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
if (cvmx_unlikely(!callback))
- CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM);
+ return CVMX_USB_INVALID_PARAM;
usb->callback[reason] = callback;
usb->callback_data[reason] = user_data;
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}
cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state;
cvmx_usbcx_hfnum_t usbc_hfnum;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
-
usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index));
frame_number = usbc_hfnum.s.frnum;
- CVMX_USB_RETURN(frame_number);
+ return frame_number;
}
int bytes_in_last_packet;
int packets_processed;
int buffer_space_left;
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", usb);
- CVMX_USB_LOG_PARAM("%d", channel);
/* Read the interrupt status bits for the channel */
usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index));
IN transfers to get stuck until we do a write of HCCHARX
without changing things */
__cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32);
- CVMX_USB_RETURN(0);
+ return 0;
}
/* In non DMA mode the channels don't halt themselves. We need to
__cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), hcintmsk.u32);
usbc_hcchar.s.chdis = 1;
__cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32);
- CVMX_USB_RETURN(0);
+ return 0;
}
else if (usbc_hcint.s.xfercompl) {
/* Successful IN/OUT with transfer complete. Channel halt isn't needed */
}
else {
cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", usb->index, channel);
- CVMX_USB_RETURN(0);
+ return 0;
}
}
}
/* There is are no interrupts that we need to process when the channel is
still running */
if (!usbc_hcint.s.chhltd)
- CVMX_USB_RETURN(0);
+ return 0;
}
/* Disable the channel interrupts now that it is done */
CVMX_PREFETCH(pipe, 0);
CVMX_PREFETCH(pipe, 128);
if (!pipe)
- CVMX_USB_RETURN(0);
+ return 0;
transaction = pipe->head;
CVMX_PREFETCH0(transaction);
__cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR);
}
}
- CVMX_USB_RETURN(0);
+ return 0;
}
CVMX_PREFETCH(usb, 3*128);
CVMX_PREFETCH(usb, 4*128);
- CVMX_USB_LOG_CALLED();
- CVMX_USB_LOG_PARAM("%p", state);
-
/* Update the frame counter */
usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index));
if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum)
__cvmx_usb_schedule(usb, usbc_gintsts.s.sof);
- CVMX_USB_RETURN(CVMX_USB_SUCCESS);
+ return CVMX_USB_SUCCESS;
}