phy: amlogic: meson8b-usb2: Don't set REG_ADP_BC_ACA_ENABLE on Meson8
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>
Tue, 12 May 2020 22:24:22 +0000 (00:24 +0200)
committerVinod Koul <vkoul@kernel.org>
Fri, 15 May 2020 07:46:55 +0000 (13:16 +0530)
Skip setting REG_ADP_BC_ACA_ENABLE on Meson8 SoCs and polling for the
REG_ADP_BC_ACA_PIN_FLOAT bit. The vendor also skips this part on Meson8
SoCs.
This fixes initialization of the host-only USB PHY on Meson8 which would
otherwise fail with "USB ID detect failed!".

Fixes: 4a3449d1a0a10c ("phy: meson8b-usb2: add support for the USB PHY on Meson8 SoCs")
Reported-by: Thomas Graichen <thomas.graichen@gmail.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Tested-by: Thomas Graichen <thomas.graichen@gmail.com>
Link: https://lore.kernel.org/r/20200512222424.549351-5-martin.blumenstingl@googlemail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/amlogic/phy-meson8b-usb2.c

index 86824cc..7236b88 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 #include <linux/phy/phy.h>
 #define RESET_COMPLETE_TIME                            500
 #define ACA_ENABLE_COMPLETE_TIME                       50
 
+struct phy_meson8b_usb2_match_data {
+       bool                    host_enable_aca;
+};
+
 struct phy_meson8b_usb2_priv {
-       struct regmap           *regmap;
-       enum usb_dr_mode        dr_mode;
-       struct clk              *clk_usb_general;
-       struct clk              *clk_usb;
-       struct reset_control    *reset;
+       struct regmap                                   *regmap;
+       enum usb_dr_mode                                dr_mode;
+       struct clk                                      *clk_usb_general;
+       struct clk                                      *clk_usb;
+       struct reset_control                            *reset;
+       const struct phy_meson8b_usb2_match_data        *match;
 };
 
 static const struct regmap_config phy_meson8b_usb2_regmap_conf = {
@@ -166,7 +172,8 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
        regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT,
                           REG_CTRL_SOF_TOGGLE_OUT);
 
-       if (priv->dr_mode == USB_DR_MODE_HOST) {
+       if (priv->dr_mode == USB_DR_MODE_HOST &&
+           priv->match->host_enable_aca) {
                regmap_update_bits(priv->regmap, REG_ADP_BC,
                                   REG_ADP_BC_ACA_ENABLE,
                                   REG_ADP_BC_ACA_ENABLE);
@@ -216,6 +223,10 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)
        if (IS_ERR(base))
                return PTR_ERR(base);
 
+       priv->match = device_get_match_data(&pdev->dev);
+       if (!priv->match)
+               return -ENODEV;
+
        priv->regmap = devm_regmap_init_mmio(&pdev->dev, base,
                                             &phy_meson8b_usb2_regmap_conf);
        if (IS_ERR(priv->regmap))
@@ -254,11 +265,28 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)
        return PTR_ERR_OR_ZERO(phy_provider);
 }
 
+static const struct phy_meson8b_usb2_match_data phy_meson8_usb2_match_data = {
+       .host_enable_aca = false,
+};
+
+static const struct phy_meson8b_usb2_match_data phy_meson8b_usb2_match_data = {
+       .host_enable_aca = true,
+};
+
 static const struct of_device_id phy_meson8b_usb2_of_match[] = {
-       { .compatible = "amlogic,meson8-usb2-phy", },
-       { .compatible = "amlogic,meson8b-usb2-phy", },
-       { .compatible = "amlogic,meson-gxbb-usb2-phy", },
-       { },
+       {
+               .compatible = "amlogic,meson8-usb2-phy",
+               .data = &phy_meson8_usb2_match_data
+       },
+       {
+               .compatible = "amlogic,meson8b-usb2-phy",
+               .data = &phy_meson8b_usb2_match_data
+       },
+       {
+               .compatible = "amlogic,meson-gxbb-usb2-phy",
+               .data = &phy_meson8b_usb2_match_data
+       },
+       { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, phy_meson8b_usb2_of_match);