author: Emil Renner Berthing <emil.renner.berthing@canonical.com> 2023-07-22 16:21:04 +0200
committer: Emil Renner Berthing <emil.renner.berthing@canonical.com> 2024-01-30 15:22:25 +0100
commit: 2a7c96c1a9707bb9b1c213e28a8ad373ede4f565
parent: 5293f377ba6e684ae022034fbd07d4f8b10a257d
Commit Summary:
Diffstat:
1 file changed, 26 insertions, 18 deletions
diff --git a/drivers/usb/cdns3/cdns3-starfive.c b/drivers/usb/cdns3/cdns3-starfive.c
index 03b66787fc6f..f9907ca0a04a 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;
@@ -208,7 +217,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);