static void dwc2_check_param_tx_fifo_sizes(struct dwc2_hsotg *hsotg) { int fifo_count; int fifo; int min; u32 total = 0; u32 dptxfszn; fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); min = hsotg->hw_params.en_multiple_tx_fifo ? 16 : 4; for (fifo = 1; fifo <= fifo_count; fifo++) total += hsotg->params.g_tx_fifo_size[fifo]; if (total > dwc2_hsotg_tx_fifo_total_depth(hsotg) || !total) { dev_warn(hsotg->dev, "%s: Invalid parameter g-tx-fifo-size, setting to default average\n", __func__); dwc2_set_param_tx_fifo_sizes(hsotg); } for (fifo = 1; fifo <= fifo_count; fifo++) { dptxfszn = (dwc2_readl(hsotg->regs + DPTXFSIZN(fifo)) & FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; if (hsotg->params.g_tx_fifo_size[fifo] < min || hsotg->params.g_tx_fifo_size[fifo] > dptxfszn) { dev_warn(hsotg->dev, "%s: Invalid parameter g_tx_fifo_size[%d]=%d\n", __func__, fifo, hsotg->params.g_tx_fifo_size[fifo]); hsotg->params.g_tx_fifo_size[fifo] = dptxfszn; } } }
/* * Gets device hardware parameters. Forces device mode if not * currently in device mode. Should be called immediately after a core * soft reset in order to get the reset values. */ static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg) { struct dwc2_hw_params *hw = &hsotg->hw_params; u32 gnptxfsiz; int fifo, fifo_count; if (hsotg->dr_mode == USB_DR_MODE_HOST) return; dwc2_force_mode(hsotg, false); gnptxfsiz = dwc2_readl(hsotg, GNPTXFSIZ); fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); for (fifo = 1; fifo <= fifo_count; fifo++) { hw->g_tx_fifo_size[fifo] = (dwc2_readl(hsotg, DPTXFSIZN(fifo)) & FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; } hw->dev_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >> FIFOSIZE_DEPTH_SHIFT; }