Skip to content

Commit 6b99262

Browse files
xdarklightvinodkoul
authored andcommitted
phy: amlogic: meson8b-usb2: Don't set REG_ADP_BC_ACA_ENABLE on Meson8
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: 4a3449d ("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>
1 parent de143a4 commit 6b99262

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

‎drivers/phy/amlogic/phy-meson8b-usb2.c‎

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/io.h>
1111
#include <linux/module.h>
1212
#include <linux/of_device.h>
13+
#include <linux/property.h>
1314
#include <linux/regmap.h>
1415
#include <linux/reset.h>
1516
#include <linux/phy/phy.h>
@@ -105,12 +106,17 @@
105106
#define RESET_COMPLETE_TIME 500
106107
#define ACA_ENABLE_COMPLETE_TIME 50
107108

109+
struct phy_meson8b_usb2_match_data {
110+
bool host_enable_aca;
111+
};
112+
108113
struct phy_meson8b_usb2_priv {
109-
struct regmap *regmap;
110-
enum usb_dr_mode dr_mode;
111-
struct clk *clk_usb_general;
112-
struct clk *clk_usb;
113-
struct reset_control *reset;
114+
struct regmap *regmap;
115+
enum usb_dr_mode dr_mode;
116+
struct clk *clk_usb_general;
117+
struct clk *clk_usb;
118+
struct reset_control *reset;
119+
const struct phy_meson8b_usb2_match_data *match;
114120
};
115121

116122
static const struct regmap_config phy_meson8b_usb2_regmap_conf = {
@@ -166,7 +172,8 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
166172
regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT,
167173
REG_CTRL_SOF_TOGGLE_OUT);
168174

169-
if (priv->dr_mode == USB_DR_MODE_HOST) {
175+
if (priv->dr_mode == USB_DR_MODE_HOST &&
176+
priv->match->host_enable_aca) {
170177
regmap_update_bits(priv->regmap, REG_ADP_BC,
171178
REG_ADP_BC_ACA_ENABLE,
172179
REG_ADP_BC_ACA_ENABLE);
@@ -216,6 +223,10 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)
216223
if (IS_ERR(base))
217224
return PTR_ERR(base);
218225

226+
priv->match = device_get_match_data(&pdev->dev);
227+
if (!priv->match)
228+
return -ENODEV;
229+
219230
priv->regmap = devm_regmap_init_mmio(&pdev->dev, base,
220231
&phy_meson8b_usb2_regmap_conf);
221232
if (IS_ERR(priv->regmap))
@@ -254,11 +265,28 @@ static int phy_meson8b_usb2_probe(struct platform_device *pdev)
254265
return PTR_ERR_OR_ZERO(phy_provider);
255266
}
256267

268+
static const struct phy_meson8b_usb2_match_data phy_meson8_usb2_match_data = {
269+
.host_enable_aca = false,
270+
};
271+
272+
static const struct phy_meson8b_usb2_match_data phy_meson8b_usb2_match_data = {
273+
.host_enable_aca = true,
274+
};
275+
257276
static const struct of_device_id phy_meson8b_usb2_of_match[] = {
258-
{ .compatible = "amlogic,meson8-usb2-phy", },
259-
{ .compatible = "amlogic,meson8b-usb2-phy", },
260-
{ .compatible = "amlogic,meson-gxbb-usb2-phy", },
261-
{ },
277+
{
278+
.compatible = "amlogic,meson8-usb2-phy",
279+
.data = &phy_meson8_usb2_match_data
280+
},
281+
{
282+
.compatible = "amlogic,meson8b-usb2-phy",
283+
.data = &phy_meson8b_usb2_match_data
284+
},
285+
{
286+
.compatible = "amlogic,meson-gxbb-usb2-phy",
287+
.data = &phy_meson8b_usb2_match_data
288+
},
289+
{ /* sentinel */ }
262290
};
263291
MODULE_DEVICE_TABLE(of, phy_meson8b_usb2_of_match);
264292

0 commit comments

Comments
 (0)