phy: bcm63xx-usbh: Add BCM63xx USBH driver
Subsystems (2)
v5 cover phy: bcm63xx-usbh: Add BCM63xx USBH driver
Add BCM63xx USBH PHY driver for BMIPS.
v5: use devm_reset_control_get_exclusive.
v4: fix dt-bindings documentation and improve device mode config.
v3: introduce changes suggested by Florian:
- Add support for device mode.
v2: introduce changes suggested by Florian:
- phy-cells changed to 1.
- Drop OF dependency (use device_get_match_data).
- Drop __initconst from variant tables.
- Use devm_clk_get_optional.
Álvaro Fernández Rojas (2):
dt-bindings: phy: add bcm63xx-usbh bindings
phy: bcm63xx-usbh: Add BCM63xx USBH driver
.../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 84 ++++ drivers/phy/broadcom/Kconfig | 9 + drivers/phy/broadcom/Makefile | 1 + drivers/phy/broadcom/phy-bcm63xx-usbh.c | 457 ++++++++++++++++++ 4 files changed, 551 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c
Signature · 1 line
2.27.0
PATCH v5 1/2 dt-bindings: phy: add bcm63xx-usbh bindings
Document BCM63xx USBH PHY bindings.
---
v5: no changes.
v4: conditionally require 1/2 clocks and fix clock/reset values.
v3: no changes.
v2: phy-cells changed to 1.
.../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +84 -0
@@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/phy/brcm,bcm63xx-usbh-phy.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: BCM63xx USBH PHY + +maintainers: + - Álvaro Fernández Rojas <[email protected]> + +properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm6328-usbh-phy + - brcm,bcm6358-usbh-phy + - brcm,bcm6362-usbh-phy + - brcm,bcm6368-usbh-phy + - brcm,bcm63268-usbh-phy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: usbh + + resets: + maxItems: 1 + + "#phy-cells": + const: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - "#phy-cells" + +allOf: + - if: + properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm63268-usbh-phy + then: + properties: + clocks: + maxItems: 2 + clock-names: + items: + - const: usbh + - const: usb_ref + - if: + properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm6328-usbh-phy + - brcm,bcm6362-usbh-phy + - brcm,bcm63268-usbh-phy + then: + properties: + power-domains: + maxItems: 1 + required: + - power-domains + +examples: + - | + usbh: usb-phy@10001700 { + compatible = "brcm,bcm6368-usbh-phy"; + reg = <0x10001700 0x38>; + clocks = <&periph_clk 15>; + clock-names = "usbh"; + resets = <&periph_rst 12>; + #phy-cells = <1>; + };
Signature · 1 line
2.27.0
Rob Herring
maintainerRe: [PATCH v5 1/2] dt-bindings: phy: add bcm63xx-usbh bindings
Quoted 53 lines · Álvaro Fernández Rojas
Document BCM63xx USBH PHY bindings.
Signed-off-by Álvaro Fernández Rojas <[email protected]>Reviewed-by Florian Fainelli <[email protected]>---
v5: no changes.
v4: conditionally require 1/2 clocks and fix clock/reset values.
v3: no changes.
v2: phy-cells changed to 1..../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yamlDocumentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +33
-0@@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/phy/brcm,bcm63xx-usbh-phy.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: BCM63xx USBH PHY + +maintainers: + - Álvaro Fernández Rojas <[email protected]> + +properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm6328-usbh-phy + - brcm,bcm6358-usbh-phy + - brcm,bcm6362-usbh-phy + - brcm,bcm6368-usbh-phy + - brcm,bcm63268-usbh-phy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: usbh + + resets: + maxItems: 1 +
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +10
-0+ "#phy-cells": + const: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - "#phy-cells"
You need:
additionalProperties: false
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml line 55
Quoted 12 lines
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +12
-0+ +allOf: + - if: + properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm63268-usbh-phy + then: + properties: + clocks: + maxItems: 2
This doesn't work. The main schema will also be applied and it says there's 1. The main schema has to cover all the cases and then if/then schemas add constraints.
Quoted 32 lines
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +29
-0+ clock-names: + items: + - const: usbh + - const: usb_ref + - if: + properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm6328-usbh-phy + - brcm,bcm6362-usbh-phy + - brcm,bcm63268-usbh-phy + then: + properties: + power-domains: + maxItems: 1 + required: + - power-domains + +examples: + - | + usbh: usb-phy@10001700 { + compatible = "brcm,bcm6368-usbh-phy"; + reg = <0x10001700 0x38>; + clocks = <&periph_clk 15>; + clock-names = "usbh"; + resets = <&periph_rst 12>; + #phy-cells = <1>; + };Signature · 1 line
2.27.0
Re: [PATCH v5 1/2] dt-bindings: phy: add bcm63xx-usbh bindings
Hi Rob,
If adding "additionalProperties: false” throws the following error, which I don’t understand:/home/noltari/workspace/linux/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.example.dt.yaml: usb-phy@10001700: 'clock-names', 'clocks' do not match any of the regexes: 'pinctrl-[0-9]+’
BTW, is this what you mean? (I added another if section for the cases with just 1 clock):
https://gist.github.com/Noltari/9bd94a30e8bcc857d6af87985d7ca010
Best regards,
Álvaro.
Quoted 119 lines · Rob Herring
Quoted 53 lines · Álvaro Fernández Rojas
Document BCM63xx USBH PHY bindings.
Signed-off-by Álvaro Fernández Rojas <[email protected]>Reviewed-by Florian Fainelli <[email protected]>---
v5: no changes.
v4: conditionally require 1/2 clocks and fix clock/reset values.
v3: no changes.
v2: phy-cells changed to 1.
.../bindings/phy/brcm,bcm63xx-usbh-phy.yaml| 84 +++++++++++++++++++1 file changed, 84 insertions(+)create mode 100644
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yamlDocumentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +33
-0@@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/phy/brcm,bcm63xx-usbh-phy.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: BCM63xx USBH PHY + +maintainers: + - Álvaro Fernández Rojas <[email protected]> + +properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm6328-usbh-phy + - brcm,bcm6358-usbh-phy + - brcm,bcm6362-usbh-phy + - brcm,bcm6368-usbh-phy + - brcm,bcm63268-usbh-phy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: usbh + + resets: + maxItems: 1 +Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +10
-0+ "#phy-cells": + const: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - "#phy-cells"You need:
additionalProperties: false
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml line 55
Quoted 12 lines
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +12
-0+ +allOf: + - if: + properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm63268-usbh-phy + then: + properties: + clocks: + maxItems: 2This doesn't work. The main schema will also be applied and it says there's 1. The main schema has to cover all the cases and then if/then schemas add constraints.
Quoted 31 lines
Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file +29
-0+ clock-names: + items: + - const: usbh + - const: usb_ref + - if: + properties: + compatible: + enum: + - brcm,bcm6318-usbh-phy + - brcm,bcm6328-usbh-phy + - brcm,bcm6362-usbh-phy + - brcm,bcm63268-usbh-phy + then: + properties: + power-domains: + maxItems: 1 + required: + - power-domains + +examples: + - | + usbh: usb-phy@10001700 { + compatible = "brcm,bcm6368-usbh-phy"; + reg = <0x10001700 0x38>; + clocks = <&periph_clk 15>; + clock-names = "usbh"; + resets = <&periph_rst 12>; + #phy-cells = <1>; + };Signature · 1 line
2.27.0
PATCH v5 2/2 phy: bcm63xx-usbh: Add BCM63xx USBH driver
In reply to Álvaro Fernández RojasAdd BCM63xx USBH PHY driver for BMIPS.
---
v5: use devm_reset_control_get_exclusive.
v4: several improvements:
- Use devm_platform_ioremap_resource.
- Code cleanups.
- Improve device mode config:
- Move USBH_SWAP_CONTROL device mode value to variant variable.
- Set USBH_UTMI_CONTROL1 register value (variant variable).
v3: introduce changes suggested by Florian:
- Add support for device mode.
v2: introduce changes suggested by Florian:
- Drop OF dependency (use device_get_match_data).
- Drop __initconst from variant tables.
- Use devm_clk_get_optional.
drivers/phy/broadcom/Kconfig | 9 + drivers/phy/broadcom/Makefile | 1 + drivers/phy/broadcom/phy-bcm63xx-usbh.c | 457 ++++++++++++++++++++++++ 3 files changed, 467 insertions(+) create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c
drivers/phy/broadcom/Kconfig +9 -0
@@ -2,6 +2,15 @@ # # Phy drivers for Broadcom platforms # +config PHY_BCM63XX_USBH + tristate "BCM63xx USBH PHY driver" + depends on BMIPS_GENERIC || COMPILE_TEST + select GENERIC_PHY + default BMIPS_GENERIC + help + Enable this to support the BCM63xx USBH PHY driver. + If unsure, say N. + config PHY_CYGNUS_PCIE tristate "Broadcom Cygnus PCIe PHY driver" depends on OF && (ARCH_BCM_CYGNUS || COMPILE_TEST)
drivers/phy/broadcom/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PHY_BCM63XX_USBH) += phy-bcm63xx-usbh.o obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o obj-$(CONFIG_PHY_BCM_NS_USB2) += phy-bcm-ns-usb2.o
drivers/phy/broadcom/phy-bcm63xx-usbh.c new file +457 -0
457 lines not on this page · raw message
Signature · 7 lines
2.27.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 3 lines · Álvaro Fernández Rojas
Add BCM63xx USBH PHY driver for BMIPS.
Signed-off-by Álvaro Fernández Rojas <[email protected]>
This looks great, thanks Alvaro!
Signature · 1 line
Florian
Vinod Koul
maintainerQuoted 29 lines · Álvaro Fernández Rojas
Add BCM63xx USBH PHY driver for BMIPS.
Signed-off-by Álvaro Fernández Rojas <[email protected]>---
v5: usedevm_reset_control_get_exclusive.
v4: several improvements:
- Usedevm_platform_ioremap_resource.
- Code cleanups.
- Improve device mode config:
- MoveUSBH_SWAP_CONTROLdevice mode value to variant variable.
- SetUSBH_UTMI_CONTROL1register value (variant variable).
v3: introduce changes suggested by Florian:
- Add support for device mode.
v2: introduce changes suggested by Florian:
- Drop OF dependency (usedevice_get_match_data).
- Drop__initconstfrom variant tables.
- Usedevm_clk_get_optional.drivers/phy/broadcom/Kconfig | 9 + drivers/phy/broadcom/Makefile | 1 + drivers/phy/broadcom/phy-bcm63xx-usbh.c | 457 ++++++++++++++++++++++++ 3 files changed, 467 insertions(+) create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.cdrivers/phy/broadcom/Kconfig +0
-0
drivers/phy/broadcom/Kconfig line 9
Quoted 8 lines
drivers/phy/broadcom/Kconfig +5
-0@@ -2,6 +2,15 @@ # # Phy drivers for Broadcom platforms # +config PHY_BCM63XX_USBH + tristate "BCM63xx USBH PHY driver" + depends on BMIPS_GENERIC || COMPILE_TEST + select GENERIC_PHY + default BMIPS_GENERIC
you depend on BMIPS_GENERIC and also use as default?
Quoted 43 lines
drivers/phy/broadcom/Kconfig +43
-0+static int __init bcm63xx_usbh_phy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct bcm63xx_usbh_phy *usbh; + const struct bcm63xx_usbh_phy_variant *variant; + struct phy *phy; + struct phy_provider *phy_provider; + + usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL); + if (!usbh) + return -ENOMEM; + + variant = device_get_match_data(dev); + if (!variant) + return -EINVAL; + usbh->variant = variant; + + usbh->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(usbh->base)) + return PTR_ERR(usbh->base); + + usbh->reset = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(usbh->reset)) { + if (PTR_ERR(usbh->reset) != -EPROBE_DEFER) + dev_err(dev, "failed to get reset\n"); + return PTR_ERR(usbh->reset); + } + + usbh->usbh_clk = devm_clk_get_optional(dev, "usbh"); + if (IS_ERR(usbh->usbh_clk)) + return PTR_ERR(usbh->usbh_clk); + + usbh->usb_ref_clk = devm_clk_get_optional(dev, "usb_ref"); + if (IS_ERR(usbh->usb_ref_clk)) + return PTR_ERR(usbh->usb_ref_clk); + + phy = devm_phy_create(dev, NULL, &bcm63xx_usbh_phy_ops); + if (IS_ERR(phy)) { + dev_err(dev, "failed to create PHY\n"); + return PTR_ERR(phy); + } + + platform_set_drvdata(pdev, usbh);
drivers/phy/broadcom/Kconfig
Quoted 10 lines
drivers/phy/broadcom/Kconfig +10
-0+ phy_set_drvdata(phy, usbh); + + phy_provider = devm_of_phy_provider_register(dev, + bcm63xx_usbh_phy_xlate); + if (IS_ERR(phy_provider)) { + dev_err(dev, "failed to register PHY provider\n"); + return PTR_ERR(phy_provider); + } + + dev_info(dev, "Registered BCM63xx USB PHY driver\n");
debug level?
Signature · 1 line
~Vinod
Hi Vinod,
Quoted 27 lines · Vinod Koul
Quoted 24 lines · Álvaro Fernández Rojas
Add BCM63xx USBH PHY driver for BMIPS.
Signed-off-by Álvaro Fernández Rojas <[email protected]>---
v5: usedevm_reset_control_get_exclusive.
v4: several improvements:
- Usedevm_platform_ioremap_resource.
- Code cleanups.
- Improve device mode config:
- MoveUSBH_SWAP_CONTROLdevice mode value to variant variable.
- SetUSBH_UTMI_CONTROL1register value (variant variable).
v3: introduce changes suggested by Florian:
- Add support for device mode.
v2: introduce changes suggested by Florian:
- Drop OF dependency (usedevice_get_match_data).
- Drop__initconstfrom variant tables.
- Usedevm_clk_get_optional.drivers/phy/broadcom/Kconfig | 9 + drivers/phy/broadcom/Makefile | 1 + drivers/phy/broadcom/phy-bcm63xx-usbh.c | 457 ++++++++++++++++++++++++ 3 files changed, 467 insertions(+)create mode 100644
drivers/phy/broadcom/phy-bcm63xx-usbh.c
Quoted 15 lines
drivers/phy/broadcom/Kconfig line 9
Quoted 13 lines
drivers/phy/broadcom/Kconfig +5
-0@@ -2,6 +2,15 @@ # # Phy drivers for Broadcom platforms # +config PHY_BCM63XX_USBH + tristate "BCM63xx USBH PHY driver" + depends on BMIPS_GENERIC || COMPILE_TEST + select GENERIC_PHY + default BMIPS_GENERICyou depend on
BMIPS_GENERICand also use as default?
PHY_CYGNUS_PCIE, PHY_BCM_SR_USB, PHY_NS2_USB_DRD, PHY_BRCM_USB and PHY_BCM_SR_PCIE are doing that, so I just copied it ¯\_(ツ)_/¯. I will remove the default since there are other SoCs in BMIPS_GENERIC that won’t need this.
Quoted 48 lines
Quoted 48 lines
drivers/phy/broadcom/Kconfig +47
-0+static int __init bcm63xx_usbh_phy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct bcm63xx_usbh_phy *usbh; + const struct bcm63xx_usbh_phy_variant *variant; + struct phy *phy; + struct phy_provider *phy_provider; + + usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL); + if (!usbh) + return -ENOMEM; + + variant = device_get_match_data(dev); + if (!variant) + return -EINVAL; + usbh->variant = variant; + + usbh->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(usbh->base)) + return PTR_ERR(usbh->base); + + usbh->reset = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(usbh->reset)) { + if (PTR_ERR(usbh->reset) != -EPROBE_DEFER) + dev_err(dev, "failed to get reset\n"); + return PTR_ERR(usbh->reset); + } + + usbh->usbh_clk = devm_clk_get_optional(dev, "usbh"); + if (IS_ERR(usbh->usbh_clk)) + return PTR_ERR(usbh->usbh_clk); + + usbh->usb_ref_clk = devm_clk_get_optional(dev, "usb_ref"); + if (IS_ERR(usbh->usb_ref_clk)) + return PTR_ERR(usbh->usb_ref_clk); + + phy = devm_phy_create(dev, NULL, &bcm63xx_usbh_phy_ops); + if (IS_ERR(phy)) { + dev_err(dev, "failed to create PHY\n"); + return PTR_ERR(phy); + } + + platform_set_drvdata(pdev, usbh); + phy_set_drvdata(phy, usbh); + + phy_provider = devm_of_phy_provider_register(dev, + bcm63xx_usbh_phy_xlate);
Quoted 8 lines
drivers/phy/broadcom/Kconfig
Quoted 6 lines
drivers/phy/broadcom/Kconfig +6
-0+ if (IS_ERR(phy_provider)) { + dev_err(dev, "failed to register PHY provider\n"); + return PTR_ERR(phy_provider); + } + + dev_info(dev, "Registered BCM63xx USB PHY driver\n");debug level?
Yeah, I will change it.
Quoted 2 lines
Signature · 1 line
~Vinod