aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2021-11-23 10:14:22 +0100
committerRafał Miłecki <rafal@milecki.pl>2021-11-23 13:49:10 +0100
commit1d7c1a41987ae463700224c08a3629e4086a8f39 (patch)
tree7f2d7ae573234e085222310f323cc0fce3cffbca
parentcee0a95005a1a3ef48f5c2750605140dae6b7e66 (diff)
downloadupstream-1d7c1a41987ae463700224c08a3629e4086a8f39.tar.gz
upstream-1d7c1a41987ae463700224c08a3629e4086a8f39.tar.bz2
upstream-1d7c1a41987ae463700224c08a3629e4086a8f39.zip
bcm53xx: use new USB 2.0 PHY binding
This fixes: [ 10.440495] bcm_ns_usb2 1800c000.usb2-phy: can't request region for resource [mem 0x1800c000-0x1800cfff] [ 10.450039] bcm_ns_usb2 1800c000.usb2-phy: Failed to map DMU regs [ 10.456183] bcm_ns_usb2: probe of 1800c000.usb2-phy failed with error -16 caused by conflict in allocating resources. Fixes: f55f1dbaad33 ("bcm53xx: switch to the kernel 5.10") Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--target/linux/bcm53xx/patches-5.10/070-v5.17-phy-bcm-ns-usb2-support-updated-DT-binding-with-PHY-.patch131
-rw-r--r--target/linux/bcm53xx/patches-5.10/130-ARM-dts-BCM5301X-use-non-deprecated-USB-2.0-PHY-bind.patch52
2 files changed, 183 insertions, 0 deletions
diff --git a/target/linux/bcm53xx/patches-5.10/070-v5.17-phy-bcm-ns-usb2-support-updated-DT-binding-with-PHY-.patch b/target/linux/bcm53xx/patches-5.10/070-v5.17-phy-bcm-ns-usb2-support-updated-DT-binding-with-PHY-.patch
new file mode 100644
index 0000000000..464849bc69
--- /dev/null
+++ b/target/linux/bcm53xx/patches-5.10/070-v5.17-phy-bcm-ns-usb2-support-updated-DT-binding-with-PHY-.patch
@@ -0,0 +1,131 @@
+From d3bc6269e21fc474763708e79c7a118740befb94 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 26 Oct 2021 11:37:16 +0200
+Subject: [PATCH] phy: bcm-ns-usb2: support updated DT binding with PHY reg
+ space
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Updated DT binding maps just a PHY's register space instead of the whole
+DMU block. Accessing a common CRU reg is handled using syscon &
+regmap.
+
+The old binding has been deprecated and remains supported as a fallback
+method.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Link: https://lore.kernel.org/r/20211026093716.5567-1-zajec5@gmail.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+---
+ drivers/phy/broadcom/phy-bcm-ns-usb2.c | 52 +++++++++++++++++++++-----
+ 1 file changed, 43 insertions(+), 9 deletions(-)
+
+--- a/drivers/phy/broadcom/phy-bcm-ns-usb2.c
++++ b/drivers/phy/broadcom/phy-bcm-ns-usb2.c
+@@ -9,17 +9,23 @@
+ #include <linux/clk.h>
+ #include <linux/delay.h>
+ #include <linux/err.h>
++#include <linux/mfd/syscon.h>
+ #include <linux/module.h>
+ #include <linux/of_address.h>
+ #include <linux/of_platform.h>
+ #include <linux/phy/phy.h>
+ #include <linux/platform_device.h>
++#include <linux/regmap.h>
+ #include <linux/slab.h>
+
+ struct bcm_ns_usb2 {
+ struct device *dev;
+ struct clk *ref_clk;
+ struct phy *phy;
++ struct regmap *clkset;
++ void __iomem *base;
++
++ /* Deprecated binding */
+ void __iomem *dmu;
+ };
+
+@@ -27,7 +33,6 @@ static int bcm_ns_usb2_phy_init(struct p
+ {
+ struct bcm_ns_usb2 *usb2 = phy_get_drvdata(phy);
+ struct device *dev = usb2->dev;
+- void __iomem *dmu = usb2->dmu;
+ u32 ref_clk_rate, usb2ctl, usb_pll_ndiv, usb_pll_pdiv;
+ int err = 0;
+
+@@ -44,7 +49,10 @@ static int bcm_ns_usb2_phy_init(struct p
+ goto err_clk_off;
+ }
+
+- usb2ctl = readl(dmu + BCMA_DMU_CRU_USB2_CONTROL);
++ if (usb2->base)
++ usb2ctl = readl(usb2->base);
++ else
++ usb2ctl = readl(usb2->dmu + BCMA_DMU_CRU_USB2_CONTROL);
+
+ if (usb2ctl & BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK) {
+ usb_pll_pdiv = usb2ctl;
+@@ -58,15 +66,24 @@ static int bcm_ns_usb2_phy_init(struct p
+ usb_pll_ndiv = (1920000000 * usb_pll_pdiv) / ref_clk_rate;
+
+ /* Unlock DMU PLL settings with some magic value */
+- writel(0x0000ea68, dmu + BCMA_DMU_CRU_CLKSET_KEY);
++ if (usb2->clkset)
++ regmap_write(usb2->clkset, 0, 0x0000ea68);
++ else
++ writel(0x0000ea68, usb2->dmu + BCMA_DMU_CRU_CLKSET_KEY);
+
+ /* Write USB 2.0 PLL control setting */
+ usb2ctl &= ~BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_MASK;
+ usb2ctl |= usb_pll_ndiv << BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_SHIFT;
+- writel(usb2ctl, dmu + BCMA_DMU_CRU_USB2_CONTROL);
++ if (usb2->base)
++ writel(usb2ctl, usb2->base);
++ else
++ writel(usb2ctl, usb2->dmu + BCMA_DMU_CRU_USB2_CONTROL);
+
+ /* Lock DMU PLL settings */
+- writel(0x00000000, dmu + BCMA_DMU_CRU_CLKSET_KEY);
++ if (usb2->clkset)
++ regmap_write(usb2->clkset, 0, 0x00000000);
++ else
++ writel(0x00000000, usb2->dmu + BCMA_DMU_CRU_CLKSET_KEY);
+
+ err_clk_off:
+ clk_disable_unprepare(usb2->ref_clk);
+@@ -91,11 +108,28 @@ static int bcm_ns_usb2_probe(struct plat
+ return -ENOMEM;
+ usb2->dev = dev;
+
+- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmu");
+- usb2->dmu = devm_ioremap_resource(dev, res);
+- if (IS_ERR(usb2->dmu)) {
+- dev_err(dev, "Failed to map DMU regs\n");
+- return PTR_ERR(usb2->dmu);
++ if (of_find_property(dev->of_node, "brcm,syscon-clkset", NULL)) {
++ usb2->base = devm_platform_ioremap_resource(pdev, 0);
++ if (IS_ERR(usb2->base)) {
++ dev_err(dev, "Failed to map control reg\n");
++ return PTR_ERR(usb2->base);
++ }
++
++ usb2->clkset = syscon_regmap_lookup_by_phandle(dev->of_node,
++ "brcm,syscon-clkset");
++ if (IS_ERR(usb2->clkset)) {
++ dev_err(dev, "Failed to lookup clkset regmap\n");
++ return PTR_ERR(usb2->clkset);
++ }
++ } else {
++ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmu");
++ usb2->dmu = devm_ioremap_resource(dev, res);
++ if (IS_ERR(usb2->dmu)) {
++ dev_err(dev, "Failed to map DMU regs\n");
++ return PTR_ERR(usb2->dmu);
++ }
++
++ dev_warn(dev, "using deprecated DT binding\n");
+ }
+
+ usb2->ref_clk = devm_clk_get(dev, "phy-ref-clk");
diff --git a/target/linux/bcm53xx/patches-5.10/130-ARM-dts-BCM5301X-use-non-deprecated-USB-2.0-PHY-bind.patch b/target/linux/bcm53xx/patches-5.10/130-ARM-dts-BCM5301X-use-non-deprecated-USB-2.0-PHY-bind.patch
new file mode 100644
index 0000000000..e50bcd9f25
--- /dev/null
+++ b/target/linux/bcm53xx/patches-5.10/130-ARM-dts-BCM5301X-use-non-deprecated-USB-2.0-PHY-bind.patch
@@ -0,0 +1,52 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 23 Nov 2021 09:55:06 +0100
+Subject: [PATCH] ARM: dts: BCM5301X: use non-deprecated USB 2.0 PHY binding
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The new binding covers a single reg and uses syscon to reference shared
+register.
+
+References: 55b9b741712d ("dt-bindings: phy: brcm,ns-usb2-phy: bind just a PHY block")
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+---
+ arch/arm/boot/dts/bcm5301x.dtsi | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+--- a/arch/arm/boot/dts/bcm5301x.dtsi
++++ b/arch/arm/boot/dts/bcm5301x.dtsi
+@@ -148,15 +148,6 @@
+ };
+ };
+
+- usb2_phy: usb2-phy@1800c000 {
+- compatible = "brcm,ns-usb2-phy";
+- reg = <0x1800c000 0x1000>;
+- reg-names = "dmu";
+- #phy-cells = <0>;
+- clocks = <&genpll BCM_NSP_GENPLL_USB_PHY_REF_CLK>;
+- clock-names = "phy-ref-clk";
+- };
+-
+ axi@18000000 {
+ compatible = "brcm,bus-axi";
+ reg = <0x18000000 0x1000>;
+@@ -450,7 +441,16 @@
+ "sata1", "sata2";
+ };
+
+- syscon@180 {
++ usb2_phy: phy@164 {
++ compatible = "brcm,ns-usb2-phy";
++ reg = <0x164 0x4>;
++ brcm,syscon-clkset = <&cru_clkset>;
++ clocks = <&genpll BCM_NSP_GENPLL_USB_PHY_REF_CLK>;
++ clock-names = "phy-ref-clk";
++ #phy-cells = <0>;
++ };
++
++ cru_clkset: syscon@180 {
+ compatible = "brcm,cru-clkset", "syscon";
+ reg = <0x180 0x4>;
+ };