diff options
author | Emil Renner Berthing <emil.renner.berthing@canonical.com> | 2023-07-22 16:59:02 +0300 |
---|---|---|
committer | Emil Renner Berthing <emil.renner.berthing@canonical.com> | 2024-05-28 13:42:33 +0300 |
commit | 630ef736a2bf9387d5dccf63a77a1c62a72647dd (patch) | |
tree | 73060ac35103aa575434e62c32e2f2db4ff11bb3 /drivers/usb | |
parent | 6e76370f88c694a271a743b5acdcae31cd542a1d (diff) | |
download | linux-630ef736a2bf9387d5dccf63a77a1c62a72647dd.tar.xz |
usb: cdns3: starfive: Simplify mode init
The syscon regmap and offset to the USB mode register is only used at
probe time, so there is no need to store it in the device data. Just get
the regmap pointer in the cdns_mode_init() function where it is needed.
Also this function never uses the platform device, so just pass the
device pointer directly.
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/cdns3/cdns3-starfive.c | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/drivers/usb/cdns3/cdns3-starfive.c b/drivers/usb/cdns3/cdns3-starfive.c index c04d196abd87..dc941dbae723 100644 --- a/drivers/usb/cdns3/cdns3-starfive.c +++ b/drivers/usb/cdns3/cdns3-starfive.c @@ -34,46 +34,45 @@ struct cdns_starfive { struct device *dev; - struct regmap *stg_syscon; struct reset_control *resets; struct clk_bulk_data *clks; int num_clks; - u32 stg_usb_mode; }; -static void cdns_mode_init(struct platform_device *pdev, - struct cdns_starfive *data) +static int cdns_mode_init(struct device *dev, struct cdns_starfive *data) { + struct regmap *syscon; + unsigned int usb_mode; enum usb_dr_mode mode; - regmap_update_bits(data->stg_syscon, data->stg_usb_mode, + syscon = syscon_regmap_lookup_by_phandle_args(dev->of_node, + "starfive,stg-syscon", 1, &usb_mode); + if (IS_ERR(syscon)) + return dev_err_probe(dev, PTR_ERR(syscon), + "Failed to parse starfive,stg-syscon\n"); + + regmap_update_bits(syscon, usb_mode, USB_MISC_CFG_MASK, USB_SUSPENDM_BYPS | USB_PLL_EN | USB_REFCLK_MODE); /* dr mode setting */ - mode = usb_get_dr_mode(&pdev->dev); + mode = usb_get_dr_mode(dev); switch (mode) { case USB_DR_MODE_HOST: - regmap_update_bits(data->stg_syscon, - data->stg_usb_mode, - USB_STRAP_MASK, - USB_STRAP_HOST); - regmap_update_bits(data->stg_syscon, - data->stg_usb_mode, - USB_SUSPENDM_MASK, - USB_SUSPENDM_HOST); + regmap_update_bits(syscon, usb_mode, USB_STRAP_MASK, USB_STRAP_HOST); + regmap_update_bits(syscon, usb_mode, USB_SUSPENDM_MASK, USB_SUSPENDM_HOST); break; case USB_DR_MODE_PERIPHERAL: - regmap_update_bits(data->stg_syscon, data->stg_usb_mode, - USB_STRAP_MASK, USB_STRAP_DEVICE); - regmap_update_bits(data->stg_syscon, data->stg_usb_mode, - USB_SUSPENDM_MASK, 0); + regmap_update_bits(syscon, usb_mode, USB_STRAP_MASK, USB_STRAP_DEVICE); + regmap_update_bits(syscon, usb_mode, USB_SUSPENDM_MASK, 0); break; default: break; } + + return 0; } static int cdns_clk_rst_init(struct cdns_starfive *data) @@ -108,7 +107,6 @@ static int cdns_starfive_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct cdns_starfive *data; - unsigned int args; int ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -117,16 +115,6 @@ static int cdns_starfive_probe(struct platform_device *pdev) data->dev = dev; - data->stg_syscon = - syscon_regmap_lookup_by_phandle_args(pdev->dev.of_node, - "starfive,stg-syscon", 1, &args); - - if (IS_ERR(data->stg_syscon)) - return dev_err_probe(dev, PTR_ERR(data->stg_syscon), - "Failed to parse starfive,stg-syscon\n"); - - data->stg_usb_mode = args; - data->num_clks = devm_clk_bulk_get_all(data->dev, &data->clks); if (data->num_clks < 0) return dev_err_probe(data->dev, -ENODEV, @@ -137,7 +125,10 @@ static int cdns_starfive_probe(struct platform_device *pdev) return dev_err_probe(data->dev, PTR_ERR(data->resets), "Failed to get resets"); - cdns_mode_init(pdev, data); + ret = cdns_mode_init(dev, data); + if (ret) + return ret; + ret = cdns_clk_rst_init(data); if (ret) return ret; |