linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hex dump <hexdump0815@gmail.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: kishon@ti.com, robh+dt@kernel.org, vkoul@kernel.org,
	devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org,
	narmstrong@baylibre.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] phy: amlogic: meson8b-usb2: Don't set REG_ADP_BC_ACA_ENABLE on Meson8
Date: Mon, 4 May 2020 12:59:14 +0200	[thread overview]
Message-ID: <CAKTihDWOZMHs5Bq++NeyE=VoyKBkAkfEXbr5QY29k=2XEr4K1g@mail.gmail.com> (raw)
In-Reply-To: <20200502114752.1048500-5-martin.blumenstingl@googlemail.com>

On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:
>
> 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: hexdump <hexdump0815@googlemail.com>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Tested-by: hexdump <hexdump0815@googlemail.com>

BEFORE: usb failed with:
[    3.451386] dwc2 c9040000.usb: c9040000.usb supply vusb_d not
found, using dummy regulator
[    3.454097] dwc2 c9040000.usb: c9040000.usb supply vusb_a not
found, using dummy regulator
[    3.463602] phy phy-c1108800.phy.0: USB ID detect failed!
[    3.467646] phy phy-c1108800.phy.0: phy poweron failed --> -22

AFTER: usb is detected and working fine on my mxiiii meson8 box

> ---
>  drivers/phy/amlogic/phy-meson8b-usb2.c | 48 ++++++++++++++++++++------
>  1 file changed, 38 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
> index 86824cc21f11..7236b8885f07 100644
> --- a/drivers/phy/amlogic/phy-meson8b-usb2.c
> +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
> @@ -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>
> @@ -105,12 +106,17 @@
>  #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);
>
> --
> 2.26.2
>

  reply	other threads:[~2020-05-04 10:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-02 11:47 [PATCH 0/6] phy: meson8b-usb2: small fixes and improvements Martin Blumenstingl
2020-05-02 11:47 ` [PATCH 1/6] dt-bindings: phy: meson8b-usb2: Convert to json-schema Martin Blumenstingl
2020-05-04 10:55   ` hex dump
2020-05-04 17:31     ` Joe Perches
2020-05-05  5:06       ` Vinod Koul
2020-05-12 22:03   ` Rob Herring
2020-05-02 11:47 ` [PATCH 2/6] dt-bindings: phy: meson8b-usb2: Add compatible string for Meson8m2 Martin Blumenstingl
2020-05-04 10:57   ` hex dump
2020-05-12 22:03   ` Rob Herring
2020-05-02 11:47 ` [PATCH 3/6] phy: amlogic: meson8b-usb2: Use a MMIO regmap Martin Blumenstingl
2020-05-04 10:57   ` hex dump
2020-05-02 11:47 ` [PATCH 4/6] phy: amlogic: meson8b-usb2: Don't set REG_ADP_BC_ACA_ENABLE on Meson8 Martin Blumenstingl
2020-05-04 10:59   ` hex dump [this message]
2020-05-02 11:47 ` [PATCH 5/6] phy: amlogic: meson8b-usb2: unset the IDDQ bit during PHY power-on Martin Blumenstingl
2020-05-04 11:00   ` hex dump
2020-05-02 11:47 ` [PATCH 6/6] phy: amlogic: meson8b-usb2: Add a compatible string for Meson8m2 Martin Blumenstingl
2020-05-04 11:01   ` hex dump

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKTihDWOZMHs5Bq++NeyE=VoyKBkAkfEXbr5QY29k=2XEr4K1g@mail.gmail.com' \
    --to=hexdump0815@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).