* Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
* "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
* otherwise expressly agreed to in writing between Synopsys and you.
- *
+ *
* The Software IS NOT an item of Licensed Software or Licensed Product under
* any End User Software License Agreement or Agreement for Licensed Product
* with Synopsys or any supplement thereto. You are permitted to use and
* any information contained herein except pursuant to this license grant from
* Synopsys. If you do not agree with this notice, including the disclaimer
* below, then you are not authorized to use the Software.
- *
+ *
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* DAMAGE.
* ========================================================================== */
-/** @file
+/** @file
*
- * This file contains the most of the CFI(Core Feature Interface)
- * implementation for the OTG.
+ * This file contains the most of the CFI(Core Feature Interface)
+ * implementation for the OTG.
*/
#ifdef DWC_UTE_CFI
/** This definition should actually migrate to the Portability Library */
#define DWC_CONSTANT_CPU_TO_LE16(x) (x)
-extern dwc_otg_pcd_ep_t *get_ep_by_addr(dwc_otg_pcd_t * pcd, u16 wIndex);
+extern dwc_otg_pcd_ep_t *get_ep_by_addr(dwc_otg_pcd_t *pcd, u16 wIndex);
-static int cfi_core_features_buf(uint8_t * buf, uint16_t buflen);
-static int cfi_get_feature_value(uint8_t * buf, uint16_t buflen,
+static int cfi_core_features_buf(uint8_t *buf, uint16_t buflen);
+static int cfi_get_feature_value(uint8_t *buf, uint16_t buflen,
struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *ctrl_req);
static int cfi_set_feature_value(struct dwc_otg_pcd *pcd);
-static int cfi_ep_get_sg_val(uint8_t * buf, struct dwc_otg_pcd *pcd,
+static int cfi_ep_get_sg_val(uint8_t *buf, struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req);
-static int cfi_ep_get_concat_val(uint8_t * buf, struct dwc_otg_pcd *pcd,
+static int cfi_ep_get_concat_val(uint8_t *buf, struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req);
-static int cfi_ep_get_align_val(uint8_t * buf, struct dwc_otg_pcd *pcd,
+static int cfi_ep_get_align_val(uint8_t *buf, struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req);
static int cfi_preproc_reset(struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req);
-static void cfi_free_ep_bs_dyn_data(cfi_ep_t * cfiep);
+static void cfi_free_ep_bs_dyn_data(cfi_ep_t *cfiep);
-static uint16_t get_dfifo_size(dwc_otg_core_if_t * core_if);
-static int32_t get_rxfifo_size(dwc_otg_core_if_t * core_if, uint16_t wValue);
+static uint16_t get_dfifo_size(dwc_otg_core_if_t *core_if);
+static int32_t get_rxfifo_size(dwc_otg_core_if_t *core_if, uint16_t wValue);
static int32_t get_txfifo_size(struct dwc_otg_pcd *pcd, uint16_t wValue);
-static uint8_t resize_fifos(dwc_otg_core_if_t * core_if);
+static uint8_t resize_fifos(dwc_otg_core_if_t *core_if);
/** This is the header of the all features descriptor */
static cfi_all_features_header_t all_props_desc_header = {
{
.wFeatureID = DWC_CONSTANT_CPU_TO_LE16(FT_ID_DMA_CONCAT_SETUP),
.bmAttributes = CFI_FEATURE_ATTR_RW,
- //.wDataLength = DWC_CONSTANT_CPU_TO_LE16(6),
+ /* .wDataLength = DWC_CONSTANT_CPU_TO_LE16(6), */
},
/* FT_ID_DMA_CIRCULAR */
/************************************************************************/
-/**
- * Returns the name of the feature by its ID
+/**
+ * Returns the name of the feature by its ID
* or NULL if no featute ID matches.
- *
+ *
*/
const uint8_t *get_prop_name(uint16_t prop_id, int *len)
{
/**
* This function handles all CFI specific control requests.
- *
+ *
* Return a negative value to stall the DCE.
*/
int cfi_setup(struct dwc_otg_pcd *pcd, struct cfi_usb_ctrlrequest *ctrl)
uint32_t regaddr = 0;
uint32_t regval = 0;
- /* Save this Control Request in the CFI object.
- * The data field will be assigned in the data stage completion CB function.
+ /* Save this Control Request in the CFI object.
+ * The data field will be assigned in the data
+ * stage completion CB function.
*/
cfi->ctrl_req = *ctrl;
cfi->ctrl_req.data = NULL;
case VEN_CORE_GET_FEATURES:
retval = cfi_core_features_buf(cfi->buf_in.buf, CFI_IN_BUF_LEN);
if (retval >= 0) {
- //dump_msg(cfi->buf_in.buf, retval);
+ /* dump_msg(cfi->buf_in.buf, retval); */
ep = &pcd->ep0;
retval = min((uint16_t) retval, wLen);
- /* Transfer this buffer to the host through the EP0-IN EP */
+ /* Transfer this buffer to the host
+ * through the EP0-IN EP
+ */
ep->dwc_ep.dma_addr = cfi->buf_in.addr;
ep->dwc_ep.start_xfer_buff = cfi->buf_in.buf;
ep->dwc_ep.xfer_buff = cfi->buf_in.buf;
ep = &pcd->ep0;
retval = min((uint16_t) retval, wLen);
- /* Transfer this buffer to the host through the EP0-IN EP */
+ /* Transfer this buffer to the host
+ * through the EP0-IN EP
+ */
ep->dwc_ep.dma_addr = cfi->buf_in.addr;
ep->dwc_ep.start_xfer_buff = cfi->buf_in.buf;
ep->dwc_ep.xfer_buff = cfi->buf_in.buf;
case VEN_CORE_READ_REGISTER:
CFI_INFO("VEN_CORE_READ_REGISTER\n");
- /* wValue optionally contains the HI WORD of the register offset and
- * wIndex contains the LOW WORD of the register offset
+ /* wValue optionally contains the HI WORD of
+ * the register offset and wIndex contains
+ * the LOW WORD of the register offset
*/
if (wValue == 0) {
/* @TODO - MAS - fix the access to the base field */
regaddr = 0;
- //regaddr = (uint32_t) pcd->otg_dev->os_dep.base;
- //GET_CORE_IF(pcd)->co
+ /* regaddr = (uint32_t) pcd->otg_dev->os_dep.base; */
+ /* GET_CORE_IF(pcd)->co */
regaddr |= wIndex;
} else {
regaddr = (wValue << 16) | wIndex;
/**
* This function prepares the core features descriptors and copies its
* raw representation into the buffer <buf>.
- *
+ *
* The buffer structure is as follows:
* all_features_header (8 bytes)
* features_#1 (8 bytes + feature name string length)
* .....
* features_#n - where n=the total count of feature descriptors
*/
-static int cfi_core_features_buf(uint8_t * buf, uint16_t buflen)
+static int cfi_core_features_buf(uint8_t *buf, uint16_t buflen)
{
cfi_feature_desc_header_t *prop_hdr = prop_descs;
cfi_feature_desc_header_t *prop;
/**
* This function releases all the dynamic memory in the CFI object.
*/
-static void cfi_release(cfiobject_t * cfiobj)
+static void cfi_release(cfiobject_t *cfiobj)
{
cfi_ep_t *cfiep;
dwc_list_link_t *tmp;
}
/* Free the Buffer Setup values for each EP */
- //list_for_each_entry(cfiep, &cfiobj->active_eps, lh) {
+ /* list_for_each_entry(cfiep, &cfiobj->active_eps, lh) { */
DWC_LIST_FOREACH(tmp, &cfiobj->active_eps) {
cfiep = DWC_LIST_ENTRY(tmp, struct cfi_ep, lh);
cfi_free_ep_bs_dyn_data(cfiep);
/**
* This function frees the dynamically allocated EP buffer setup data.
*/
-static void cfi_free_ep_bs_dyn_data(cfi_ep_t * cfiep)
+static void cfi_free_ep_bs_dyn_data(cfi_ep_t *cfiep)
{
if (cfiep->bm_sg) {
DWC_FREE(cfiep->bm_sg);
* for a specific endpoint and should be called only once when
* the EP is enabled first time.
*/
-static int cfi_ep_init_defaults(struct dwc_otg_pcd *pcd, cfi_ep_t * cfiep)
+static int cfi_ep_init_defaults(struct dwc_otg_pcd *pcd, cfi_ep_t *cfiep)
{
int retval = 0;
dwc_memset(cfiep->bm_sg, 0, sizeof(ddma_sg_buffer_setup_t));
/* For the Concatenation feature's default value we do not allocate
- * memory for the wTxBytes field - it will be done in the set_feature_value
- * request handler.
+ * memory for the wTxBytes field - it will be done in the
+ * set_feature_value request handler.
*/
cfiep->bm_concat = DWC_ALLOC(sizeof(ddma_concat_buffer_setup_t));
if (NULL == cfiep->bm_concat) {
CFI_INFO
- ("Failed to allocate memory for CONCATENATION feature value\n");
+ ("Failed to allocate memory for
+ CONCATENATION feature value\n");
DWC_FREE(cfiep->bm_sg);
return -DWC_E_NO_MEMORY;
}
* The callback function that notifies the CFI on the activation of
* an endpoint in the PCD. The following steps are done in this function:
*
- * Create a dynamically allocated cfi_ep_t object (a CFI wrapper to the PCD's
+ * Create a dynamically allocated cfi_ep_t object (a CFI wrapper to the PCD's
* active endpoint)
* Create MAX_DMA_DESCS_PER_EP count DMA Descriptors for the EP
* Set the Buffer Mode to standard
/* Save the dwc_otg_pcd_ep pointer in the cfiep object */
cfiep->ep = ep;
- /* Allocate the DMA Descriptors chain of MAX_DMA_DESCS_PER_EP count */
+ /* Allocate the DMA Descriptors chain of
+ * MAX_DMA_DESCS_PER_EP count */
ep->dwc_ep.descs =
DWC_DMA_ALLOC(MAX_DMA_DESCS_PER_EP *
sizeof(dwc_otg_dma_desc_t),
DWC_LIST_INIT(&cfiep->lh);
- /* Set the buffer mode to BM_STANDARD. It will be modified
+ /* Set the buffer mode to BM_STANDARD. It will be modified
* when building descriptors for a specific buffer mode */
ep->dwc_ep.buff_mode = BM_STANDARD;
- /* Create and initialize the default values for this EP's Buffer modes */
- if ((retval = cfi_ep_init_defaults(pcd, cfiep)) < 0)
+ /* Create and initialize the default values
+ * for this EP's Buffer modes */
+ retval = cfi_ep_init_defaults(pcd, cfiep);
+ if (retval < 0)
return retval;
- /* Add the cfi_ep_t object to the CFI object's list of active endpoints */
+ /* Add the cfi_ep_t object to the CFI object's
+ * list of active endpoints */
DWC_LIST_INSERT_TAIL(&cfi->active_eps, &cfiep->lh);
retval = 0;
} else { /* The sought EP already is in the list */
/**
* This function is called when the data stage of a 3-stage Control Write request
* is complete.
- *
+ *
*/
static int cfi_ctrl_write_complete(struct cfiobject *cfi,
struct dwc_otg_pcd *pcd)
uint16_t wIndex, wValue;
uint8_t bRequest;
uint8_t *buf = cfi->buf_out.buf;
- //struct usb_ctrlrequest *ctrl_req = &cfi->ctrl_req_saved;
+ /* struct usb_ctrlrequest *ctrl_req = &cfi->ctrl_req_saved; */
struct cfi_usb_ctrlrequest *ctrl_req = &cfi->ctrl_req;
int retval = -DWC_E_NOT_SUPPORTED;
wIndex = DWC_CONSTANT_CPU_TO_LE16(ctrl_req->wIndex);
wValue = DWC_CONSTANT_CPU_TO_LE16(ctrl_req->wValue);
- /*
+ /*
* Save the pointer to the data stage in the ctrl_req's <data> field.
* The request should be already saved in the command stage by now.
*/
switch (bRequest) {
case VEN_CORE_WRITE_REGISTER:
- /* The buffer contains raw data of the new value for the register */
+ /* The buffer contains raw data of
+ * the new value for the register */
reg_value = *((uint32_t *) buf);
if (wValue == 0) {
addr = 0;
- //addr = (uint32_t) pcd->otg_dev->os_dep.base;
+ /* addr = (uint32_t) pcd->otg_dev->os_dep.base; */
addr += wIndex;
} else {
addr = (wValue << 16) | wIndex;
}
- //writel(reg_value, addr);
+ /* writel(reg_value, addr); */
retval = 0;
cfi->need_status_in_complete = 1;
break;
case VEN_CORE_SET_FEATURE:
- /* The buffer contains raw data of the new value of the feature */
+ /* The buffer contains raw data of
+ * the new value of the feature */
retval = cfi_set_feature_value(pcd);
if (retval < 0)
return retval;
/**
* This function builds the DMA descriptors for the SG buffer mode.
*/
-static void cfi_build_sg_descs(struct cfiobject *cfi, cfi_ep_t * cfiep,
- dwc_otg_pcd_request_t * req)
+static void cfi_build_sg_descs(struct cfiobject *cfi, cfi_ep_t *cfiep,
+ dwc_otg_pcd_request_t *req)
{
struct dwc_otg_pcd_ep *ep = cfiep->ep;
ddma_sg_buffer_setup_t *sgval = cfiep->bm_sg;
txsize = sgval->wSize;
off = sgval->bOffset;
-// CFI_INFO("%s: %s TXSIZE=0x%08x; OFFSET=0x%08x\n",
-// __func__, cfiep->ep->ep.name, txsize, off);
+ /* CFI_INFO("%s: %s TXSIZE=0x%08x; OFFSET=0x%08x\n",
+ __func__, cfiep->ep->ep.name, txsize, off);*/
for (i = 0; i < sgval->bCount; i++) {
desc->status.b.bs = BS_HOST_BUSY;
/**
* This function builds the DMA descriptors for the Concatenation buffer mode.
*/
-static void cfi_build_concat_descs(struct cfiobject *cfi, cfi_ep_t * cfiep,
- dwc_otg_pcd_request_t * req)
+static void cfi_build_concat_descs(struct cfiobject *cfi, cfi_ep_t *cfiep,
+ dwc_otg_pcd_request_t *req)
{
struct dwc_otg_pcd_ep *ep = cfiep->ep;
ddma_concat_buffer_setup_t *concatval = cfiep->bm_concat;
/**
* This function builds the DMA descriptors for the Circular buffer mode
*/
-static void cfi_build_circ_descs(struct cfiobject *cfi, cfi_ep_t * cfiep,
- dwc_otg_pcd_request_t * req)
+static void cfi_build_circ_descs(struct cfiobject *cfi, cfi_ep_t *cfiep,
+ dwc_otg_pcd_request_t *req)
{
- /* @todo: MAS - add implementation when this feature needs to be tested */
+ /* @todo: MAS - add implementation when
+ * this feature needs to be tested */
}
/**
* This function builds the DMA descriptors for the Alignment buffer mode
*/
-static void cfi_build_align_descs(struct cfiobject *cfi, cfi_ep_t * cfiep,
- dwc_otg_pcd_request_t * req)
+static void cfi_build_align_descs(struct cfiobject *cfi, cfi_ep_t *cfiep,
+ dwc_otg_pcd_request_t *req)
{
struct dwc_otg_pcd_ep *ep = cfiep->ep;
ddma_align_buffer_setup_t *alignval = cfiep->bm_align;
static void cfi_build_descriptors(struct cfiobject *cfi,
struct dwc_otg_pcd *pcd,
struct dwc_otg_pcd_ep *ep,
- dwc_otg_pcd_request_t * req)
+ dwc_otg_pcd_request_t *req)
{
cfi_ep_t *cfiep;
* Allocate DMA buffer for different Buffer modes.
*/
static void *cfi_ep_alloc_buf(struct cfiobject *cfi, struct dwc_otg_pcd *pcd,
- struct dwc_otg_pcd_ep *ep, dma_addr_t * dma,
+ struct dwc_otg_pcd_ep *ep, dma_addr_t *dma,
unsigned size, gfp_t flags)
{
return DWC_DMA_ALLOC(size, dma);
/**
* This function initializes the CFI object.
*/
-int init_cfi(cfiobject_t * cfiobj)
+int init_cfi(cfiobject_t *cfiobj)
{
CFI_INFO("%s\n", __func__);
/**
* This function reads the required feature's current value into the buffer
*
- * @retval: Returns negative as error, or the data length of the feature
+ * @retval: Returns negative as error, or the data length of the feature
*/
-static int cfi_get_feature_value(uint8_t * buf, uint16_t buflen,
+static int cfi_get_feature_value(uint8_t *buf, uint16_t buflen,
struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *ctrl_req)
{
/**
* This function resets the SG for the specified EP to its default value
*/
-static int cfi_reset_sg_val(cfi_ep_t * cfiep)
+static int cfi_reset_sg_val(cfi_ep_t *cfiep)
{
dwc_memset(cfiep->bm_sg, 0, sizeof(ddma_sg_buffer_setup_t));
return 0;
/**
* This function resets the Alignment for the specified EP to its default value
*/
-static int cfi_reset_align_val(cfi_ep_t * cfiep)
+static int cfi_reset_align_val(cfi_ep_t *cfiep)
{
dwc_memset(cfiep->bm_sg, 0, sizeof(ddma_sg_buffer_setup_t));
return 0;
/**
* This function resets the Concatenation for the specified EP to its default value
- * This function will also set the value of the wTxBytes field to NULL after
+ * This function will also set the value of the wTxBytes field to NULL after
* freeing the memory previously allocated for this field.
*/
-static int cfi_reset_concat_val(cfi_ep_t * cfiep)
+static int cfi_reset_concat_val(cfi_ep_t *cfiep)
{
/* First we need to free the wTxBytes field */
if (cfiep->bm_concat->wTxBytes) {
/**
* This function resets all the buffer setups of the specified endpoint
*/
-static int cfi_ep_reset_all_setup_vals(cfi_ep_t * cfiep)
+static int cfi_ep_reset_all_setup_vals(cfi_ep_t *cfiep)
{
cfi_reset_sg_val(cfiep);
cfi_reset_align_val(cfiep);
params->dev_tx_fifo_size[ep->dwc_ep.tx_fifo_num -
1];
params->dev_tx_fifo_size[ep->dwc_ep.tx_fifo_num - 1] =
- GET_CORE_IF(pcd)->init_txfsiz[ep->
- dwc_ep.tx_fifo_num -
- 1];
+ GET_CORE_IF(pcd)->init_txfsiz[ep->dwc_ep.
+ tx_fifo_num - 1];
}
}
CFI_INFO
("%s: Error resetting the feature Reset All(FIFO size)\n",
__func__);
- if (rx_rst) {
+ if (rx_rst)
params->dev_rx_fifo_size = rx_siz;
- }
if (tx_rst) {
if (ep_addr == 0) {
int i;
for (i = 0; i < core_if->hwcfg4.b.num_in_eps;
i++) {
- core_if->
- core_params->dev_tx_fifo_size[i] =
- tx_siz[i];
+ core_if->core_params->
+ dev_tx_fifo_size[i] = tx_siz[i];
}
} else {
- params->dev_tx_fifo_size[ep->
- dwc_ep.tx_fifo_num -
- 1] = tx_siz[0];
+ params->dev_tx_fifo_size[ep->dwc_ep.
+ tx_fifo_num - 1] =
+ tx_siz[0];
}
}
retval = -DWC_E_INVALID;
dwc_list_link_t *tmp;
retval = cfi_handle_reset_fifo_val(pcd, addr, 1, 1);
- if (retval < 0) {
+ if (retval < 0)
return retval;
- }
- /* If the EP address is known then reset the features for only that EP */
+ /* If the EP address is known then
+ * reset the features for only that EP */
if (addr) {
cfiep = get_cfi_ep_by_addr(pcd->cfi, addr);
if (NULL == cfiep) {
}
/* Otherwise (wValue == 0), reset all features of all EP's */
else {
- /* Traverse all the active EP's and reset the feature(s) value(s) */
- //list_for_each_entry(cfiep, &cfi->active_eps, lh) {
+ /* Traverse all the active EP's and
+ * reset the feature(s) value(s) */
+ /* list_for_each_entry(cfiep, &cfi->active_eps, lh) { */
DWC_LIST_FOREACH(tmp, &cfi->active_eps) {
cfiep = DWC_LIST_ENTRY(tmp, struct cfi_ep, lh);
retval = cfi_ep_reset_all_setup_vals(cfiep);
cfiobject_t *cfi = pcd->cfi;
dwc_list_link_t *tmp;
- /* If the EP address is known then reset the features for only that EP */
+ /* If the EP address is known then reset
+ * the features for only that EP */
+
if (addr) {
cfiep = get_cfi_ep_by_addr(pcd->cfi, addr);
if (NULL == cfiep) {
}
/* Otherwise (wValue == 0), reset all features of all EP's */
else {
- /* Traverse all the active EP's and reset the feature(s) value(s) */
- //list_for_each_entry(cfiep, &cfi->active_eps, lh) {
+ /* Traverse all the active EP's and
+ * reset the feature(s) value(s) */
+ /* list_for_each_entry(cfiep, &cfi->active_eps, lh) { */
DWC_LIST_FOREACH(tmp, &cfi->active_eps) {
cfiep = DWC_LIST_ENTRY(tmp, struct cfi_ep, lh);
retval = cfi_reset_sg_val(cfiep);
cfiobject_t *cfi = pcd->cfi;
dwc_list_link_t *tmp;
- /* If the EP address is known then reset the features for only that EP */
+ /* If the EP address is known then
+ * reset the features for only that EP */
if (addr) {
cfiep = get_cfi_ep_by_addr(pcd->cfi, addr);
if (NULL == cfiep) {
}
/* Otherwise (wValue == 0), reset all features of all EP's */
else {
- /* Traverse all the active EP's and reset the feature(s) value(s) */
- //list_for_each_entry(cfiep, &cfi->active_eps, lh) {
+ /* Traverse all the active EP's and
+ * reset the feature(s) value(s) */
+ /* list_for_each_entry(cfiep, &cfi->active_eps, lh) { */
DWC_LIST_FOREACH(tmp, &cfi->active_eps) {
cfiep = DWC_LIST_ENTRY(tmp, struct cfi_ep, lh);
retval = cfi_reset_concat_val(cfiep);
/* Otherwise (wValue == 0), reset all features of all EP's */
else {
/* Traverse all the active EP's and reset the feature(s) value(s) */
- //list_for_each_entry(cfiep, &cfi->active_eps, lh) {
+ /* list_for_each_entry(cfiep, &cfi->active_eps, lh) { */
DWC_LIST_FOREACH(tmp, &cfi->active_eps) {
cfiep = DWC_LIST_ENTRY(tmp, struct cfi_ep, lh);
retval = cfi_reset_align_val(cfiep);
/**
* This function sets a new value for the SG buffer setup.
*/
-static int cfi_ep_set_sg_val(uint8_t * buf, struct dwc_otg_pcd *pcd)
+static int cfi_ep_set_sg_val(uint8_t *buf, struct dwc_otg_pcd *pcd)
{
uint8_t inaddr, outaddr;
cfi_ep_t *epin, *epout;
/**
* This function sets a new value for the buffer Alignment setup.
*/
-static int cfi_ep_set_alignment_val(uint8_t * buf, struct dwc_otg_pcd *pcd)
+static int cfi_ep_set_alignment_val(uint8_t *buf, struct dwc_otg_pcd *pcd)
{
cfi_ep_t *ep;
uint8_t addr;
/**
* This function sets a new value for the Concatenation buffer setup.
*/
-static int cfi_ep_set_concat_val(uint8_t * buf, struct dwc_otg_pcd *pcd)
+static int cfi_ep_set_concat_val(uint8_t *buf, struct dwc_otg_pcd *pcd)
{
uint8_t addr;
cfi_ep_t *ep;
/**
* This function calculates the total of all FIFO sizes
- *
+ *
* @param core_if Programming view of DWC_otg controller
*
* @return The total of data FIFO sizes.
*
*/
-static uint16_t get_dfifo_size(dwc_otg_core_if_t * core_if)
+static uint16_t get_dfifo_size(dwc_otg_core_if_t *core_if)
{
dwc_otg_core_params_t *params = core_if->core_params;
uint16_t dfifo_total = 0;
params->dev_rx_fifo_size + params->dev_nperio_tx_fifo_size;
/* Add up each TxFIFO size to the total */
- for (i = 0; i < core_if->hwcfg4.b.num_in_eps; i++) {
+ for (i = 0; i < core_if->hwcfg4.b.num_in_eps; i++)
dfifo_total += params->dev_tx_fifo_size[i];
- }
return dfifo_total;
}
/**
* This function returns Rx FIFO size
- *
+ *
* @param core_if Programming view of DWC_otg controller
*
* @return The total of data FIFO sizes.
*
*/
-static int32_t get_rxfifo_size(dwc_otg_core_if_t * core_if, uint16_t wValue)
+static int32_t get_rxfifo_size(dwc_otg_core_if_t *core_if, uint16_t wValue)
{
switch (wValue >> 8) {
case 0:
/**
* This function returns Tx FIFO size for IN EP
- *
+ *
* @param core_if Programming view of DWC_otg controller
*
* @return The total of data FIFO sizes.
case 0:
return (GET_CORE_IF(pcd)->pwron_txfsiz
[ep->dwc_ep.tx_fifo_num - 1] <
- 768) ? GET_CORE_IF(pcd)->pwron_txfsiz[ep->
- dwc_ep.tx_fifo_num
- - 1] : 32768;
+ 768) ? GET_CORE_IF(pcd)->pwron_txfsiz[ep->dwc_ep.
+ tx_fifo_num -
+ 1] : 32768;
break;
case 1:
- return GET_CORE_IF(pcd)->core_params->
- dev_tx_fifo_size[ep->dwc_ep.num - 1];
+ return GET_CORE_IF(pcd)->core_params->dev_tx_fifo_size[ep->
+ dwc_ep.
+ num - 1];
break;
default:
return -DWC_E_INVALID;
}
/**
- * This function checks if the submitted combination of
+ * This function checks if the submitted combination of
* device mode FIFO sizes is possible or not.
- *
+ *
* @param core_if Programming view of DWC_otg controller
*
* @return 1 if possible, 0 otherwise.
*
*/
-static uint8_t check_fifo_sizes(dwc_otg_core_if_t * core_if)
+static uint8_t check_fifo_sizes(dwc_otg_core_if_t *core_if)
{
uint16_t dfifo_actual = 0;
dwc_otg_core_params_t *params = core_if->core_params;
dfifo_actual =
params->dev_rx_fifo_size + params->dev_nperio_tx_fifo_size;
- for (i = 0; i < core_if->hwcfg4.b.num_in_eps; i++) {
+ for (i = 0; i < core_if->hwcfg4.b.num_in_eps; i++)
dfifo_actual += params->dev_tx_fifo_size[i];
- }
- if (dfifo_actual > core_if->total_fifo_size) {
+ if (dfifo_actual > core_if->total_fifo_size)
return 0;
- }
if (params->dev_rx_fifo_size > 32768 || params->dev_rx_fifo_size < 16)
return 0;
/**
* This function resizes Device mode FIFOs
- *
+ *
* @param core_if Programming view of DWC_otg controller
*
* @return 1 if successful, 0 otherwise
*
*/
-static uint8_t resize_fifos(dwc_otg_core_if_t * core_if)
+static uint8_t resize_fifos(dwc_otg_core_if_t *core_if)
{
int i = 0;
dwc_otg_core_global_regs_t *global_regs = core_if->core_global_regs;
uint16_t start_address;
uint8_t retval = 1;
- if (!check_fifo_sizes(core_if)) {
+ if (!check_fifo_sizes(core_if))
return 0;
- }
/* Configure data FIFO sizes */
if (core_if->hwcfg2.b.dynamic_fifo && params->enable_dynamic_fifo) {
}
/** Check if register values are set correctly */
- if (rx_fifo_size != DWC_READ_REG32(&global_regs->grxfsiz)) {
+ if (rx_fifo_size != DWC_READ_REG32(&global_regs->grxfsiz))
retval = 0;
- }
- if (nptxfifosize.d32 != DWC_READ_REG32(&global_regs->gnptxfsiz)) {
+ if (nptxfifosize.d32 != DWC_READ_REG32(&global_regs->gnptxfsiz))
retval = 0;
- }
for (i = 0; i < core_if->hwcfg4.b.num_in_eps; i++) {
if (txfifosize[i].d32 !=
/**
* This function sets a new value for the buffer Alignment setup.
*/
-static int cfi_ep_set_tx_fifo_val(uint8_t * buf, dwc_otg_pcd_t * pcd)
+static int cfi_ep_set_tx_fifo_val(uint8_t *buf, dwc_otg_pcd_t *pcd)
{
int retval;
uint32_t fsiz;
/**
* This function sets a new value for the buffer Alignment setup.
*/
-static int cfi_set_rx_fifo_val(uint8_t * buf, dwc_otg_pcd_t * pcd)
+static int cfi_set_rx_fifo_val(uint8_t *buf, dwc_otg_pcd_t *pcd)
{
int retval;
uint32_t fsiz;
/**
* This function reads the SG of an EP's buffer setup into the buffer buf
*/
-static int cfi_ep_get_sg_val(uint8_t * buf, struct dwc_otg_pcd *pcd,
+static int cfi_ep_get_sg_val(uint8_t *buf, struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req)
{
int retval = -DWC_E_INVALID;
uint8_t addr;
cfi_ep_t *ep;
- /* The Low Byte of the wValue contains a non-zero address of the endpoint */
+ /* The Low Byte of the wValue contains
+ * a non-zero address of the endpoint */
addr = req->wValue & 0xFF;
if (addr == 0) /* The address should be non-zero */
return retval;
}
/**
- * This function reads the Concatenation value of an EP's buffer mode into
+ * This function reads the Concatenation value of an EP's buffer mode into
* the buffer buf
*/
-static int cfi_ep_get_concat_val(uint8_t * buf, struct dwc_otg_pcd *pcd,
+static int cfi_ep_get_concat_val(uint8_t *buf, struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req)
{
int retval = -DWC_E_INVALID;
cfi_ep_t *ep;
uint8_t desc_count;
- /* The Low Byte of the wValue contains a non-zero address of the endpoint */
+ /* The Low Byte of the wValue contains
+ * a non-zero address of the endpoint */
addr = req->wValue & 0xFF;
if (addr == 0) /* The address should be non-zero */
return retval;
}
/**
- * This function reads the buffer Alignment value of an EP's buffer mode into
+ * This function reads the buffer Alignment value of an EP's buffer mode into
* the buffer buf
*
* @return The total number of bytes copied to the buffer or negative error code.
*/
-static int cfi_ep_get_align_val(uint8_t * buf, struct dwc_otg_pcd *pcd,
+static int cfi_ep_get_align_val(uint8_t *buf, struct dwc_otg_pcd *pcd,
struct cfi_usb_ctrlrequest *req)
{
int retval = -DWC_E_INVALID;
/**
* This function sets a new value for the specified feature
- *
+ *
* @param pcd A pointer to the PCD object
- *
+ *
* @return 0 if successful, negative error code otherwise to stall the DCE.
*/
static int cfi_set_feature_value(struct dwc_otg_pcd *pcd)
switch (wIndex) {
case FT_ID_DMA_BUFFER_SETUP:
/* Modify the feature */
- if ((retval = cfi_ep_set_sg_val(buf, pcd)) < 0)
+ retval = cfi_ep_set_sg_val(buf, pcd);
+ if (retval < 0)
return retval;
/* And send this request to the gadget */
break;
case FT_ID_DMA_BUFF_ALIGN:
- if ((retval = cfi_ep_set_alignment_val(buf, pcd)) < 0)
+ retval = cfi_ep_set_alignment_val(buf, pcd);
+ if (retval < 0)
return retval;
cfi->need_gadget_att = 1;
break;
case FT_ID_DMA_CONCAT_SETUP:
/* Modify the feature */
- if ((retval = cfi_ep_set_concat_val(buf, pcd)) < 0)
+ retval = cfi_ep_set_concat_val(buf, pcd);
+ if (retval < 0)
return retval;
cfi->need_gadget_att = 1;
break;
case FT_ID_TX_FIFO_DEPTH:
CFI_INFO("FT_ID_TX_FIFO_DEPTH\n");
- if ((retval = cfi_ep_set_tx_fifo_val(buf, pcd)) < 0)
+ retval = cfi_ep_set_tx_fifo_val(buf, pcd);
+ if (retval < 0)
return retval;
cfi->need_gadget_att = 0;
break;
case FT_ID_RX_FIFO_DEPTH:
CFI_INFO("FT_ID_RX_FIFO_DEPTH\n");
- if ((retval = cfi_set_rx_fifo_val(buf, pcd)) < 0)
+ retval = cfi_set_rx_fifo_val(buf, pcd);
+ if (retval < 0)
return retval;
cfi->need_gadget_att = 0;
break;
return retval;
}
-#endif //DWC_UTE_CFI
+#endif /* DWC_UTE_CFI */