diff options
author | Emil Renner Berthing <emil.renner.berthing@canonical.com> | 2023-07-22 19:50:49 +0300 |
---|---|---|
committer | Emil Renner Berthing <emil.renner.berthing@canonical.com> | 2024-05-28 13:42:34 +0300 |
commit | 0f5db8641af7bed224244e71db6129e6e71be0d8 (patch) | |
tree | ad055e9ef1962f6e7cbf49b547f673afc670cc0a /drivers/usb | |
parent | b16f680045ec84fe0ed73bdb99af16d2375000d6 (diff) | |
download | linux-0f5db8641af7bed224244e71db6129e6e71be0d8.tar.xz |
usb: cdns3: starfive: Initialize JH7100 host mode
These settings are directly copied from StarFive's port of u-boot
for the JH7100:
/* config strap */
_SET_SYSCON_REG_SCFG_usb0_mode_strap(0x2);
_SET_SYSCON_REG_SCFG_usb7_PLL_EN(0x1);
_SET_SYSCON_REG_SCFG_usb7_U3_EQ_EN(0x1);
_SET_SYSCON_REG_SCFG_usb7_U3_SSRX_SEL(0x1);
_SET_SYSCON_REG_SCFG_usb7_U3_SSTX_SEL(0x1);
_SET_SYSCON_REG_SCFG_usb3_utmi_iddig(0x1);
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 | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/usb/cdns3/cdns3-starfive.c b/drivers/usb/cdns3/cdns3-starfive.c index d122554b65f5..2a0ed1e6ba01 100644 --- a/drivers/usb/cdns3/cdns3-starfive.c +++ b/drivers/usb/cdns3/cdns3-starfive.c @@ -20,6 +20,19 @@ #include <linux/usb/otg.h> #include "core.h" +#define JH7100_USB0 0x20 +#define JH7100_USB0_MODE_STRAP_MASK GENMASK(2, 0) +#define JH7100_USB0_MODE_STRAP_HOST 2 + +#define JH7100_USB3 0x2c +#define JH7100_USB3_UTMI_IDDIG BIT(21) + +#define JH7100_USB7 0x3c +#define JH7100_USB7_SSRX_SEL BIT(18) +#define JH7100_USB7_SSTX_SEL BIT(19) +#define JH7100_USB7_PLL_EN BIT(23) +#define JH7100_USB7_EQ_EN BIT(25) + #define JH7110_STRAP_HOST BIT(17) #define JH7110_STRAP_DEVICE BIT(18) #define JH7110_STRAP_MASK GENMASK(18, 16) @@ -42,6 +55,36 @@ typedef int (cdns_starfive_mode_init_t)(struct device *dev, struct cdns_starfive static int cdns_jh7100_mode_init(struct device *dev, struct cdns_starfive *data) { + struct regmap *syscon; + enum usb_dr_mode mode; + + syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "starfive,syscon"); + if (IS_ERR(syscon)) + return dev_err_probe(dev, PTR_ERR(syscon), + "failed to get starfive,syscon\n"); + + /* dr mode setting */ + mode = usb_get_dr_mode(dev); + + switch (mode) { + case USB_DR_MODE_HOST: + regmap_update_bits(syscon, JH7100_USB0, + JH7100_USB0_MODE_STRAP_MASK, JH7100_USB0_MODE_STRAP_HOST); + regmap_update_bits(syscon, JH7100_USB7, + JH7100_USB7_PLL_EN, JH7100_USB7_PLL_EN); + regmap_update_bits(syscon, JH7100_USB7, + JH7100_USB7_EQ_EN, JH7100_USB7_EQ_EN); + regmap_update_bits(syscon, JH7100_USB7, + JH7100_USB7_SSRX_SEL, JH7100_USB7_SSRX_SEL); + regmap_update_bits(syscon, JH7100_USB7, + JH7100_USB7_SSTX_SEL, JH7100_USB7_SSTX_SEL); + regmap_update_bits(syscon, JH7100_USB3, + JH7100_USB3_UTMI_IDDIG, JH7100_USB3_UTMI_IDDIG); + break; + default: + break; + } + return 0; } |