Commit 5174564c authored by Neil Armstrong's avatar Neil Armstrong Committed by Felipe Balbi

usb: dwc3: meson-g12a: specify phy names in soc data

To handle the variable USB2 PHY counts on GXL and GXM SoCs, add the
possible PHY names for each SoC in the compatible match data.
Reviewed-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: default avatarHanjie Lin <hanjie.lin@amlogic.com>
Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 8f385b67
...@@ -96,16 +96,8 @@ ...@@ -96,16 +96,8 @@
#define USB_R5_ID_DIG_TH_MASK GENMASK(15, 8) #define USB_R5_ID_DIG_TH_MASK GENMASK(15, 8)
#define USB_R5_ID_DIG_CNT_MASK GENMASK(23, 16) #define USB_R5_ID_DIG_CNT_MASK GENMASK(23, 16)
enum { #define PHY_COUNT 3
USB2_HOST_PHY = 0, #define USB2_OTG_PHY 1
USB2_OTG_PHY,
USB3_HOST_PHY,
PHY_COUNT,
};
static const char *phy_names[PHY_COUNT] = {
"usb2-phy0", "usb2-phy1", "usb3-phy0",
};
static struct clk_bulk_data meson_g12a_clocks[] = { static struct clk_bulk_data meson_g12a_clocks[] = {
{ .id = NULL }, { .id = NULL },
...@@ -117,22 +109,44 @@ static struct clk_bulk_data meson_a1_clocks[] = { ...@@ -117,22 +109,44 @@ static struct clk_bulk_data meson_a1_clocks[] = {
{ .id = "xtal_usb_ctrl" }, { .id = "xtal_usb_ctrl" },
}; };
static const char *meson_g12a_phy_names[] = {
"usb2-phy0", "usb2-phy1", "usb3-phy0",
};
/*
* Amlogic A1 has a single physical PHY, in slot 1, but still has the
* two U2 PHY controls register blocks like G12A.
* Handling the first PHY on slot 1 would need a large amount of code
* changes, and the current management is generic enough to handle it
* correctly when only the "usb2-phy1" phy is specified on-par with the
* DT bindings.
*/
static const char *meson_a1_phy_names[] = {
"usb2-phy0", "usb2-phy1"
};
struct dwc3_meson_g12a_drvdata { struct dwc3_meson_g12a_drvdata {
bool otg_switch_supported; bool otg_switch_supported;
struct clk_bulk_data *clks; struct clk_bulk_data *clks;
int num_clks; int num_clks;
const char **phy_names;
int num_phys;
}; };
static struct dwc3_meson_g12a_drvdata g12a_drvdata = { static struct dwc3_meson_g12a_drvdata g12a_drvdata = {
.otg_switch_supported = true, .otg_switch_supported = true,
.clks = meson_g12a_clocks, .clks = meson_g12a_clocks,
.num_clks = ARRAY_SIZE(meson_g12a_clocks), .num_clks = ARRAY_SIZE(meson_g12a_clocks),
.phy_names = meson_g12a_phy_names,
.num_phys = ARRAY_SIZE(meson_g12a_phy_names),
}; };
static struct dwc3_meson_g12a_drvdata a1_drvdata = { static struct dwc3_meson_g12a_drvdata a1_drvdata = {
.otg_switch_supported = false, .otg_switch_supported = false,
.clks = meson_a1_clocks, .clks = meson_a1_clocks,
.num_clks = ARRAY_SIZE(meson_a1_clocks), .num_clks = ARRAY_SIZE(meson_a1_clocks),
.phy_names = meson_a1_phy_names,
.num_phys = ARRAY_SIZE(meson_a1_phy_names),
}; };
struct dwc3_meson_g12a { struct dwc3_meson_g12a {
...@@ -171,10 +185,13 @@ static int dwc3_meson_g12a_usb2_init(struct dwc3_meson_g12a *priv) ...@@ -171,10 +185,13 @@ static int dwc3_meson_g12a_usb2_init(struct dwc3_meson_g12a *priv)
else else
priv->otg_phy_mode = PHY_MODE_USB_HOST; priv->otg_phy_mode = PHY_MODE_USB_HOST;
for (i = 0 ; i < USB3_HOST_PHY ; ++i) { for (i = 0; i < priv->drvdata->num_phys; ++i) {
if (!priv->phys[i]) if (!priv->phys[i])
continue; continue;
if (!strstr(priv->drvdata->phy_names[i], "usb2"))
continue;
regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i),
U2P_R0_POWER_ON_RESET, U2P_R0_POWER_ON_RESET,
U2P_R0_POWER_ON_RESET); U2P_R0_POWER_ON_RESET);
...@@ -284,17 +301,19 @@ static const struct regmap_config phy_meson_g12a_usb3_regmap_conf = { ...@@ -284,17 +301,19 @@ static const struct regmap_config phy_meson_g12a_usb3_regmap_conf = {
static int dwc3_meson_g12a_get_phys(struct dwc3_meson_g12a *priv) static int dwc3_meson_g12a_get_phys(struct dwc3_meson_g12a *priv)
{ {
const char *phy_name;
int i; int i;
for (i = 0 ; i < PHY_COUNT ; ++i) { for (i = 0 ; i < priv->drvdata->num_phys ; ++i) {
priv->phys[i] = devm_phy_optional_get(priv->dev, phy_names[i]); phy_name = priv->drvdata->phy_names[i];
priv->phys[i] = devm_phy_optional_get(priv->dev, phy_name);
if (!priv->phys[i]) if (!priv->phys[i])
continue; continue;
if (IS_ERR(priv->phys[i])) if (IS_ERR(priv->phys[i]))
return PTR_ERR(priv->phys[i]); return PTR_ERR(priv->phys[i]);
if (i == USB3_HOST_PHY) if (strstr(phy_name, "usb3"))
priv->usb3_ports++; priv->usb3_ports++;
else else
priv->usb2_ports++; priv->usb2_ports++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment