* [PATCH 0/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver @ 2020-06-16 8:34 Álvaro Fernández Rojas 2020-06-16 8:34 ` [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings Álvaro Fernández Rojas 2020-06-16 8:34 ` [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas 0 siblings, 2 replies; 10+ messages in thread From: Álvaro Fernández Rojas @ 2020-06-16 8:34 UTC (permalink / raw) To: simon, jonas.gorski, kishon, vkoul, robh+dt, f.fainelli, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel Cc: Álvaro Fernández Rojas Add BCM63xx USBH PHY driver for BMIPS. Á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 | 72 +++ drivers/phy/broadcom/Kconfig | 10 + drivers/phy/broadcom/Makefile | 1 + drivers/phy/broadcom/phy-bcm63xx-usbh.c | 463 ++++++++++++++++++ 4 files changed, 546 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c -- 2.27.0 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-16 8:34 [PATCH 0/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas @ 2020-06-16 8:34 ` Álvaro Fernández Rojas 2020-06-16 17:17 ` Florian Fainelli 2020-06-17 17:00 ` Rob Herring 2020-06-16 8:34 ` [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas 1 sibling, 2 replies; 10+ messages in thread From: Álvaro Fernández Rojas @ 2020-06-16 8:34 UTC (permalink / raw) To: simon, jonas.gorski, kishon, vkoul, robh+dt, f.fainelli, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel Cc: Álvaro Fernández Rojas Document BCM63xx USBH PHY bindings. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> --- .../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml diff --git a/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml new file mode 100644 index 000000000000..3e7c97799b91 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml @@ -0,0 +1,72 @@ +# 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 <noltari@gmail.com> + +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: 2 + + clock-names: + items: + - const: usbh + - const: usb_ref + + resets: + maxItems: 1 + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - "#phy-cells" + +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 BCM6368_CLK_USBH>; + clock-names = "usbh"; + resets = <&periph_rst BCM6368_RST_USBH>; + #phy-cells = <0>; + }; -- 2.27.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-16 8:34 ` [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings Álvaro Fernández Rojas @ 2020-06-16 17:17 ` Florian Fainelli 2020-06-16 18:10 ` Álvaro Fernández Rojas 2020-06-17 11:16 ` Álvaro Fernández Rojas 2020-06-17 17:00 ` Rob Herring 1 sibling, 2 replies; 10+ messages in thread From: Florian Fainelli @ 2020-06-16 17:17 UTC (permalink / raw) To: Álvaro Fernández Rojas, simon, jonas.gorski, kishon, vkoul, robh+dt, f.fainelli, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel On 6/16/2020 1:34 AM, Álvaro Fernández Rojas wrote: > Document BCM63xx USBH PHY bindings. > > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> > --- > .../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 72 +++++++++++++++++++ > 1 file changed, 72 insertions(+) > create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml > > diff --git a/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml > new file mode 100644 > index 000000000000..3e7c97799b91 > --- /dev/null > +++ b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml > @@ -0,0 +1,72 @@ > +# 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 <noltari@gmail.com> > + > +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: 2 > + > + clock-names: > + items: > + - const: usbh > + - const: usb_ref > + > + resets: > + maxItems: 1 > + > + "#phy-cells": > + const: 0 On 6328, the same register space allows the controlling of the USB PHY in either host or device mode, so I believe you would need to add a #phy-cells = 1 in order to distinguish the consumer (host versus device) if we get to the point where drivers/usb/gadget/udc/bcm63xx_udc.c becomes DT aware. Other than that, this looks good to me! -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-16 17:17 ` Florian Fainelli @ 2020-06-16 18:10 ` Álvaro Fernández Rojas 2020-06-16 18:21 ` Florian Fainelli 2020-06-17 11:16 ` Álvaro Fernández Rojas 1 sibling, 1 reply; 10+ messages in thread From: Álvaro Fernández Rojas @ 2020-06-16 18:10 UTC (permalink / raw) To: Florian Fainelli Cc: simon, Jonas Gorski, kishon, vkoul, robh+dt, bcm-kernel-feedback-list, Philipp Zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel Hello Florian, > El 16 jun 2020, a las 19:17, Florian Fainelli <f.fainelli@gmail.com> escribió: > > > > On 6/16/2020 1:34 AM, Álvaro Fernández Rojas wrote: >> Document BCM63xx USBH PHY bindings. >> >> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> >> --- >> .../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 72 +++++++++++++++++++ >> 1 file changed, 72 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >> >> diff --git a/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >> new file mode 100644 >> index 000000000000..3e7c97799b91 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >> @@ -0,0 +1,72 @@ >> +# 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 <noltari@gmail.com> >> + >> +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: 2 >> + >> + clock-names: >> + items: >> + - const: usbh >> + - const: usb_ref >> + >> + resets: >> + maxItems: 1 >> + >> + "#phy-cells": >> + const: 0 > > On 6328, the same register space allows the controlling of the USB PHY > in either host or device mode, so I believe you would need to add a > #phy-cells = 1 in order to distinguish the consumer (host versus device) > if we get to the point where drivers/usb/gadget/udc/bcm63xx_udc.c > becomes DT aware. I’m not really sure about how I should do this because there’s no definition for device phy mode in dt-bindings/phy/phy.h: https://github.com/torvalds/linux/blob/master/include/dt-bindings/phy/phy.h#L13 Which value should I use for device mode and which one for host? Should I support both modes at the same time or are they exclusive? > > Other than that, this looks good to me! > -- > Florian Best regards, Álvaro. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-16 18:10 ` Álvaro Fernández Rojas @ 2020-06-16 18:21 ` Florian Fainelli 0 siblings, 0 replies; 10+ messages in thread From: Florian Fainelli @ 2020-06-16 18:21 UTC (permalink / raw) To: Álvaro Fernández Rojas, Florian Fainelli Cc: simon, Jonas Gorski, kishon, vkoul, robh+dt, bcm-kernel-feedback-list, Philipp Zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel On 6/16/2020 11:10 AM, Álvaro Fernández Rojas wrote: > Hello Florian, > >> El 16 jun 2020, a las 19:17, Florian Fainelli <f.fainelli@gmail.com> escribió: >> >> >> >> On 6/16/2020 1:34 AM, Álvaro Fernández Rojas wrote: >>> Document BCM63xx USBH PHY bindings. >>> >>> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> >>> --- >>> .../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 72 +++++++++++++++++++ >>> 1 file changed, 72 insertions(+) >>> create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >>> >>> diff --git a/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >>> new file mode 100644 >>> index 000000000000..3e7c97799b91 >>> --- /dev/null >>> +++ b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >>> @@ -0,0 +1,72 @@ >>> +# 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 <noltari@gmail.com> >>> + >>> +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: 2 >>> + >>> + clock-names: >>> + items: >>> + - const: usbh >>> + - const: usb_ref >>> + >>> + resets: >>> + maxItems: 1 >>> + >>> + "#phy-cells": >>> + const: 0 >> >> On 6328, the same register space allows the controlling of the USB PHY >> in either host or device mode, so I believe you would need to add a >> #phy-cells = 1 in order to distinguish the consumer (host versus device) >> if we get to the point where drivers/usb/gadget/udc/bcm63xx_udc.c >> becomes DT aware. > > I’m not really sure about how I should do this because there’s no definition for device phy mode in dt-bindings/phy/phy.h: > https://github.com/torvalds/linux/blob/master/include/dt-bindings/phy/phy.h#L13 > > Which value should I use for device mode and which one for host? 0 for the host, which would be equivalent to not specifying the property, and 1 for the device. > Should I support both modes at the same time or are they exclusive? This is an OTG controller so you need to be able to dynamically re-configure the PHY to be in either device or host mode (see comment about bcm63xx_select_phy_mode), but there would not be both at the same time. -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-16 17:17 ` Florian Fainelli 2020-06-16 18:10 ` Álvaro Fernández Rojas @ 2020-06-17 11:16 ` Álvaro Fernández Rojas 2020-06-17 21:35 ` Florian Fainelli 1 sibling, 1 reply; 10+ messages in thread From: Álvaro Fernández Rojas @ 2020-06-17 11:16 UTC (permalink / raw) To: Florian Fainelli Cc: simon, Jonas Gorski, kishon, vkoul, robh+dt, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel Hi Florian, > El 16 jun 2020, a las 19:17, Florian Fainelli <f.fainelli@gmail.com> escribió: > > > > On 6/16/2020 1:34 AM, Álvaro Fernández Rojas wrote: >> Document BCM63xx USBH PHY bindings. >> >> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> >> --- >> .../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 72 +++++++++++++++++++ >> 1 file changed, 72 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >> >> diff --git a/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >> new file mode 100644 >> index 000000000000..3e7c97799b91 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml >> @@ -0,0 +1,72 @@ >> +# 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 <noltari@gmail.com> >> + >> +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: 2 >> + >> + clock-names: >> + items: >> + - const: usbh >> + - const: usb_ref >> + >> + resets: >> + maxItems: 1 >> + >> + "#phy-cells": >> + const: 0 > > On 6328, the same register space allows the controlling of the USB PHY > in either host or device mode, so I believe you would need to add a > #phy-cells = 1 in order to distinguish the consumer (host versus device) > if we get to the point where drivers/usb/gadget/udc/bcm63xx_udc.c > becomes DT aware. I’ve just realized that I have implemented this wrong in v3, because I implemented the SwapControl USB_DEVICE_SEL value, and you meant the UTMIControl1 USB_DEVICE_MODE_SEL value. So I have a couple of questions about this, because I haven’t got any bcm63xx with usb device configuration to test: - Is USB_DEVICE_SEL also needed in SwapControl or do we only need USB_DEVICE_MODE_SEL in UTMIControl1? - Are the rest of the host values needed when configured in device mode? Should I only set the device values when in device mode? > > Other than that, this looks good to me! > -- > Florian Best regards, Álvaro. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-17 11:16 ` Álvaro Fernández Rojas @ 2020-06-17 21:35 ` Florian Fainelli 0 siblings, 0 replies; 10+ messages in thread From: Florian Fainelli @ 2020-06-17 21:35 UTC (permalink / raw) To: Álvaro Fernández Rojas, Florian Fainelli Cc: Jonas Gorski, kishon, vkoul, robh+dt, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel On 6/17/2020 4:16 AM, Álvaro Fernández Rojas wrote: >> On 6328, the same register space allows the controlling of the USB PHY >> in either host or device mode, so I believe you would need to add a >> #phy-cells = 1 in order to distinguish the consumer (host versus device) >> if we get to the point where drivers/usb/gadget/udc/bcm63xx_udc.c >> becomes DT aware. > > I’ve just realized that I have implemented this wrong in v3, because I implemented the SwapControl USB_DEVICE_SEL value, and you meant the UTMIControl1 USB_DEVICE_MODE_SEL value. Right that is the register I was referring to. > So I have a couple of questions about this, because I haven’t got any bcm63xx with usb device configuration to test: > - Is USB_DEVICE_SEL also needed in SwapControl or do we only need USB_DEVICE_MODE_SEL in UTMIControl1? It looks like it depends on the device, for 6318 and 63268, there is USB_DEVICE_MODE_SEL defined, but not for 6328, 6362 or 6368 for instance. Note that USB_DEVICE_MODE_SEL is relevant for port 2 only for 6318 and 63268 whereas the UTMI_CONTROL1 appears to be for any port. > - Are the rest of the host values needed when configured in device mode? Should I only set the device values when in device mode? They could probably be configured although I am not sure they sure they will be used at all, it's been a while since I looked at this (over 8 years). I don't know if you have any board with USB device mode capability, if you do not please email privately and I will ship you one. -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings 2020-06-16 8:34 ` [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings Álvaro Fernández Rojas 2020-06-16 17:17 ` Florian Fainelli @ 2020-06-17 17:00 ` Rob Herring 1 sibling, 0 replies; 10+ messages in thread From: Rob Herring @ 2020-06-17 17:00 UTC (permalink / raw) To: Álvaro Fernández Rojas Cc: vkoul, f.fainelli, jonas.gorski, simon, robh+dt, kishon, devicetree, krzk, p.zabel, linux-arm-kernel, gregkh, linux-kernel, alcooperx, bcm-kernel-feedback-list On Tue, 16 Jun 2020 10:34:07 +0200, Álvaro Fernández Rojas wrote: > Document BCM63xx USBH PHY bindings. > > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> > --- > .../bindings/phy/brcm,bcm63xx-usbh-phy.yaml | 72 +++++++++++++++++++ > 1 file changed, 72 insertions(+) > create mode 100644 Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.yaml > My bot found errors running 'make dt_binding_check' on your patch: Error: Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.example.dts:22.33-34 syntax error FATAL ERROR: Unable to parse input tree scripts/Makefile.lib:315: recipe for target 'Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.example.dt.yaml' failed make[1]: *** [Documentation/devicetree/bindings/phy/brcm,bcm63xx-usbh-phy.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs.... Makefile:1347: recipe for target 'dt_binding_check' failed make: *** [dt_binding_check] Error 2 See https://patchwork.ozlabs.org/patch/1310130 If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date: pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade Please check and re-submit. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver 2020-06-16 8:34 [PATCH 0/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas 2020-06-16 8:34 ` [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings Álvaro Fernández Rojas @ 2020-06-16 8:34 ` Álvaro Fernández Rojas 2020-06-16 17:22 ` Florian Fainelli 1 sibling, 1 reply; 10+ messages in thread From: Álvaro Fernández Rojas @ 2020-06-16 8:34 UTC (permalink / raw) To: simon, jonas.gorski, kishon, vkoul, robh+dt, f.fainelli, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel Cc: Álvaro Fernández Rojas Add BCM63xx USBH PHY driver for BMIPS. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> --- drivers/phy/broadcom/Kconfig | 10 + drivers/phy/broadcom/Makefile | 1 + drivers/phy/broadcom/phy-bcm63xx-usbh.c | 463 ++++++++++++++++++++++++ 3 files changed, 474 insertions(+) create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig index b29f11c19155..896506c7b1f8 100644 --- a/drivers/phy/broadcom/Kconfig +++ b/drivers/phy/broadcom/Kconfig @@ -2,6 +2,16 @@ # # Phy drivers for Broadcom platforms # +config PHY_BCM63XX_USBH + tristate "BCM63xx USBH PHY driver" + depends on BMIPS_GENERIC || COMPILE_TEST + depends on OF + 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) diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile index c78de546135c..7024127f86ad 100644 --- a/drivers/phy/broadcom/Makefile +++ b/drivers/phy/broadcom/Makefile @@ -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 diff --git a/drivers/phy/broadcom/phy-bcm63xx-usbh.c b/drivers/phy/broadcom/phy-bcm63xx-usbh.c new file mode 100644 index 000000000000..c7225dc99c49 --- /dev/null +++ b/drivers/phy/broadcom/phy-bcm63xx-usbh.c @@ -0,0 +1,463 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * BCM6328 USBH PHY Controller Driver + * + * Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com> + * Copyright (C) 2015 Simon Arlott <simon@fire.lp0.eu> + * + * Derived from bcm963xx_4.12L.06B_consumer/kernel/linux/arch/mips/bcm963xx/setup.c: + * Copyright (C) 2002 Broadcom Corporation + * + * Derived from OpenWrt patches: + * Copyright (C) 2013 Jonas Gorski <jonas.gorski@gmail.com> + * Copyright (C) 2013 Florian Fainelli <f.fainelli@gmail.com> + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> + */ + +#include <linux/clk.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/reset.h> + +/* USBH control register offsets */ +enum usbh_regs { + USBH_BRT_CONTROL1 = 0, + USBH_BRT_CONTROL2, + USBH_BRT_STATUS1, + USBH_BRT_STATUS2, + USBH_UTMI_CONTROL1, + USBH_TEST_PORT_CONTROL, + USBH_PLL_CONTROL1, +#define USBH_PLLC_REFCLKSEL_SHIFT 0 +#define USBH_PLLC_REFCLKSEL_MASK (0x3 << USBH_PLLC_REFCLKSEL_SHIFT) +#define USBH_PLLC_CLKSEL_SHIFT 2 +#define USBH_PLLC_CLKSEL_MASK (0x3 << USBH_PLLC_CLKSEL_MASK) +#define USBH_PLLC_XTAL_PWRDWNB BIT(4) +#define USBH_PLLC_PLL_PWRDWNB BIT(5) +#define USBH_PLLC_PLL_CALEN BIT(6) +#define USBH_PLLC_PHYPLL_BYP BIT(7) +#define USBH_PLLC_PLL_RESET BIT(8) +#define USBH_PLLC_PLL_IDDQ_PWRDN BIT(9) +#define USBH_PLLC_PLL_PWRDN_DELAY BIT(10) +#define USBH_6318_PLLC_PLL_SUSPEND_EN BIT(27) +#define USBH_6318_PLLC_PHYPLL_BYP BIT(29) +#define USBH_6318_PLLC_PLL_RESET BIT(30) +#define USBH_6318_PLLC_PLL_IDDQ_PWRDN BIT(31) + USBH_SWAP_CONTROL, +#define USBH_SC_OHCI_DATA_SWAP BIT(0) +#define USBH_SC_OHCI_ENDIAN_SWAP BIT(1) +#define USBH_SC_OHCI_LOGICAL_ADDR_EN BIT(2) +#define USBH_SC_EHCI_DATA_SWAP BIT(3) +#define USBH_SC_EHCI_ENDIAN_SWAP BIT(4) +#define USBH_SC_EHCI_LOGICAL_ADDR_EN BIT(5) +#define USBH_SC_USB_DEVICE_SEL BIT(6) + USBH_GENERIC_CONTROL, +#define USBH_GC_PLL_SUSPEND_EN BIT(1) + USBH_FRAME_ADJUST_VALUE, + USBH_SETUP, +#define USBH_S_IOC BIT(4) +#define USBH_S_IPP BIT(5) + USBH_MDIO, + USBH_MDIO32, + USBH_USB_SIM_CONTROL, +#define USBH_USC_LADDR_SEL BIT(5) + + __USBH_ENUM_SIZE +}; + +struct bcm63xx_usbh_phy_variant { + /* USB Sim Control bits to set */ + u32 usc_set; + + /* Test Port Control value to set if non-zero */ + u32 tpc_val; + + /* Setup bits to set/clear for power on */ + u32 setup_set; + u32 setup_clr; + + /* PLLC bits to set/clear for power on */ + u32 power_pllc_set; + u32 power_pllc_clr; + + /* USB clocks */ + bool has_usb_clk; + bool has_usb_ref_clk; + + /* Registers */ + long regs[__USBH_ENUM_SIZE]; +}; + +struct bcm63xx_usbh_phy { + void __iomem *base; + struct clk *usbh_clk; + struct clk *usb_ref_clk; + struct reset_control *reset; + struct bcm63xx_usbh_phy_variant variant; +}; + +static const struct bcm63xx_usbh_phy_variant usbh_bcm6318 __initconst = { + .regs = { + [USBH_BRT_CONTROL1] = -1, + [USBH_BRT_CONTROL2] = -1, + [USBH_BRT_STATUS1] = -1, + [USBH_BRT_STATUS2] = -1, + [USBH_UTMI_CONTROL1] = 0x2c, + [USBH_TEST_PORT_CONTROL] = 0x1c, + [USBH_PLL_CONTROL1] = 0x04, + [USBH_SWAP_CONTROL] = 0x0c, + [USBH_GENERIC_CONTROL] = -1, + [USBH_FRAME_ADJUST_VALUE] = 0x08, + [USBH_SETUP] = 0x00, + [USBH_MDIO] = 0x14, + [USBH_MDIO32] = 0x18, + [USBH_USB_SIM_CONTROL] = 0x20, + }, + .setup_set = USBH_S_IOC, + .setup_clr = 0, + .usc_set = USBH_USC_LADDR_SEL, + .tpc_val = 0, + .power_pllc_set = USBH_6318_PLLC_PLL_SUSPEND_EN, + .power_pllc_clr = USBH_6318_PLLC_PLL_IDDQ_PWRDN, + .has_usb_clk = 1, + .has_usb_ref_clk = 1, +}; + +static const struct bcm63xx_usbh_phy_variant usbh_bcm6328 __initconst = { + .regs = { + [USBH_BRT_CONTROL1] = 0x00, + [USBH_BRT_CONTROL2] = 0x04, + [USBH_BRT_STATUS1] = 0x08, + [USBH_BRT_STATUS2] = 0x0c, + [USBH_UTMI_CONTROL1] = 0x10, + [USBH_TEST_PORT_CONTROL] = 0x14, + [USBH_PLL_CONTROL1] = 0x18, + [USBH_SWAP_CONTROL] = 0x1c, + [USBH_GENERIC_CONTROL] = 0x20, + [USBH_FRAME_ADJUST_VALUE] = 0x24, + [USBH_SETUP] = 0x28, + [USBH_MDIO] = 0x2c, + [USBH_MDIO32] = 0x30, + [USBH_USB_SIM_CONTROL] = 0x34, + }, + .setup_set = USBH_S_IOC, + .setup_clr = 0, + .usc_set = 0, + .tpc_val = 0, + .power_pllc_set = 0, + .power_pllc_clr = 0, + .has_usb_clk = 1, + .has_usb_ref_clk = 0, +}; + +static const struct bcm63xx_usbh_phy_variant usbh_bcm6358 __initconst = { + .regs = { + [USBH_BRT_CONTROL1] = -1, + [USBH_BRT_CONTROL2] = -1, + [USBH_BRT_STATUS1] = -1, + [USBH_BRT_STATUS2] = -1, + [USBH_UTMI_CONTROL1] = -1, + [USBH_TEST_PORT_CONTROL] = 0x24, + [USBH_PLL_CONTROL1] = -1, + [USBH_SWAP_CONTROL] = 0x00, + [USBH_GENERIC_CONTROL] = -1, + [USBH_FRAME_ADJUST_VALUE] = -1, + [USBH_SETUP] = -1, + [USBH_MDIO] = -1, + [USBH_MDIO32] = -1, + [USBH_USB_SIM_CONTROL] = -1, + }, + /* + * The magic value comes for the original vendor BSP + * and is needed for USB to work. Datasheet does not + * help, so the magic value is used as-is. + */ + .tpc_val = 0x1c0020, + .has_usb_clk = 0, + .has_usb_ref_clk = 0, +}; + +static const struct bcm63xx_usbh_phy_variant usbh_bcm6368 __initconst = { + .regs = { + [USBH_BRT_CONTROL1] = 0x00, + [USBH_BRT_CONTROL2] = 0x04, + [USBH_BRT_STATUS1] = 0x08, + [USBH_BRT_STATUS2] = 0x0c, + [USBH_UTMI_CONTROL1] = 0x10, + [USBH_TEST_PORT_CONTROL] = 0x14, + [USBH_PLL_CONTROL1] = 0x18, + [USBH_SWAP_CONTROL] = 0x1c, + [USBH_GENERIC_CONTROL] = -1, + [USBH_FRAME_ADJUST_VALUE] = 0x24, + [USBH_SETUP] = 0x28, + [USBH_MDIO] = 0x2c, + [USBH_MDIO32] = 0x30, + [USBH_USB_SIM_CONTROL] = 0x34, + }, + .setup_set = USBH_S_IOC, + .setup_clr = 0, + .usc_set = 0, + .tpc_val = 0, + .power_pllc_set = 0, + .power_pllc_clr = USBH_PLLC_PLL_IDDQ_PWRDN | USBH_PLLC_PLL_PWRDN_DELAY, + .has_usb_clk = 1, + .has_usb_ref_clk = 0, +}; + +static const struct bcm63xx_usbh_phy_variant usbh_bcm63268 __initconst = { + .regs = { + [USBH_BRT_CONTROL1] = 0x00, + [USBH_BRT_CONTROL2] = 0x04, + [USBH_BRT_STATUS1] = 0x08, + [USBH_BRT_STATUS2] = 0x0c, + [USBH_UTMI_CONTROL1] = 0x10, + [USBH_TEST_PORT_CONTROL] = 0x14, + [USBH_PLL_CONTROL1] = 0x18, + [USBH_SWAP_CONTROL] = 0x1c, + [USBH_GENERIC_CONTROL] = 0x20, + [USBH_FRAME_ADJUST_VALUE] = 0x24, + [USBH_SETUP] = 0x28, + [USBH_MDIO] = 0x2c, + [USBH_MDIO32] = 0x30, + [USBH_USB_SIM_CONTROL] = 0x34, + }, + .setup_set = USBH_S_IOC, + .setup_clr = USBH_S_IPP, + .usc_set = 0, + .tpc_val = 0, + .power_pllc_set = 0, + .power_pllc_clr = USBH_PLLC_PLL_IDDQ_PWRDN | USBH_PLLC_PLL_PWRDN_DELAY, + .has_usb_clk = 1, + .has_usb_ref_clk = 1, +}; + +static inline bool usbh_has_reg(struct bcm63xx_usbh_phy *usbh, int reg) +{ + return (usbh->variant.regs[reg] >= 0); +} + +static inline u32 usbh_readl(struct bcm63xx_usbh_phy *usbh, int reg) +{ + return __raw_readl(usbh->base + usbh->variant.regs[reg]); +} + +static inline void usbh_writel(struct bcm63xx_usbh_phy *usbh, int reg, + u32 value) +{ + __raw_writel(value, usbh->base + usbh->variant.regs[reg]); +} + +static int bcm63xx_usbh_phy_init(struct phy *phy) +{ + struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); + int ret; + + ret = clk_prepare_enable(usbh->usbh_clk); + if (ret) { + dev_err(&phy->dev, "unable to enable usbh clock: %d\n", ret); + return ret; + } + + ret = clk_prepare_enable(usbh->usb_ref_clk); + if (ret) { + dev_err(&phy->dev, "unable to enable usb_ref clock: %d\n", ret); + clk_disable_unprepare(usbh->usbh_clk); + return ret; + } + + ret = reset_control_reset(usbh->reset); + if (ret) { + dev_err(&phy->dev, "unable to reset device: %d\n", ret); + clk_disable_unprepare(usbh->usb_ref_clk); + clk_disable_unprepare(usbh->usbh_clk); + return ret; + } + + /* Configure to work in native CPU endian */ + if (usbh_has_reg(usbh, USBH_SWAP_CONTROL)) { + u32 val = usbh_readl(usbh, USBH_SWAP_CONTROL); + + val |= USBH_SC_EHCI_DATA_SWAP; + val &= ~USBH_SC_EHCI_ENDIAN_SWAP; + + val |= USBH_SC_OHCI_DATA_SWAP; + val &= ~USBH_SC_OHCI_ENDIAN_SWAP; + + usbh_writel(usbh, USBH_SWAP_CONTROL, val); + } + + if (usbh_has_reg(usbh, USBH_SETUP)) { + u32 val = usbh_readl(usbh, USBH_SETUP); + + val |= usbh->variant.setup_set; + val &= ~usbh->variant.setup_clr; + + usbh_writel(usbh, USBH_SETUP, val); + } + + if (usbh_has_reg(usbh, USBH_USB_SIM_CONTROL)) { + u32 val = usbh_readl(usbh, USBH_USB_SIM_CONTROL); + + val |= usbh->variant.usc_set; + + usbh_writel(usbh, USBH_USB_SIM_CONTROL, val); + } + + if (usbh->variant.tpc_val && + usbh_has_reg(usbh, USBH_TEST_PORT_CONTROL)) + usbh_writel(usbh, USBH_TEST_PORT_CONTROL, + usbh->variant.tpc_val); + + return 0; +} + +static int bcm63xx_usbh_phy_power_on(struct phy *phy) +{ + struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); + + if (usbh_has_reg(usbh, USBH_PLL_CONTROL1)) { + u32 val = usbh_readl(usbh, USBH_PLL_CONTROL1); + + val |= usbh->variant.power_pllc_set; + val &= ~usbh->variant.power_pllc_clr; + + usbh_writel(usbh, USBH_PLL_CONTROL1, val); + } + + return 0; +} + +static int bcm63xx_usbh_phy_power_off(struct phy *phy) +{ + struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); + + if (usbh_has_reg(usbh, USBH_PLL_CONTROL1)) { + u32 val = usbh_readl(usbh, USBH_PLL_CONTROL1); + + val &= ~usbh->variant.power_pllc_set; + val |= usbh->variant.power_pllc_clr; + + usbh_writel(usbh, USBH_PLL_CONTROL1, val); + } + + return 0; +} + +static int bcm63xx_usbh_phy_exit(struct phy *phy) +{ + struct bcm63xx_usbh_phy *usbh = phy_get_drvdata(phy); + + clk_disable_unprepare(usbh->usbh_clk); + clk_disable_unprepare(usbh->usb_ref_clk); + + return 0; +} + +static const struct phy_ops bcm63xx_usbh_phy_ops = { + .exit = bcm63xx_usbh_phy_exit, + .init = bcm63xx_usbh_phy_init, + .power_off = bcm63xx_usbh_phy_power_off, + .power_on = bcm63xx_usbh_phy_power_on, + .owner = THIS_MODULE, +}; + +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 resource *res; + struct phy *phy; + struct phy_provider *phy_provider; + + usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL); + if (!usbh) + return -ENOMEM; + + variant = of_device_get_match_data(dev); + if (!variant) + return -EINVAL; + memcpy(&usbh->variant, variant, sizeof(*variant)); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + usbh->base = devm_ioremap_resource(dev, res); + if (IS_ERR(usbh->base)) + return PTR_ERR(usbh->base); + + usbh->reset = devm_reset_control_get(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); + } + + if (variant->has_usb_clk) { + usbh->usbh_clk = devm_clk_get(dev, "usbh"); + if (IS_ERR(usbh->usbh_clk)) { + if (PTR_ERR(usbh->usbh_clk) != -EPROBE_DEFER) + dev_err(dev, "failed to get usbh clock\n"); + return PTR_ERR(usbh->usbh_clk); + } + } else { + usbh->usbh_clk = NULL; + } + + if (variant->has_usb_ref_clk) { + usbh->usb_ref_clk = devm_clk_get(dev, "usb_ref"); + if (IS_ERR(usbh->usb_ref_clk)) { + if (PTR_ERR(usbh->usb_ref_clk) != -EPROBE_DEFER) + dev_err(dev, "failed to get usb_ref clock\n"); + return PTR_ERR(usbh->usb_ref_clk); + } + } else { + usbh->usb_ref_clk = NULL; + } + + 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, of_phy_simple_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"); + + return 0; +} + +static const struct of_device_id bcm63xx_usbh_phy_ids[] __initconst = { + { .compatible = "brcm,bcm6318-usbh-phy", .data = &usbh_bcm6318 }, + { .compatible = "brcm,bcm6328-usbh-phy", .data = &usbh_bcm6328 }, + { .compatible = "brcm,bcm6358-usbh-phy", .data = &usbh_bcm6358 }, + { .compatible = "brcm,bcm6362-usbh-phy", .data = &usbh_bcm6368 }, + { .compatible = "brcm,bcm6368-usbh-phy", .data = &usbh_bcm6368 }, + { .compatible = "brcm,bcm63268-usbh-phy", .data = &usbh_bcm63268 }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, bcm63xx_usbh_phy_ids); + +static struct platform_driver bcm63xx_usbh_phy_driver __refdata = { + .driver = { + .name = "bcm63xx-usbh-phy", + .of_match_table = bcm63xx_usbh_phy_ids, + }, + .probe = bcm63xx_usbh_phy_probe, +}; +module_platform_driver(bcm63xx_usbh_phy_driver); + +MODULE_DESCRIPTION("BCM63xx USBH PHY driver"); +MODULE_AUTHOR("Álvaro Fernández Rojas <noltari@gmail.com>"); +MODULE_AUTHOR("Simon Arlott <simon@fire.lp0.eu>"); +MODULE_LICENSE("GPL"); -- 2.27.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver 2020-06-16 8:34 ` [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas @ 2020-06-16 17:22 ` Florian Fainelli 0 siblings, 0 replies; 10+ messages in thread From: Florian Fainelli @ 2020-06-16 17:22 UTC (permalink / raw) To: Álvaro Fernández Rojas, simon, jonas.gorski, kishon, vkoul, robh+dt, f.fainelli, bcm-kernel-feedback-list, p.zabel, krzk, gregkh, alcooperx, linux-kernel, devicetree, linux-arm-kernel On 6/16/2020 1:34 AM, Álvaro Fernández Rojas wrote: > Add BCM63xx USBH PHY driver for BMIPS. > > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> This looks good to me at first glance, just a few comments below. > --- > drivers/phy/broadcom/Kconfig | 10 + > drivers/phy/broadcom/Makefile | 1 + > drivers/phy/broadcom/phy-bcm63xx-usbh.c | 463 ++++++++++++++++++++++++ > 3 files changed, 474 insertions(+) > create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c > > diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig > index b29f11c19155..896506c7b1f8 100644 > --- a/drivers/phy/broadcom/Kconfig > +++ b/drivers/phy/broadcom/Kconfig > @@ -2,6 +2,16 @@ > # > # Phy drivers for Broadcom platforms > # > +config PHY_BCM63XX_USBH > + tristate "BCM63xx USBH PHY driver" > + depends on BMIPS_GENERIC || COMPILE_TEST > + depends on OF I do not think you need to add the depends on OF here if you use device_get_match_data() instead of of_device_get_match_data() and devm_of_phy_provider_register() has an inline stub provided when CONFIG_OF=n. [snip] > +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 resource *res; > + struct phy *phy; > + struct phy_provider *phy_provider; > + > + usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL); > + if (!usbh) > + return -ENOMEM; > + > + variant = of_device_get_match_data(dev); We can use device_get_match_data() to be OF independent. > + if (!variant) > + return -EINVAL; > + memcpy(&usbh->variant, variant, sizeof(*variant)); I would just avoid marking the variant tables with __initconst, and just reference them directly here. > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + usbh->base = devm_ioremap_resource(dev, res); > + if (IS_ERR(usbh->base)) > + return PTR_ERR(usbh->base); > + > + usbh->reset = devm_reset_control_get(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); > + } > + > + if (variant->has_usb_clk) { > + usbh->usbh_clk = devm_clk_get(dev, "usbh"); You can use devm_clk_get_optional() which would save you from having to record whether the clock is needed or not. > + if (IS_ERR(usbh->usbh_clk)) { > + if (PTR_ERR(usbh->usbh_clk) != -EPROBE_DEFER) > + dev_err(dev, "failed to get usbh clock\n"); > + return PTR_ERR(usbh->usbh_clk); > + } > + } else { > + usbh->usbh_clk = NULL; > + } > + > + if (variant->has_usb_ref_clk) { > + usbh->usb_ref_clk = devm_clk_get(dev, "usb_ref"); Likewise. -- Florian ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-06-17 21:36 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-06-16 8:34 [PATCH 0/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas 2020-06-16 8:34 ` [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings Álvaro Fernández Rojas 2020-06-16 17:17 ` Florian Fainelli 2020-06-16 18:10 ` Álvaro Fernández Rojas 2020-06-16 18:21 ` Florian Fainelli 2020-06-17 11:16 ` Álvaro Fernández Rojas 2020-06-17 21:35 ` Florian Fainelli 2020-06-17 17:00 ` Rob Herring 2020-06-16 8:34 ` [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas 2020-06-16 17:22 ` Florian Fainelli
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).