usb: dwc2: Remove dwc2_set_all_params function
Replace this by statically defining a function with defaults, and just assigning it. This will allow us to use parameters of any type and any default value. Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
parent
334bbd4ebe
commit
0a7d0d7fa8
|
@ -1252,8 +1252,6 @@ extern void dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val);
|
||||||
extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
|
extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
|
||||||
const struct dwc2_core_params *params);
|
const struct dwc2_core_params *params);
|
||||||
|
|
||||||
extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
|
|
||||||
|
|
||||||
extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
|
extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
|
||||||
|
|
||||||
extern int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg);
|
extern int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg);
|
||||||
|
|
|
@ -197,6 +197,44 @@ static const struct dwc2_core_params params_amlogic = {
|
||||||
.hibernation = -1,
|
.hibernation = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct dwc2_core_params params_default = {
|
||||||
|
.otg_cap = -1,
|
||||||
|
.otg_ver = -1,
|
||||||
|
.dma_enable = -1,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Disable descriptor dma mode by default as the HW can support
|
||||||
|
* it, but does not support it for SPLIT transactions.
|
||||||
|
* Disable it for FS devices as well.
|
||||||
|
*/
|
||||||
|
.dma_desc_enable = 0,
|
||||||
|
.dma_desc_fs_enable = 0,
|
||||||
|
|
||||||
|
.speed = -1,
|
||||||
|
.enable_dynamic_fifo = -1,
|
||||||
|
.en_multiple_tx_fifo = -1,
|
||||||
|
.host_rx_fifo_size = -1,
|
||||||
|
.host_nperio_tx_fifo_size = -1,
|
||||||
|
.host_perio_tx_fifo_size = -1,
|
||||||
|
.max_transfer_size = -1,
|
||||||
|
.max_packet_count = -1,
|
||||||
|
.host_channels = -1,
|
||||||
|
.phy_type = -1,
|
||||||
|
.phy_utmi_width = -1,
|
||||||
|
.phy_ulpi_ddr = -1,
|
||||||
|
.phy_ulpi_ext_vbus = -1,
|
||||||
|
.i2c_enable = -1,
|
||||||
|
.ulpi_fs_ls = -1,
|
||||||
|
.host_support_fs_ls_low_power = -1,
|
||||||
|
.host_ls_low_power_phy_clk = -1,
|
||||||
|
.ts_dline = -1,
|
||||||
|
.reload_ctl = -1,
|
||||||
|
.ahbcfg = -1,
|
||||||
|
.uframe_sched = -1,
|
||||||
|
.external_id_pin_ctl = -1,
|
||||||
|
.hibernation = -1,
|
||||||
|
};
|
||||||
|
|
||||||
const struct of_device_id dwc2_of_match_table[] = {
|
const struct of_device_id dwc2_of_match_table[] = {
|
||||||
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
|
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
|
||||||
{ .compatible = "hisilicon,hi6220-usb", .data = ¶ms_hi6220 },
|
{ .compatible = "hisilicon,hi6220-usb", .data = ¶ms_hi6220 },
|
||||||
|
@ -1109,46 +1147,18 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets all parameters to the given value.
|
|
||||||
*
|
|
||||||
* Assumes that the dwc2_core_params struct contains only integers.
|
|
||||||
*/
|
|
||||||
void dwc2_set_all_params(struct dwc2_core_params *params, int value)
|
|
||||||
{
|
|
||||||
int *p = (int *)params;
|
|
||||||
size_t size = sizeof(*params) / sizeof(*p);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
p[i] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dwc2_init_params(struct dwc2_hsotg *hsotg)
|
int dwc2_init_params(struct dwc2_hsotg *hsotg)
|
||||||
{
|
{
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
const struct dwc2_core_params *params;
|
struct dwc2_core_params params;
|
||||||
struct dwc2_core_params defparams;
|
|
||||||
|
|
||||||
match = of_match_device(dwc2_of_match_table, hsotg->dev);
|
match = of_match_device(dwc2_of_match_table, hsotg->dev);
|
||||||
if (match && match->data) {
|
if (match && match->data)
|
||||||
params = match->data;
|
params = *((struct dwc2_core_params *)match->data);
|
||||||
} else {
|
else
|
||||||
/* Default all params to autodetect */
|
params = params_default;
|
||||||
dwc2_set_all_params(&defparams, -1);
|
|
||||||
params = &defparams;
|
|
||||||
|
|
||||||
/*
|
dwc2_set_parameters(hsotg, ¶ms);
|
||||||
* Disable descriptor dma mode by default as the HW can support
|
|
||||||
* it, but does not support it for SPLIT transactions.
|
|
||||||
* Disable it for FS devices as well.
|
|
||||||
*/
|
|
||||||
defparams.dma_desc_enable = 0;
|
|
||||||
defparams.dma_desc_fs_enable = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Validate parameter values */
|
|
||||||
dwc2_set_parameters(hsotg, params);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,8 +398,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
|
||||||
|
|
||||||
spin_lock_init(&hsotg->lock);
|
spin_lock_init(&hsotg->lock);
|
||||||
|
|
||||||
dwc2_set_all_params(&hsotg->params, -1);
|
|
||||||
|
|
||||||
hsotg->irq = platform_get_irq(dev, 0);
|
hsotg->irq = platform_get_irq(dev, 0);
|
||||||
if (hsotg->irq < 0) {
|
if (hsotg->irq < 0) {
|
||||||
dev_err(&dev->dev, "missing IRQ resource\n");
|
dev_err(&dev->dev, "missing IRQ resource\n");
|
||||||
|
|
Loading…
Reference in New Issue