This is a batch of fixes and improvements for the phy-meson8b-usb2
driver:
- convert the existing dt-bindings to json-schema and add a fallback
compatible string which is already in existing .dtsi files
- differentiate between Meson8 and Meson8m2 using a new compatible
string for the latter
- simplify the code by using a MMIO regmap
- set / unset the IDDQ and ACA enable bits depending on the operating
mode (and for the latter also the compatible string)
I suggest that all of these are applied to -next because we will need a
separate .dts patch (which I already have prepared) to use the new
Meson8m2 compatible string in meson8m2.dtsi. Otherwise we will be
changing behavior in patch #4, because meson8m2.dtsi currently inherits
the Meson8 compatible string.
The number of actual Meson8 users is very small (I only know one case),
so keeping Meson8m2 working is more important to me (because I know
several users with boards that have a Meson8m2 SoC).
Martin Blumenstingl (6):
dt-bindings: phy: meson8b-usb2: Convert to json-schema
dt-bindings: phy: meson8b-usb2: Add compatible string for Meson8m2
phy: amlogic: meson8b-usb2: Use a MMIO regmap
phy: amlogic: meson8b-usb2: Don't set REG_ADP_BC_ACA_ENABLE on Meson8
phy: amlogic: meson8b-usb2: unset the IDDQ bit during PHY power-on
phy: amlogic: meson8b-usb2: Add a compatible string for Meson8m2
.../phy/amlogic,meson8b-usb2-phy.yaml | 62 ++++++++
.../bindings/phy/meson8b-usb2-phy.txt | 28 ----
drivers/phy/amlogic/Kconfig | 3 +-
drivers/phy/amlogic/phy-meson8b-usb2.c | 149 ++++++++++++------
4 files changed, 162 insertions(+), 80 deletions(-)
create mode 100644 Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
delete mode 100644 Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
--
2.26.2
Now that we have the DT validation in place, let's convert the device
tree bindings for the Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2
PHY over to a YAML schema.
While here, also add the fallback compatible string
"amlogic,meson-gxbb-usb2-phy" which is already used in
arch/arm/boot/dts/meson{,8,8b}.dtsi.
Signed-off-by: Martin Blumenstingl <[email protected]>
---
.../phy/amlogic,meson8b-usb2-phy.yaml | 61 +++++++++++++++++++
.../bindings/phy/meson8b-usb2-phy.txt | 28 ---------
2 files changed, 61 insertions(+), 28 deletions(-)
create mode 100644 Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
delete mode 100644 Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
diff --git a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
new file mode 100644
index 000000000000..c2fe8c08d99e
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/amlogic,meson8b-usb2-phy.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY
+
+maintainers:
+ - Martin Blumenstingl <[email protected]>
+
+properties:
+ compatible:
+ oneOf:
+ - items:
+ - enum:
+ - amlogic,meson8-usb2-phy
+ - amlogic,meson8b-usb2-phy
+ - const: amlogic,meson-mx-usb2-phy
+ - const: amlogic,meson-gxbb-usb2-phy
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ minItems: 2
+
+ clock-names:
+ items:
+ - const: usb_general
+ - const: usb
+
+ resets:
+ minItems: 1
+
+ "#phy-cells":
+ const: 0
+
+ phy-supply:
+ description:
+ Phandle to a regulator that provides power to the PHY. This
+ regulator will be managed during the PHY power on/off sequence.
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - "#phy-cells"
+
+examples:
+ - |
+ usb-phy@c0000000 {
+ compatible = "amlogic,meson-gxbb-usb2-phy";
+ reg = <0xc0000000 0x20>;
+ resets = <&reset_usb_phy>;
+ clocks = <&clk_usb_general>, <&reset_usb>;
+ clock-names = "usb_general", "usb";
+ phy-supply = <&usb_vbus>;
+ #phy-cells = <0>;
+ };
diff --git a/Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt b/Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
deleted file mode 100644
index d81d73aea608..000000000000
--- a/Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-* Amlogic Meson8, Meson8b and GXBB USB2 PHY
-
-Required properties:
-- compatible: Depending on the platform this should be one of:
- "amlogic,meson8-usb2-phy"
- "amlogic,meson8b-usb2-phy"
- "amlogic,meson-gxbb-usb2-phy"
-- reg: The base address and length of the registers
-- #phys-cells: should be 0 (see phy-bindings.txt in this directory)
-- clocks: phandle and clock identifier for the phy clocks
-- clock-names: "usb_general" and "usb"
-
-Optional properties:
-- resets: reference to the reset controller
-- phy-supply: see phy-bindings.txt in this directory
-
-
-Example:
-
-usb0_phy: usb-phy@c0000000 {
- compatible = "amlogic,meson-gxbb-usb2-phy";
- #phy-cells = <0>;
- reg = <0x0 0xc0000000 0x0 0x20>;
- resets = <&reset RESET_USB_OTG>;
- clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB0>;
- clock-names = "usb_general", "usb";
- phy-supply = <&usb_vbus>;
-};
--
2.26.2
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 <[email protected]>
Signed-off-by: Martin Blumenstingl <[email protected]>
---
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
The 3.10 vendor kernel sets the ACA_ENABLE bit on Meson8b, Meson8m2 and
GXBB, but not on Meson8. Add a compatible string for Meson8m2 which also
sets that bit.
While here, also update the Kconfig text and MODULE_DESCRIPTION.
Signed-off-by: Martin Blumenstingl <[email protected]>
---
drivers/phy/amlogic/Kconfig | 2 +-
drivers/phy/amlogic/phy-meson8b-usb2.c | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/phy/amlogic/Kconfig b/drivers/phy/amlogic/Kconfig
index 3495b23af797..5ec53874d1ea 100644
--- a/drivers/phy/amlogic/Kconfig
+++ b/drivers/phy/amlogic/Kconfig
@@ -3,7 +3,7 @@
# Phy drivers for Amlogic platforms
#
config PHY_MESON8B_USB2
- tristate "Meson8, Meson8b and GXBB USB2 PHY driver"
+ tristate "Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY driver"
default ARCH_MESON
depends on OF && (ARCH_MESON || COMPILE_TEST)
depends on USB_SUPPORT
diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
index 436dfa1a8a04..03c061dd5f0d 100644
--- a/drivers/phy/amlogic/phy-meson8b-usb2.c
+++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
@@ -302,6 +302,10 @@ static const struct of_device_id phy_meson8b_usb2_of_match[] = {
.compatible = "amlogic,meson8b-usb2-phy",
.data = &phy_meson8b_usb2_match_data
},
+ {
+ .compatible = "amlogic,meson8m2-usb2-phy",
+ .data = &phy_meson8b_usb2_match_data
+ },
{
.compatible = "amlogic,meson-gxbb-usb2-phy",
.data = &phy_meson8b_usb2_match_data
@@ -320,5 +324,5 @@ static struct platform_driver phy_meson8b_usb2_driver = {
module_platform_driver(phy_meson8b_usb2_driver);
MODULE_AUTHOR("Martin Blumenstingl <[email protected]>");
-MODULE_DESCRIPTION("Meson8, Meson8b and GXBB USB2 PHY driver");
+MODULE_DESCRIPTION("Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY driver");
MODULE_LICENSE("GPL");
--
2.26.2
Using a MMIO regmap and switch to regmap_update_bits() to simplify the
code in the driver. Also switch to devm_platform_ioremap_resource()
instead of open-coding it. No functional changes intended.
Signed-off-by: Martin Blumenstingl <[email protected]>
---
drivers/phy/amlogic/Kconfig | 1 +
drivers/phy/amlogic/phy-meson8b-usb2.c | 73 ++++++++++++--------------
2 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/drivers/phy/amlogic/Kconfig b/drivers/phy/amlogic/Kconfig
index 71801e30d601..3495b23af797 100644
--- a/drivers/phy/amlogic/Kconfig
+++ b/drivers/phy/amlogic/Kconfig
@@ -9,6 +9,7 @@ config PHY_MESON8B_USB2
depends on USB_SUPPORT
select USB_COMMON
select GENERIC_PHY
+ select REGMAP_MMIO
help
Enable this to support the Meson USB2 PHYs found in Meson8,
Meson8b and GXBB SoCs.
diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
index bd66bd723e4a..86824cc21f11 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/regmap.h>
#include <linux/reset.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
@@ -105,34 +106,24 @@
#define ACA_ENABLE_COMPLETE_TIME 50
struct phy_meson8b_usb2_priv {
- void __iomem *regs;
+ struct regmap *regmap;
enum usb_dr_mode dr_mode;
struct clk *clk_usb_general;
struct clk *clk_usb;
struct reset_control *reset;
};
-static u32 phy_meson8b_usb2_read(struct phy_meson8b_usb2_priv *phy_priv,
- u32 reg)
-{
- return readl(phy_priv->regs + reg);
-}
-
-static void phy_meson8b_usb2_mask_bits(struct phy_meson8b_usb2_priv *phy_priv,
- u32 reg, u32 mask, u32 value)
-{
- u32 data;
-
- data = phy_meson8b_usb2_read(phy_priv, reg);
- data &= ~mask;
- data |= (value & mask);
-
- writel(data, phy_priv->regs + reg);
-}
+static const struct regmap_config phy_meson8b_usb2_regmap_conf = {
+ .reg_bits = 8,
+ .val_bits = 32,
+ .reg_stride = 4,
+ .max_register = REG_TUNE,
+};
static int phy_meson8b_usb2_power_on(struct phy *phy)
{
struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
+ u32 reg;
int ret;
if (!IS_ERR_OR_NULL(priv->reset)) {
@@ -156,34 +147,34 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
return ret;
}
- phy_meson8b_usb2_mask_bits(priv, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL,
- REG_CONFIG_CLK_32k_ALTSEL);
+ regmap_update_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL,
+ REG_CONFIG_CLK_32k_ALTSEL);
- phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
- 0x2 << REG_CTRL_REF_CLK_SEL_SHIFT);
+ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
+ 0x2 << REG_CTRL_REF_CLK_SEL_SHIFT);
- phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_FSEL_MASK,
- 0x5 << REG_CTRL_FSEL_SHIFT);
+ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_FSEL_MASK,
+ 0x5 << REG_CTRL_FSEL_SHIFT);
/* reset the PHY */
- phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_POWER_ON_RESET,
- REG_CTRL_POWER_ON_RESET);
+ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
+ REG_CTRL_POWER_ON_RESET);
udelay(RESET_COMPLETE_TIME);
- phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0);
+ regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0);
udelay(RESET_COMPLETE_TIME);
- phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT,
- REG_CTRL_SOF_TOGGLE_OUT);
+ 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) {
- phy_meson8b_usb2_mask_bits(priv, REG_ADP_BC,
- REG_ADP_BC_ACA_ENABLE,
- REG_ADP_BC_ACA_ENABLE);
+ regmap_update_bits(priv->regmap, REG_ADP_BC,
+ REG_ADP_BC_ACA_ENABLE,
+ REG_ADP_BC_ACA_ENABLE);
udelay(ACA_ENABLE_COMPLETE_TIME);
- if (phy_meson8b_usb2_read(priv, REG_ADP_BC) &
- REG_ADP_BC_ACA_PIN_FLOAT) {
+ regmap_read(priv->regmap, REG_ADP_BC, ®);
+ if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
dev_warn(&phy->dev, "USB ID detect failed!\n");
clk_disable_unprepare(priv->clk_usb);
clk_disable_unprepare(priv->clk_usb_general);
@@ -213,18 +204,22 @@ static const struct phy_ops phy_meson8b_usb2_ops = {
static int phy_meson8b_usb2_probe(struct platform_device *pdev)
{
struct phy_meson8b_usb2_priv *priv;
- struct resource *res;
struct phy *phy;
struct phy_provider *phy_provider;
+ void __iomem *base;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- priv->regs = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(priv->regs))
- return PTR_ERR(priv->regs);
+ base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ priv->regmap = devm_regmap_init_mmio(&pdev->dev, base,
+ &phy_meson8b_usb2_regmap_conf);
+ if (IS_ERR(priv->regmap))
+ return PTR_ERR(priv->regmap);
priv->clk_usb_general = devm_clk_get(&pdev->dev, "usb_general");
if (IS_ERR(priv->clk_usb_general))
--
2.26.2
The USB2 PHY on Meson8m2 is identical to the one on Meson8b but
different to the one on Meson8. The only known difference is that Meson8
does not set the ACA_ENABLE bit while Meson8b and Meson8m2 do.
Add an explicit compatible string for Meson8m2 so those differences can
be taken care of.
Signed-off-by: Martin Blumenstingl <[email protected]>
---
.../devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
index c2fe8c08d99e..1d402e055045 100644
--- a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
@@ -16,6 +16,7 @@ properties:
- enum:
- amlogic,meson8-usb2-phy
- amlogic,meson8b-usb2-phy
+ - amlogic,meson8m2-usb2-phy
- const: amlogic,meson-mx-usb2-phy
- const: amlogic,meson-gxbb-usb2-phy
--
2.26.2
The vendor driver unsets the set_iddig bit during power-on as well and
sets it when suspending the PHY. I did not notice this in the vendor
driver first, because it's part of the dwc_otg driver there (instead of
their PHY code). While here, also add all other REG_DBG_UART register
bit definitions.
Signed-off-by: Martin Blumenstingl <[email protected]>
---
drivers/phy/amlogic/phy-meson8b-usb2.c | 44 +++++++++++++++++++-------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
index 7236b8885f07..436dfa1a8a04 100644
--- a/drivers/phy/amlogic/phy-meson8b-usb2.c
+++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
@@ -78,6 +78,17 @@
#define REG_ADP_BC_ACA_PIN_FLOAT BIT(26)
#define REG_DBG_UART 0x10
+ #define REG_DBG_UART_BYPASS_SEL BIT(0)
+ #define REG_DBG_UART_BYPASS_DM_EN BIT(1)
+ #define REG_DBG_UART_BYPASS_DP_EN BIT(2)
+ #define REG_DBG_UART_BYPASS_DM_DATA BIT(3)
+ #define REG_DBG_UART_BYPASS_DP_DATA BIT(4)
+ #define REG_DBG_UART_FSV_MINUS BIT(5)
+ #define REG_DBG_UART_FSV_PLUS BIT(6)
+ #define REG_DBG_UART_FSV_BURN_IN_TEST BIT(7)
+ #define REG_DBG_UART_LOOPBACK_EN_B BIT(8)
+ #define REG_DBG_UART_SET_IDDQ BIT(9)
+ #define REG_DBG_UART_ATE_RESET BIT(10)
#define REG_TEST 0x14
#define REG_TEST_DATA_IN_MASK GENMASK(3, 0)
@@ -172,20 +183,24 @@ 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 &&
- priv->match->host_enable_aca) {
- regmap_update_bits(priv->regmap, REG_ADP_BC,
- REG_ADP_BC_ACA_ENABLE,
- REG_ADP_BC_ACA_ENABLE);
+ if (priv->dr_mode == USB_DR_MODE_HOST) {
+ regmap_update_bits(priv->regmap, REG_DBG_UART,
+ REG_DBG_UART_SET_IDDQ, 0);
- udelay(ACA_ENABLE_COMPLETE_TIME);
+ if (priv->match->host_enable_aca) {
+ regmap_update_bits(priv->regmap, REG_ADP_BC,
+ REG_ADP_BC_ACA_ENABLE,
+ REG_ADP_BC_ACA_ENABLE);
- regmap_read(priv->regmap, REG_ADP_BC, ®);
- if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
- dev_warn(&phy->dev, "USB ID detect failed!\n");
- clk_disable_unprepare(priv->clk_usb);
- clk_disable_unprepare(priv->clk_usb_general);
- return -EINVAL;
+ udelay(ACA_ENABLE_COMPLETE_TIME);
+
+ regmap_read(priv->regmap, REG_ADP_BC, ®);
+ if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
+ dev_warn(&phy->dev, "USB ID detect failed!\n");
+ clk_disable_unprepare(priv->clk_usb);
+ clk_disable_unprepare(priv->clk_usb_general);
+ return -EINVAL;
+ }
}
}
@@ -196,6 +211,11 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)
{
struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
+ if (priv->dr_mode == USB_DR_MODE_HOST)
+ regmap_update_bits(priv->regmap, REG_DBG_UART,
+ REG_DBG_UART_SET_IDDQ,
+ REG_DBG_UART_SET_IDDQ);
+
clk_disable_unprepare(priv->clk_usb);
clk_disable_unprepare(priv->clk_usb_general);
--
2.26.2
On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<[email protected]> wrote:
>
> The USB2 PHY on Meson8m2 is identical to the one on Meson8b but
> different to the one on Meson8. The only known difference is that Meson8
> does not set the ACA_ENABLE bit while Meson8b and Meson8m2 do.
> Add an explicit compatible string for Meson8m2 so those differences can
> be taken care of.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
Tested-by: hexdump <[email protected]>
> ---
> .../devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> index c2fe8c08d99e..1d402e055045 100644
> --- a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> +++ b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> @@ -16,6 +16,7 @@ properties:
> - enum:
> - amlogic,meson8-usb2-phy
> - amlogic,meson8b-usb2-phy
> + - amlogic,meson8m2-usb2-phy
> - const: amlogic,meson-mx-usb2-phy
> - const: amlogic,meson-gxbb-usb2-phy
>
> --
> 2.26.2
>
On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<[email protected]> wrote:
>
> Now that we have the DT validation in place, let's convert the device
> tree bindings for the Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2
> PHY over to a YAML schema.
>
> While here, also add the fallback compatible string
> "amlogic,meson-gxbb-usb2-phy" which is already used in
> arch/arm/boot/dts/meson{,8,8b}.dtsi.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
Tested-by: hexdump <[email protected]>
> ---
> .../phy/amlogic,meson8b-usb2-phy.yaml | 61 +++++++++++++++++++
> .../bindings/phy/meson8b-usb2-phy.txt | 28 ---------
> 2 files changed, 61 insertions(+), 28 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> delete mode 100644 Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
>
> diff --git a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> new file mode 100644
> index 000000000000..c2fe8c08d99e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> @@ -0,0 +1,61 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/phy/amlogic,meson8b-usb2-phy.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY
> +
> +maintainers:
> + - Martin Blumenstingl <[email protected]>
> +
> +properties:
> + compatible:
> + oneOf:
> + - items:
> + - enum:
> + - amlogic,meson8-usb2-phy
> + - amlogic,meson8b-usb2-phy
> + - const: amlogic,meson-mx-usb2-phy
> + - const: amlogic,meson-gxbb-usb2-phy
> +
> + reg:
> + maxItems: 1
> +
> + clocks:
> + minItems: 2
> +
> + clock-names:
> + items:
> + - const: usb_general
> + - const: usb
> +
> + resets:
> + minItems: 1
> +
> + "#phy-cells":
> + const: 0
> +
> + phy-supply:
> + description:
> + Phandle to a regulator that provides power to the PHY. This
> + regulator will be managed during the PHY power on/off sequence.
> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - "#phy-cells"
> +
> +examples:
> + - |
> + usb-phy@c0000000 {
> + compatible = "amlogic,meson-gxbb-usb2-phy";
> + reg = <0xc0000000 0x20>;
> + resets = <&reset_usb_phy>;
> + clocks = <&clk_usb_general>, <&reset_usb>;
> + clock-names = "usb_general", "usb";
> + phy-supply = <&usb_vbus>;
> + #phy-cells = <0>;
> + };
> diff --git a/Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt b/Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
> deleted file mode 100644
> index d81d73aea608..000000000000
> --- a/Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -* Amlogic Meson8, Meson8b and GXBB USB2 PHY
> -
> -Required properties:
> -- compatible: Depending on the platform this should be one of:
> - "amlogic,meson8-usb2-phy"
> - "amlogic,meson8b-usb2-phy"
> - "amlogic,meson-gxbb-usb2-phy"
> -- reg: The base address and length of the registers
> -- #phys-cells: should be 0 (see phy-bindings.txt in this directory)
> -- clocks: phandle and clock identifier for the phy clocks
> -- clock-names: "usb_general" and "usb"
> -
> -Optional properties:
> -- resets: reference to the reset controller
> -- phy-supply: see phy-bindings.txt in this directory
> -
> -
> -Example:
> -
> -usb0_phy: usb-phy@c0000000 {
> - compatible = "amlogic,meson-gxbb-usb2-phy";
> - #phy-cells = <0>;
> - reg = <0x0 0xc0000000 0x0 0x20>;
> - resets = <&reset RESET_USB_OTG>;
> - clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB0>;
> - clock-names = "usb_general", "usb";
> - phy-supply = <&usb_vbus>;
> -};
> --
> 2.26.2
>
On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<[email protected]> wrote:
>
> Using a MMIO regmap and switch to regmap_update_bits() to simplify the
> code in the driver. Also switch to devm_platform_ioremap_resource()
> instead of open-coding it. No functional changes intended.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
Tested-by: hexdump <[email protected]>
> ---
> drivers/phy/amlogic/Kconfig | 1 +
> drivers/phy/amlogic/phy-meson8b-usb2.c | 73 ++++++++++++--------------
> 2 files changed, 35 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/phy/amlogic/Kconfig b/drivers/phy/amlogic/Kconfig
> index 71801e30d601..3495b23af797 100644
> --- a/drivers/phy/amlogic/Kconfig
> +++ b/drivers/phy/amlogic/Kconfig
> @@ -9,6 +9,7 @@ config PHY_MESON8B_USB2
> depends on USB_SUPPORT
> select USB_COMMON
> select GENERIC_PHY
> + select REGMAP_MMIO
> help
> Enable this to support the Meson USB2 PHYs found in Meson8,
> Meson8b and GXBB SoCs.
> diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
> index bd66bd723e4a..86824cc21f11 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/regmap.h>
> #include <linux/reset.h>
> #include <linux/phy/phy.h>
> #include <linux/platform_device.h>
> @@ -105,34 +106,24 @@
> #define ACA_ENABLE_COMPLETE_TIME 50
>
> struct phy_meson8b_usb2_priv {
> - void __iomem *regs;
> + struct regmap *regmap;
> enum usb_dr_mode dr_mode;
> struct clk *clk_usb_general;
> struct clk *clk_usb;
> struct reset_control *reset;
> };
>
> -static u32 phy_meson8b_usb2_read(struct phy_meson8b_usb2_priv *phy_priv,
> - u32 reg)
> -{
> - return readl(phy_priv->regs + reg);
> -}
> -
> -static void phy_meson8b_usb2_mask_bits(struct phy_meson8b_usb2_priv *phy_priv,
> - u32 reg, u32 mask, u32 value)
> -{
> - u32 data;
> -
> - data = phy_meson8b_usb2_read(phy_priv, reg);
> - data &= ~mask;
> - data |= (value & mask);
> -
> - writel(data, phy_priv->regs + reg);
> -}
> +static const struct regmap_config phy_meson8b_usb2_regmap_conf = {
> + .reg_bits = 8,
> + .val_bits = 32,
> + .reg_stride = 4,
> + .max_register = REG_TUNE,
> +};
>
> static int phy_meson8b_usb2_power_on(struct phy *phy)
> {
> struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
> + u32 reg;
> int ret;
>
> if (!IS_ERR_OR_NULL(priv->reset)) {
> @@ -156,34 +147,34 @@ static int phy_meson8b_usb2_power_on(struct phy *phy)
> return ret;
> }
>
> - phy_meson8b_usb2_mask_bits(priv, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL,
> - REG_CONFIG_CLK_32k_ALTSEL);
> + regmap_update_bits(priv->regmap, REG_CONFIG, REG_CONFIG_CLK_32k_ALTSEL,
> + REG_CONFIG_CLK_32k_ALTSEL);
>
> - phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
> - 0x2 << REG_CTRL_REF_CLK_SEL_SHIFT);
> + regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_REF_CLK_SEL_MASK,
> + 0x2 << REG_CTRL_REF_CLK_SEL_SHIFT);
>
> - phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_FSEL_MASK,
> - 0x5 << REG_CTRL_FSEL_SHIFT);
> + regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_FSEL_MASK,
> + 0x5 << REG_CTRL_FSEL_SHIFT);
>
> /* reset the PHY */
> - phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_POWER_ON_RESET,
> - REG_CTRL_POWER_ON_RESET);
> + regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET,
> + REG_CTRL_POWER_ON_RESET);
> udelay(RESET_COMPLETE_TIME);
> - phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0);
> + regmap_update_bits(priv->regmap, REG_CTRL, REG_CTRL_POWER_ON_RESET, 0);
> udelay(RESET_COMPLETE_TIME);
>
> - phy_meson8b_usb2_mask_bits(priv, REG_CTRL, REG_CTRL_SOF_TOGGLE_OUT,
> - REG_CTRL_SOF_TOGGLE_OUT);
> + 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) {
> - phy_meson8b_usb2_mask_bits(priv, REG_ADP_BC,
> - REG_ADP_BC_ACA_ENABLE,
> - REG_ADP_BC_ACA_ENABLE);
> + regmap_update_bits(priv->regmap, REG_ADP_BC,
> + REG_ADP_BC_ACA_ENABLE,
> + REG_ADP_BC_ACA_ENABLE);
>
> udelay(ACA_ENABLE_COMPLETE_TIME);
>
> - if (phy_meson8b_usb2_read(priv, REG_ADP_BC) &
> - REG_ADP_BC_ACA_PIN_FLOAT) {
> + regmap_read(priv->regmap, REG_ADP_BC, ®);
> + if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
> dev_warn(&phy->dev, "USB ID detect failed!\n");
> clk_disable_unprepare(priv->clk_usb);
> clk_disable_unprepare(priv->clk_usb_general);
> @@ -213,18 +204,22 @@ static const struct phy_ops phy_meson8b_usb2_ops = {
> static int phy_meson8b_usb2_probe(struct platform_device *pdev)
> {
> struct phy_meson8b_usb2_priv *priv;
> - struct resource *res;
> struct phy *phy;
> struct phy_provider *phy_provider;
> + void __iomem *base;
>
> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> return -ENOMEM;
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - priv->regs = devm_ioremap_resource(&pdev->dev, res);
> - if (IS_ERR(priv->regs))
> - return PTR_ERR(priv->regs);
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
> + priv->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> + &phy_meson8b_usb2_regmap_conf);
> + if (IS_ERR(priv->regmap))
> + return PTR_ERR(priv->regmap);
>
> priv->clk_usb_general = devm_clk_get(&pdev->dev, "usb_general");
> if (IS_ERR(priv->clk_usb_general))
> --
> 2.26.2
>
On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<[email protected]> wrote:
>
> The 3.10 vendor kernel sets the ACA_ENABLE bit on Meson8b, Meson8m2 and
> GXBB, but not on Meson8. Add a compatible string for Meson8m2 which also
> sets that bit.
> While here, also update the Kconfig text and MODULE_DESCRIPTION.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
Tested-by: hexdump <[email protected]>
> ---
> drivers/phy/amlogic/Kconfig | 2 +-
> drivers/phy/amlogic/phy-meson8b-usb2.c | 6 +++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/amlogic/Kconfig b/drivers/phy/amlogic/Kconfig
> index 3495b23af797..5ec53874d1ea 100644
> --- a/drivers/phy/amlogic/Kconfig
> +++ b/drivers/phy/amlogic/Kconfig
> @@ -3,7 +3,7 @@
> # Phy drivers for Amlogic platforms
> #
> config PHY_MESON8B_USB2
> - tristate "Meson8, Meson8b and GXBB USB2 PHY driver"
> + tristate "Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY driver"
> default ARCH_MESON
> depends on OF && (ARCH_MESON || COMPILE_TEST)
> depends on USB_SUPPORT
> diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
> index 436dfa1a8a04..03c061dd5f0d 100644
> --- a/drivers/phy/amlogic/phy-meson8b-usb2.c
> +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
> @@ -302,6 +302,10 @@ static const struct of_device_id phy_meson8b_usb2_of_match[] = {
> .compatible = "amlogic,meson8b-usb2-phy",
> .data = &phy_meson8b_usb2_match_data
> },
> + {
> + .compatible = "amlogic,meson8m2-usb2-phy",
> + .data = &phy_meson8b_usb2_match_data
> + },
> {
> .compatible = "amlogic,meson-gxbb-usb2-phy",
> .data = &phy_meson8b_usb2_match_data
> @@ -320,5 +324,5 @@ static struct platform_driver phy_meson8b_usb2_driver = {
> module_platform_driver(phy_meson8b_usb2_driver);
>
> MODULE_AUTHOR("Martin Blumenstingl <[email protected]>");
> -MODULE_DESCRIPTION("Meson8, Meson8b and GXBB USB2 PHY driver");
> +MODULE_DESCRIPTION("Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY driver");
> MODULE_LICENSE("GPL");
> --
> 2.26.2
>
On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<[email protected]> 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 <[email protected]>
> Signed-off-by: Martin Blumenstingl <[email protected]>
Tested-by: hexdump <[email protected]>
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
>
On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
<[email protected]> wrote:
>
> The vendor driver unsets the set_iddig bit during power-on as well and
> sets it when suspending the PHY. I did not notice this in the vendor
> driver first, because it's part of the dwc_otg driver there (instead of
> their PHY code). While here, also add all other REG_DBG_UART register
> bit definitions.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
Tested-by: hexdump <[email protected]>
> ---
> drivers/phy/amlogic/phy-meson8b-usb2.c | 44 +++++++++++++++++++-------
> 1 file changed, 32 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c
> index 7236b8885f07..436dfa1a8a04 100644
> --- a/drivers/phy/amlogic/phy-meson8b-usb2.c
> +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c
> @@ -78,6 +78,17 @@
> #define REG_ADP_BC_ACA_PIN_FLOAT BIT(26)
>
> #define REG_DBG_UART 0x10
> + #define REG_DBG_UART_BYPASS_SEL BIT(0)
> + #define REG_DBG_UART_BYPASS_DM_EN BIT(1)
> + #define REG_DBG_UART_BYPASS_DP_EN BIT(2)
> + #define REG_DBG_UART_BYPASS_DM_DATA BIT(3)
> + #define REG_DBG_UART_BYPASS_DP_DATA BIT(4)
> + #define REG_DBG_UART_FSV_MINUS BIT(5)
> + #define REG_DBG_UART_FSV_PLUS BIT(6)
> + #define REG_DBG_UART_FSV_BURN_IN_TEST BIT(7)
> + #define REG_DBG_UART_LOOPBACK_EN_B BIT(8)
> + #define REG_DBG_UART_SET_IDDQ BIT(9)
> + #define REG_DBG_UART_ATE_RESET BIT(10)
>
> #define REG_TEST 0x14
> #define REG_TEST_DATA_IN_MASK GENMASK(3, 0)
> @@ -172,20 +183,24 @@ 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 &&
> - priv->match->host_enable_aca) {
> - regmap_update_bits(priv->regmap, REG_ADP_BC,
> - REG_ADP_BC_ACA_ENABLE,
> - REG_ADP_BC_ACA_ENABLE);
> + if (priv->dr_mode == USB_DR_MODE_HOST) {
> + regmap_update_bits(priv->regmap, REG_DBG_UART,
> + REG_DBG_UART_SET_IDDQ, 0);
>
> - udelay(ACA_ENABLE_COMPLETE_TIME);
> + if (priv->match->host_enable_aca) {
> + regmap_update_bits(priv->regmap, REG_ADP_BC,
> + REG_ADP_BC_ACA_ENABLE,
> + REG_ADP_BC_ACA_ENABLE);
>
> - regmap_read(priv->regmap, REG_ADP_BC, ®);
> - if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
> - dev_warn(&phy->dev, "USB ID detect failed!\n");
> - clk_disable_unprepare(priv->clk_usb);
> - clk_disable_unprepare(priv->clk_usb_general);
> - return -EINVAL;
> + udelay(ACA_ENABLE_COMPLETE_TIME);
> +
> + regmap_read(priv->regmap, REG_ADP_BC, ®);
> + if (reg & REG_ADP_BC_ACA_PIN_FLOAT) {
> + dev_warn(&phy->dev, "USB ID detect failed!\n");
> + clk_disable_unprepare(priv->clk_usb);
> + clk_disable_unprepare(priv->clk_usb_general);
> + return -EINVAL;
> + }
> }
> }
>
> @@ -196,6 +211,11 @@ static int phy_meson8b_usb2_power_off(struct phy *phy)
> {
> struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy);
>
> + if (priv->dr_mode == USB_DR_MODE_HOST)
> + regmap_update_bits(priv->regmap, REG_DBG_UART,
> + REG_DBG_UART_SET_IDDQ,
> + REG_DBG_UART_SET_IDDQ);
> +
> clk_disable_unprepare(priv->clk_usb);
> clk_disable_unprepare(priv->clk_usb_general);
>
> --
> 2.26.2
>
On Mon, 2020-05-04 at 12:55 +0200, hex dump wrote:
> On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
> <[email protected]> wrote:
> > Now that we have the DT validation in place, let's convert the device
> > tree bindings for the Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2
> > PHY over to a YAML schema.
> >
> > While here, also add the fallback compatible string
> > "amlogic,meson-gxbb-usb2-phy" which is already used in
> > arch/arm/boot/dts/meson{,8,8b}.dtsi.
> >
> > Signed-off-by: Martin Blumenstingl <[email protected]>
>
> Tested-by: hexdump <[email protected]>
Is the kernel now accepting "Tested-by" lines from robots?
If [email protected] is not a robot, can you please use
your full legal name instead?
On 04-05-20, 10:31, Joe Perches wrote:
> On Mon, 2020-05-04 at 12:55 +0200, hex dump wrote:
> > On Sat, May 2, 2020 at 1:48 PM Martin Blumenstingl
> > <[email protected]> wrote:
> > > Now that we have the DT validation in place, let's convert the device
> > > tree bindings for the Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2
> > > PHY over to a YAML schema.
> > >
> > > While here, also add the fallback compatible string
> > > "amlogic,meson-gxbb-usb2-phy" which is already used in
> > > arch/arm/boot/dts/meson{,8,8b}.dtsi.
> > >
> > > Signed-off-by: Martin Blumenstingl <[email protected]>
> >
> > Tested-by: hexdump <[email protected]>
>
> Is the kernel now accepting "Tested-by" lines from robots?
Should we not? bots have been given Reported-by...
>
> If [email protected] is not a robot, can you please use
> your full legal name instead?
Looking at emails, this doesnt seem a bot, so I am asking for full legal
name for these to be added.
Thanks
--
~Vinod
On Sat, May 02, 2020 at 01:47:47PM +0200, Martin Blumenstingl wrote:
> Now that we have the DT validation in place, let's convert the device
> tree bindings for the Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2
> PHY over to a YAML schema.
>
> While here, also add the fallback compatible string
> "amlogic,meson-gxbb-usb2-phy" which is already used in
> arch/arm/boot/dts/meson{,8,8b}.dtsi.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> .../phy/amlogic,meson8b-usb2-phy.yaml | 61 +++++++++++++++++++
> .../bindings/phy/meson8b-usb2-phy.txt | 28 ---------
> 2 files changed, 61 insertions(+), 28 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> delete mode 100644 Documentation/devicetree/bindings/phy/meson8b-usb2-phy.txt
>
> diff --git a/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> new file mode 100644
> index 000000000000..c2fe8c08d99e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml
> @@ -0,0 +1,61 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/phy/amlogic,meson8b-usb2-phy.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Amlogic Meson8, Meson8b, Meson8m2 and GXBB USB2 PHY
> +
> +maintainers:
> + - Martin Blumenstingl <[email protected]>
> +
> +properties:
> + compatible:
> + oneOf:
> + - items:
> + - enum:
> + - amlogic,meson8-usb2-phy
> + - amlogic,meson8b-usb2-phy
Needs 2 more spaces indent.
> + - const: amlogic,meson-mx-usb2-phy
> + - const: amlogic,meson-gxbb-usb2-phy
> +
> + reg:
> + maxItems: 1
> +
> + clocks:
> + minItems: 2
> +
> + clock-names:
> + items:
> + - const: usb_general
> + - const: usb
> +
> + resets:
> + minItems: 1
> +
> + "#phy-cells":
> + const: 0
> +
> + phy-supply:
> + description:
Wrong indentation.
> + Phandle to a regulator that provides power to the PHY. This
> + regulator will be managed during the PHY power on/off sequence.
> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - "#phy-cells"
Add:
additionalProperties: false
> +
> +examples:
> + - |
> + usb-phy@c0000000 {
> + compatible = "amlogic,meson-gxbb-usb2-phy";
> + reg = <0xc0000000 0x20>;
> + resets = <&reset_usb_phy>;
> + clocks = <&clk_usb_general>, <&reset_usb>;
> + clock-names = "usb_general", "usb";
> + phy-supply = <&usb_vbus>;
> + #phy-cells = <0>;
> + };
On Sat, 2 May 2020 13:47:48 +0200, Martin Blumenstingl wrote:
> The USB2 PHY on Meson8m2 is identical to the one on Meson8b but
> different to the one on Meson8. The only known difference is that Meson8
> does not set the ACA_ENABLE bit while Meson8b and Meson8m2 do.
> Add an explicit compatible string for Meson8m2 so those differences can
> be taken care of.
>
> Signed-off-by: Martin Blumenstingl <[email protected]>
> ---
> .../devicetree/bindings/phy/amlogic,meson8b-usb2-phy.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
Acked-by: Rob Herring <[email protected]>