diff options
author | Emil Renner Berthing <emil.renner.berthing@canonical.com> | 2023-07-22 17:21:04 +0300 |
---|---|---|
committer | Emil Renner Berthing <emil.renner.berthing@canonical.com> | 2024-05-28 13:42:33 +0300 |
commit | 6f2708aad7ea1ad607ab77389eb562bc5a2b1a65 (patch) | |
tree | 275882198098cf3114a0ee873a181f1dc3e70baf | |
parent | 77568ee373a62d4193f2bd74a1ead5a0cd2f887c (diff) | |
download | linux-6f2708aad7ea1ad607ab77389eb562bc5a2b1a65.tar.xz |
usb: cdns3: starfive: Add StarFive JH7100 support
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
-rw-r--r-- | drivers/usb/cdns3/cdns3-starfive.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/drivers/usb/cdns3/cdns3-starfive.c b/drivers/usb/cdns3/cdns3-starfive.c index 74a1238176ea..d122554b65f5 100644 --- a/drivers/usb/cdns3/cdns3-starfive.c +++ b/drivers/usb/cdns3/cdns3-starfive.c @@ -20,17 +20,17 @@ #include <linux/usb/otg.h> #include "core.h" -#define USB_STRAP_HOST BIT(17) -#define USB_STRAP_DEVICE BIT(18) -#define USB_STRAP_MASK GENMASK(18, 16) +#define JH7110_STRAP_HOST BIT(17) +#define JH7110_STRAP_DEVICE BIT(18) +#define JH7110_STRAP_MASK GENMASK(18, 16) -#define USB_SUSPENDM_HOST BIT(19) -#define USB_SUSPENDM_MASK BIT(19) +#define JH7110_SUSPENDM_HOST BIT(19) +#define JH7110_SUSPENDM_MASK BIT(19) -#define USB_MISC_CFG_MASK GENMASK(23, 20) -#define USB_SUSPENDM_BYPS BIT(20) -#define USB_PLL_EN BIT(22) -#define USB_REFCLK_MODE BIT(23) +#define JH7110_MISC_CFG_MASK GENMASK(23, 20) +#define JH7110_SUSPENDM_BYPS BIT(20) +#define JH7110_PLL_EN BIT(22) +#define JH7110_REFCLK_MODE BIT(23) struct cdns_starfive { struct reset_control *resets; @@ -38,7 +38,14 @@ struct cdns_starfive { int num_clks; }; -static int cdns_mode_init(struct device *dev, struct cdns_starfive *data) +typedef int (cdns_starfive_mode_init_t)(struct device *dev, struct cdns_starfive *data); + +static int cdns_jh7100_mode_init(struct device *dev, struct cdns_starfive *data) +{ + return 0; +} + +static int cdns_jh7110_mode_init(struct device *dev, struct cdns_starfive *data) { struct regmap *syscon; unsigned int usb_mode; @@ -51,21 +58,21 @@ static int cdns_mode_init(struct device *dev, struct cdns_starfive *data) "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); + JH7110_MISC_CFG_MASK, + JH7110_SUSPENDM_BYPS | JH7110_PLL_EN | JH7110_REFCLK_MODE); /* dr mode setting */ mode = usb_get_dr_mode(dev); switch (mode) { case USB_DR_MODE_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); + regmap_update_bits(syscon, usb_mode, JH7110_STRAP_MASK, JH7110_STRAP_HOST); + regmap_update_bits(syscon, usb_mode, JH7110_SUSPENDM_MASK, JH7110_SUSPENDM_HOST); break; case USB_DR_MODE_PERIPHERAL: - regmap_update_bits(syscon, usb_mode, USB_STRAP_MASK, USB_STRAP_DEVICE); - regmap_update_bits(syscon, usb_mode, USB_SUSPENDM_MASK, 0); + regmap_update_bits(syscon, usb_mode, JH7110_STRAP_MASK, JH7110_STRAP_DEVICE); + regmap_update_bits(syscon, usb_mode, JH7110_SUSPENDM_MASK, 0); break; default: break; @@ -105,6 +112,7 @@ static int cdns_starfive_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct cdns_starfive *data; + cdns_starfive_mode_init_t *mode_init; int ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -119,7 +127,8 @@ static int cdns_starfive_probe(struct platform_device *pdev) if (IS_ERR(data->resets)) return dev_err_probe(dev, PTR_ERR(data->resets), "failed to get resets\n"); - ret = cdns_mode_init(dev, data); + mode_init = device_get_match_data(dev); + ret = mode_init(dev, data); if (ret) return ret; @@ -207,7 +216,8 @@ static const struct dev_pm_ops cdns_starfive_pm_ops = { }; static const struct of_device_id cdns_starfive_of_match[] = { - { .compatible = "starfive,jh7110-usb", }, + { .compatible = "starfive,jh7100-usb", .data = cdns_jh7100_mode_init }, + { .compatible = "starfive,jh7110-usb", .data = cdns_jh7110_mode_init }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, cdns_starfive_of_match); |