Enable IPQ5332 USB2
Subsystems (5)
v5 cover Enable IPQ5332 USB2
This patch series adds the relevant phy and controller configurations for enabling USB2 on IPQ5332
v5:
Binding and dts:-
Fix email id
Removed 'Reviewed-by: Krzysztof Kozlowski <[email protected]>' as had to change bindings file to be able to use generic phy instead of usb-phy
Driver:-
Remove unused definition Use generic phy instead of usb-phy
v4:
Binding and dts:-
Change node name (bindings & dts)
Driver:-
Remove unused enum
static const for '.data' Error handling for devm_clk_get
v3:
Fix bindings file based on review comments
v1:
Cleanup DTS
Combine driver, kconfig and makefile patches Remove unused functions from M31 driver Drop the clock driver changes
Varadarajan Narayanan (6):
dt-bindings: usb: dwc3: Add IPQ5332 compatible
dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
phy: qcom-m31: Introduce qcom,m31 USB phy driver
arm64: dts: qcom: ipq5332: Add USB related nodes
arm64: dts: qcom: ipq5332: Enable USB
arm64: defconfig: Enable M31 USB phy driver
.../bindings/phy/qcom,ipq5332-usb-hsphy.yaml | 51 ++++ .../devicetree/bindings/usb/qcom,dwc3.yaml | 3 + arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts | 12 + arch/arm64/boot/dts/qcom/ipq5332.dtsi | 56 +++++ arch/arm64/configs/defconfig | 1 + drivers/phy/qualcomm/Kconfig | 11 + drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-m31.c | 264 +++++++++++++++++++++ 8 files changed, 399 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml create mode 100644 drivers/phy/qualcomm/phy-qcom-m31.c
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v5 1/6 dt-bindings: usb: dwc3: Add IPQ5332 compatible
Document the IPQ5332 dwc3 compatible.
---
v1:
Add ipq5332 to interrupts sections
--- Documentation/devicetree/bindings/usb/qcom,dwc3.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/usb/qcom,dwc3.yaml +3 -0
@@ -14,6 +14,7 @@ properties: items: - enum: - qcom,ipq4019-dwc3 + - qcom,ipq5332-dwc3 - qcom,ipq6018-dwc3 - qcom,ipq8064-dwc3 - qcom,ipq8074-dwc3
@@ -246,6 +247,7 @@ allOf: compatible: contains: enum: + - qcom,ipq5332-dwc3 - qcom,msm8994-dwc3 - qcom,qcs404-dwc3 then:
@@ -410,6 +412,7 @@ allOf: compatible: contains: enum: + - qcom,ipq5332-dwc3 - qcom,sdm660-dwc3 then: properties:
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v5 2/6 dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
In reply to Varadarajan NarayananDocument the M31 USB2 phy present in IPQ5332.
---
v5:
Add '#phy-cells', to be able to use generic phy Remove 'Reviewed-by: Krzysztof Kozlowski' due to above change
v4:
Move M31 URL to description
Remove maxItems and relevant content from clock-names Change node name to generic name
'make dt_binding_check DT_SCHEMA_FILES=qcom' passed
v3:
Incorporate review comments. Will bring in ipq5018 compatible string while posting ipq5018 usb patchset.
v1:
Rename qcom,m31.yaml -> qcom,ipq5332-usb-hsphy.yaml Drop default binding "m31,usb-hsphy"
Add clock
Remove 'oneOf' from compatible
Remove 'qscratch' region from register space as it is not needed Remove reset-names
Fix the example definition
--- .../bindings/phy/qcom,ipq5332-usb-hsphy.yaml | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,ipq5332-usb-hsphy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: M31 USB PHY + +maintainers: + - Sricharan Ramabadhran <[email protected]> + - Varadarajan Narayanan <[email protected]> + +description: + USB M31 PHY (https://www.m31tech.com) found in Qualcomm + IPQ5018, IPQ5332 SoCs. + +properties: + "#phy-cells": + const: 0 + + compatible: + enum: + - qcom,ipq5332-usb-hsphy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: cfg_ahb + + resets: + maxItems: 1 + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,ipq5332-gcc.h> + usbphy0: usb-phy@7b000 { + compatible = "qcom,ipq5332-usb-hsphy"; + reg = <0x0007b000 0x12c>; + + clocks = <&gcc GCC_USB0_PHY_CFG_AHB_CLK>; + clock-names = "cfg_ahb"; + + resets = <&gcc GCC_QUSB2_0_PHY_BCR>; + };
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Bjorn Andersson
maintainerRe: [PATCH v5 2/6] dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
Quoted 3 lines · Varadarajan Narayanan
Document the M31 USB2 phy present in IPQ5332.
Signed-off-by Sricharan Ramabadhran <[email protected]>
As Sricharan is the first one to certify the patch's origin, it seems likely that he's the author. Please add a Co-developed-by: Sricharan.
[..]
Quoted 18 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +12
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,ipq5332-usb-hsphy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: M31 USB PHY + +maintainers: + - Sricharan Ramabadhran <[email protected]> + - Varadarajan Narayanan <[email protected]> +
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +10
-0+description: + USB M31 PHY (https://www.m31tech.com) found in Qualcomm + IPQ5018, IPQ5332 SoCs. + +properties: + "#phy-cells": + const: 0 + + compatible: + enum:
const?
Quoted 11 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +11
-0+ - qcom,ipq5332-usb-hsphy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: cfg_ahb
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +10
-0+ + resets: + maxItems: 1 + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,ipq5332-gcc.h> + usbphy0: usb-phy@7b000 {
usb@
And you don't need to give the node a label in the example.
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 49
Quoted 6 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +6
-0+ compatible = "qcom,ipq5332-usb-hsphy"; + reg = <0x0007b000 0x12c>; + + clocks = <&gcc GCC_USB0_PHY_CFG_AHB_CLK>; + clock-names = "cfg_ahb"; +
No #phy-cells?
Regards,
Bjorn
Quoted 5 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +2
-0+ resets = <&gcc GCC_QUSB2_0_PHY_BCR>; + };Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH v5 2/6] dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
Quoted 55 lines · Bjorn Andersson
Quoted 3 lines · Varadarajan Narayanan
Document the M31 USB2 phy present in IPQ5332.
Signed-off-by Sricharan Ramabadhran <[email protected]>As Sricharan is the first one to certify the patch's origin, it seems likely that he's the author. Please add a Co-developed-by: Sricharan.
[..]
Quoted 18 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +12
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/qcom,ipq5332-usb-hsphy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: M31 USB PHY + +maintainers: + - Sricharan Ramabadhran <[email protected]> + - Varadarajan Narayanan <[email protected]> +Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +10
-0+description: + USB M31 PHY (https://www.m31tech.com) found in Qualcomm + IPQ5018, IPQ5332 SoCs. + +properties: + "#phy-cells": + const: 0 + + compatible: + enum:const?
Quoted 15 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +15
-0+ - qcom,ipq5332-usb-hsphy + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: cfg_ahb + + resets: + maxItems: 1 +
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 43
Quoted 6 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +6
-0+additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,ipq5332-gcc.h> + usbphy0: usb-phy@7b000 {usb@
You mean phy@? But 'usb2-phy' is accepted too.
Quoted 20 lines
And you don't need to give the node a label in the example.
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 49
Quoted 6 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +6
-0+ compatible = "qcom,ipq5332-usb-hsphy"; + reg = <0x0007b000 0x12c>; + + clocks = <&gcc GCC_USB0_PHY_CFG_AHB_CLK>; + clock-names = "cfg_ahb"; +No #phy-cells?
Regards,
BjornQuoted 5 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml new file +2
-0+ resets = <&gcc GCC_QUSB2_0_PHY_BCR>; + };Signature · 1 line
2.7.4
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Bjorn Andersson
maintainerRe: [PATCH v5 2/6] dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
Quoted 4 lines · Rob Herring
Quoted 3 lines · Bjorn Andersson
On Fri, Jul 21, 2023 at 10:05:27AM +0530, Varadarajan Narayanan wrote:
[..]Quoted 1 line
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml +0
-0
[..]
Quoted 9 lines
Quoted 6 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml line 43
Quoted 4 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml +4
-0+examples: + - | + #include <dt-bindings/clock/qcom,ipq5332-gcc.h> + usbphy0: usb-phy@7b000 {usb@
You mean phy@? But 'usb2-phy' is accepted too.
Yes, had the controller in mind, sorry about that.
Thanks,
Bjorn
Re: [PATCH v5 2/6] dt-bindings: phy: qcom,m31: Document qcom,m31 USB phy
Bjorn & Rob,
Quoted 11 lines · Bjorn Andersson
Quoted 4 lines · Rob Herring
Quoted 3 lines · Bjorn Andersson
On Fri, Jul 21, 2023 at 10:05:27AM +0530, Varadarajan Narayanan wrote:
[..]Quoted 1 line
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml +0
-0[..]
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Documentation/devicetree/bindings/phy/qcom,ipq5332-usb-hsphy.yaml +4
-0+examples: + - | + #include <dt-bindings/clock/qcom,ipq5332-gcc.h> + usbphy0: usb-phy@7b000 {
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
usb@
You mean phy@? But 'usb2-phy' is accepted too.
Yes, had the controller in mind, sorry about that.
Have posted a new patchset addressing the comments. Please provide your feedback.
Thanks
Varada
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH v5 3/6 phy: qcom-m31: Introduce qcom,m31 USB phy driver
In reply to Varadarajan NarayananAdd the M31 USB2 phy driver.
---
v5:
Kconfig and Makefile:- place snippet according to sorted order Use generic phy instead of usb-phy
Use ARRAY_SIZE for reg init instead of blank last entry Fix copyright year
v4:
Remove unused enum
Error handling for devm_clk_get
v1:
Combine driver, makefile and kconfig into 1 patch
Remove 'qscratch' region and its usage. The controller driver takes care of those settings
Use compatible/data to handle ipq5332 init
Drop the default case
Get resources by index instead of name as there is only one resource Add clock
Fix review comments in the driver
--- drivers/phy/qualcomm/Kconfig | 11 ++ drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-m31.c | 264 ++++++++++++++++++++++++++++++++++++ 3 files changed, 276 insertions(+) create mode 100644 drivers/phy/qualcomm/phy-qcom-m31.c
drivers/phy/qualcomm/Kconfig +11 -0
@@ -143,6 +143,17 @@ config PHY_QCOM_EUSB2_REPEATER PMICs. The repeater is paired with a Synopsys eUSB2 Phy on Qualcomm SOCs. +config PHY_QCOM_M31_USB + tristate "Qualcomm M31 HS PHY driver support" + depends on (USB || USB_GADGET) && ARCH_QCOM + select USB_PHY + help + Enable this to support M31 HS PHY transceivers on Qualcomm chips + with DWC3 USB core. It handles PHY initialization, clock + management required after resetting the hardware and power + management. This driver is required even for peripheral only or + host only mode configurations. + config PHY_QCOM_USB_HS tristate "Qualcomm USB HS PHY module" depends on USB_ULPI_BUS
drivers/phy/qualcomm/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o obj-$(CONFIG_PHY_QCOM_EDP) += phy-qcom-edp.o obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o +obj-$(CONFIG_PHY_QCOM_M31_USB) += phy-qcom-m31.o obj-$(CONFIG_PHY_QCOM_PCIE2) += phy-qcom-pcie2.o obj-$(CONFIG_PHY_QCOM_QMP_COMBO) += phy-qcom-qmp-combo.o
drivers/phy/qualcomm/phy-qcom-m31.c new file +264 -0
264 lines not on this page · raw message
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Bjorn Andersson
maintainerRe: [PATCH v5 3/6] phy: qcom-m31: Introduce qcom,m31 USB phy driver
Quoted 1 line · Varadarajan Narayanan
Add the M31 USB2 phy driver.
Is it possible to extend this description a little bit? E.g. mention where this PHY is used.
Quoted 33 lines
Signed-off-by Varadarajan Narayanan <[email protected]>---
v5:
Kconfigand Makefile:- place snippet according to sorted order Use generic phy instead of usb-phy
UseARRAY_SIZEfor reg init instead of blank last entry Fix copyright yearv4:
Remove unused enum
Error handling fordevm_clk_get
v1:
Combine driver, makefile and kconfig into 1 patch
Remove 'qscratch' region and its usage. The controller driver takes care of those settings
Use compatible/data to handle ipq5332 init
Drop the default case
Get resources by index instead of name as there is only one resource Add clock
Fix review comments in the driver--- drivers/phy/qualcomm/Kconfig | 11 ++ drivers/phy/qualcomm/Makefile | 1 + drivers/phy/qualcomm/phy-qcom-m31.c | 264 ++++++++++++++++++++++++++++++++++++ 3 files changed, 276 insertions(+) create mode 100644 drivers/phy/qualcomm/phy-qcom-m31.cdrivers/phy/qualcomm/Kconfig +0
-0
drivers/phy/qualcomm/Kconfig config PHY_QCOM_EUSB2_REPEATER · line 148
Quoted 6 lines
drivers/phy/qualcomm/Kconfig +3
-0@@ -143,6 +143,17 @@ config PHY_QCOM_EUSB2_REPEATER PMICs. The repeater is paired with a Synopsys eUSB2 Phy on Qualcomm SOCs. +config PHY_QCOM_M31_USB + tristate "Qualcomm M31 HS PHY driver support" + depends on (USB || USB_GADGET) && ARCH_QCOM
The USB part seems reasonable, but it's not clear to me why you depend on USB_GADGET. And this is the only option in this directory that depends on it's consumer subsystem...
It is reasonable help the user not choose the driver if ARCH_QCOM is disabled, but most other options in this file allow compilation during COMPILE_TEST. This provides additional build coverage, so perhaps you could adopt this as well?
drivers/phy/qualcomm/Kconfig config PHY_QCOM_EUSB2_REPEATER · line 149
Quoted 1 line
drivers/phy/qualcomm/Kconfig +1
-0+ select USB_PHY
USB_PHY is for drivers in drivers/usb/phy, but you're using the generic PHY framework. Is this really needed, or just a remnant from downstream?
You should however select GENERIC_PHY, like all other options in this file.
Quoted 28 lines
drivers/phy/qualcomm/Kconfig +7
-0+ help + Enable this to support M31 HS PHY transceivers on Qualcomm chips + with DWC3 USB core. It handles PHY initialization, clock + management required after resetting the hardware and power + management. This driver is required even for peripheral only or + host only mode configurations. + config PHY_QCOM_USB_HS tristate "Qualcomm USB HS PHY module" depends on USB_ULPI_BUSdrivers/phy/qualcomm/Makefile +1
-0@@ -4,6 +4,7 @@ obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o obj-$(CONFIG_PHY_QCOM_EDP) += phy-qcom-edp.o obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o +obj-$(CONFIG_PHY_QCOM_M31_USB) += phy-qcom-m31.o obj-$(CONFIG_PHY_QCOM_PCIE2) += phy-qcom-pcie2.o obj-$(CONFIG_PHY_QCOM_QMP_COMBO) += phy-qcom-qmp-combo.odrivers/phy/qualcomm/phy-qcom-m31.c new file +0
-0
drivers/phy/qualcomm/phy-qcom-m31.c line 3
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +3
-0@@ -0,0 +1,264 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2014-2016, 2020-2023, The Linux Foundation. All rights reserved.
Please fix this.
drivers/phy/qualcomm/phy-qcom-m31.c line 12
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +9
-0+*/ + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of_device.h>
Rob Herring has posted a bunch of patches lately removing uses of of_device.h, so please don't introduce a new one.
of.h and of_platform.h are to be used instead.
drivers/phy/qualcomm/phy-qcom-m31.c line 18
Quoted 6 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +6
-0+#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/reset.h> +#include <linux/slab.h> +#include <linux/usb/of.h> +#include <linux/usb/phy.h>
I don't think you need the last two, in a generic phy driver.
Quoted 56 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +56
-0+ +#define USB2PHY_PORT_UTMI_CTRL1 0x40 + +#define USB2PHY_PORT_UTMI_CTRL2 0x44 +#define UTMI_ULPI_SEL BIT(7) +#define UTMI_TEST_MUX_SEL BIT(6) + +#define HS_PHY_CTRL_REG 0x10 +#define UTMI_OTG_VBUS_VALID BIT(20) +#define SW_SESSVLD_SEL BIT(28) + +#define USB_PHY_UTMI_CTRL0 0x3c + +#define USB_PHY_UTMI_CTRL5 0x50 +#define POR_EN BIT(1) + +#define USB_PHY_HS_PHY_CTRL_COMMON0 0x54 +#define COMMONONN BIT(7) +#define FSEL BIT(4) +#define RETENABLEN BIT(3) +#define FREQ_24MHZ (GENMASK(6, 6) | GENMASK(4, 4)) + +#define USB_PHY_HS_PHY_CTRL2 0x64 +#define USB2_SUSPEND_N_SEL BIT(3) +#define USB2_SUSPEND_N BIT(2) +#define USB2_UTMI_CLK_EN BIT(1) + +#define USB_PHY_CFG0 0x94 +#define UTMI_PHY_OVERRIDE_EN BIT(1) + +#define USB_PHY_REFCLK_CTRL 0xa0 +#define CLKCORE BIT(1) + +#define USB2PHY_PORT_POWERDOWN 0xa4 +#define POWER_UP BIT(0) +#define POWER_DOWN 0 + +#define USB_PHY_FSEL_SEL 0xb8 +#define FREQ_SEL BIT(0) + +#define USB2PHY_USB_PHY_M31_XCFGI_1 0xbc +#define USB2_0_TX_ENABLE BIT(2) + +#define USB2PHY_USB_PHY_M31_XCFGI_4 0xc8 +#define HSTX_SLEW_RATE_565PS GENMASK(1, 0) +#define PLL_CHARGING_PUMP_CURRENT_35UA GENMASK(4, 3) +#define ODT_VALUE_38_02_OHM GENMASK(7, 6) + +#define USB2PHY_USB_PHY_M31_XCFGI_5 0xcc +#define ODT_VALUE_45_02_OHM BIT(2) +#define HSTX_PRE_EMPHASIS_LEVEL_0_55MA BIT(0) + +#define USB2PHY_USB_PHY_M31_XCFGI_11 0xe4 +#define XCFG_COARSE_TUNE_NUM BIT(1) +#define XCFG_FINE_TUNE_NUM BIT(3) +
drivers/phy/qualcomm/phy-qcom-m31.c line 84
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +10
-0+struct m31_phy_regs { +u32 off; +u32 val; +u32 delay; +}; + +struct m31_priv_data { +bool ulpi_mode; +const struct m31_phy_regs *regs; +const int nregs;
Doesn't hurt to spell out that this is an unsigned int, and you don't need the const on the nregs.
drivers/phy/qualcomm/phy-qcom-m31.c line 88
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +4
-0+}; + +#define M31_REG (__o, __v, __d) \ + { .off = __o, .val = __v, .delay = __d }
This macro doesn't add any value.
Compare:
M31_REG(USB_PHY_CFG0, UTMI_PHY_OVERRIDE_EN, 0),
with:
{ USB_PHY_CFG0, UTMI_PHY_OVERRIDE_EN, 0 },drivers/phy/qualcomm/phy-qcom-m31.c line 95
Quoted 7 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +7
-0+ +struct m31_phy_regs m31_ipq5332_regs[] = { +M31_REG (USB_PHY_CFG0 ,UTMI_PHY_OVERRIDE_EN ,0 ), +M31_REG (USB_PHY_UTMI_CTRL5 ,POR_EN ,15 ), +M31_REG (USB_PHY_FSEL_SEL ,FREQ_SEL ,0 ), +M31_REG (USB_PHY_HS_PHY_CTRL_COMMON0 , +COMMONONN |FREQ_24MHZ |RETENABLEN ,0 ),
The guideline is to keep under 80 characters, but if it improves readability you may use up to 100. So this line can be unwrapped.
drivers/phy/qualcomm/phy-qcom-m31.c line 98
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +3
-0+M31_REG (USB_PHY_UTMI_CTRL5 ,POR_EN ,0 ), +M31_REG (USB_PHY_HS_PHY_CTRL2 , + USB2_SUSPEND_N_SEL | USB2_SUSPEND_N | USB2_UTMI_CLK_EN, 0),
This one as well.
drivers/phy/qualcomm/phy-qcom-m31.c line 106
Quoted 8 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +8
-0+M31_REG (USB2PHY_USB_PHY_M31_XCFGI_11 , +XCFG_COARSE_TUNE_NUM |XCFG_FINE_TUNE_NUM ,0 ), +M31_REG (USB2PHY_USB_PHY_M31_XCFGI_4 , +HSTX_SLEW_RATE_565PS |PLL_CHARGING_PUMP_CURRENT_35UA | +ODT_VALUE_38_02_OHM ,0 ), +M31_REG (USB2PHY_USB_PHY_M31_XCFGI_1 ,USB2_0_TX_ENABLE ,0 ), +M31_REG (USB2PHY_USB_PHY_M31_XCFGI_5 , + ODT_VALUE_45_02_OHM | HSTX_PRE_EMPHASIS_LEVEL_0_55MA, 4),
And this one, if you drop the M32_REG macro.
drivers/phy/qualcomm/phy-qcom-m31.c line 117
Quoted 11 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +11
-0+M31_REG (USB_PHY_UTMI_CTRL5 ,0x0 ,0 ), + M31_REG(USB_PHY_HS_PHY_CTRL2, USB2_SUSPEND_N | USB2_UTMI_CLK_EN, 0), +}; + +struct m31usb_phy { +struct phy *phy; +void __iomem *base; +const struct m31_phy_regs *regs; +int nregs; + +struct clk *cfg_ahb_clk;
If you only have one clock, you can name it "clk" without causing confusion.
drivers/phy/qualcomm/phy-qcom-m31.c line 118
Quoted 1 line
drivers/phy/qualcomm/phy-qcom-m31.c new file +1
-0+struct reset_control *phy_reset;
Same here, if there's only one reset, then "reset" is a sufficient name.
drivers/phy/qualcomm/phy-qcom-m31.c line 120
Quoted 2 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +2
-0+ +bool cable_connected;
Unused
drivers/phy/qualcomm/phy-qcom-m31.c line 121
Quoted 1 line
drivers/phy/qualcomm/phy-qcom-m31.c new file +1
-0+bool suspended;
Unused, are you missing/omitting some relevant code here?
drivers/phy/qualcomm/phy-qcom-m31.c line 125
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +4
-0+bool ulpi_mode; +}; + +static void m31usb_phy_enable_clock (struct m31usb_phy *qphy)
It wouldn't hurt to just move this code into m31usb_phy_init().
Quoted 25 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +25
-0+{ +const struct m31_phy_regs *regs = qphy->regs; +int i; + +for (i =0 ; i < qphy->nregs; i++) { +writel (regs[i].val, qphy->base + regs[i].off); +if (regs[i].delay) +udelay (regs[i].delay); + } +} + +static int m31usb_phy_init (struct phy *phy) +{ +int ret; +struct m31usb_phy *qphy =phy_get_drvdata (phy); + + ret =clk_prepare_enable (qphy->cfg_ahb_clk); +if (ret) { +dev_err (&phy->dev,"failed to enable cfg ahb clock, %d\n" , ret); +return ret; + } + +/* Perform phy reset */ +reset_control_assert (qphy->phy_reset); +udelay (5 );
drivers/phy/qualcomm/phy-qcom-m31.c line 160
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +10
-0+reset_control_deassert (qphy->phy_reset); + +/* configure for ULPI mode if requested */ +if (qphy->ulpi_mode) +writel (0x0 , qphy->base +USB2PHY_PORT_UTMI_CTRL2 ); + +/* Enable the PHY */ +writel (POWER_UP , qphy->base +USB2PHY_PORT_POWERDOWN ); + +/* Make sure above write completed */
That's not what wmb() does. It ensures that any writes prior to this line is completed before any writes after this.
But m31usb_phy_enable_clock() is using writel(), which does the same already.
If you really need the previous writes to have completed (get through the write buffer etc), then you need to readl() the same register back. But I see no reason for that.
drivers/phy/qualcomm/phy-qcom-m31.c line 161
Quoted 1 line
drivers/phy/qualcomm/phy-qcom-m31.c new file +1
-0+wmb ();
So I think this should go.
Quoted 5 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +5
-0+ +/* Turn on phy ref clock */ +m31usb_phy_enable_clock (qphy); + +return 0 ;
drivers/phy/qualcomm/phy-qcom-m31.c line 176
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +10
-0+} + +static int m31usb_phy_shutdown (struct phy *phy) +{ +struct m31usb_phy *qphy =phy_get_drvdata (phy); + +/* Disable the PHY */ +writel_relaxed (POWER_DOWN , qphy->base +USB2PHY_PORT_POWERDOWN ); +/* Make sure above write completed */ +wmb ();
Same as above.
Although here you would assume that clk_disable_unprepare() uses writel() and doesn't overtake your power-down write, but that sounds like reasonable assumptions to make.
Quoted 9 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +9
-0+ +clk_disable_unprepare (qphy->cfg_ahb_clk); + +return 0 ; +} + +static const struct phy_ops m31usb_phy_gen_ops = { + .power_on = m31usb_phy_init, + .power_off = m31usb_phy_shutdown,
drivers/phy/qualcomm/phy-qcom-m31.c line 195
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +10
-0+ .owner = THIS_MODULE, +}; + +static int m31usb_phy_probe (struct platform_device *pdev) +{ +const struct m31_priv_data *data; +struct device *dev = &pdev->dev; +struct m31usb_phy *qphy; +struct phy_provider *phy_provider; +int ret;
Please sort these in descending length order (reverse xmas tree).
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +4
-0+ + qphy =devm_kzalloc (dev,sizeof (*qphy),GFP_KERNEL ); +if (!qphy) +return -ENOMEM ;
drivers/phy/qualcomm/phy-qcom-m31.c line 209
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +10
-0+ + qphy->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (qphy->base)) +return PTR_ERR (qphy->base); + + qphy->phy_reset =devm_reset_control_get_exclusive_by_index (dev,0 ); +if (IS_ERR (qphy->phy_reset)) +return PTR_ERR (qphy->phy_reset); + + qphy->cfg_ahb_clk =devm_clk_get (dev,"cfg_ahb" );
If you only have one clock, then omitting clock-names and do devm_clk_get(dev, NULL) works well.
drivers/phy/qualcomm/phy-qcom-m31.c line 213
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +4
-0+if (IS_ERR (qphy->cfg_ahb_clk)) { + ret =PTR_ERR (qphy->cfg_ahb_clk); +dev_err (dev,"failed to get cfg_ahb clock, %d\n" , ret); +return ret;
Replace these tree lines with:
return dev_err_probe(dev, PTR_ERR(qphy->cfg_ahb_clk), "failed to get cfg_ahb_clk\n");
drivers/phy/qualcomm/phy-qcom-m31.c line 216
Quoted 3 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +3
-0+ } + +platform_set_drvdata (pdev, qphy);
There are no platform_get_drvdata() calls in this driver, so you can omit this.
drivers/phy/qualcomm/phy-qcom-m31.c line 227
Quoted 11 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +11
-0+ + data =of_device_get_match_data (dev); + qphy->regs = data->regs; + qphy->nregs = data->nregs; + qphy->ulpi_mode = data->ulpi_mode; + + qphy->phy =devm_phy_create (dev,NULL , &m31usb_phy_gen_ops); +if (IS_ERR (qphy->phy)) { + ret =PTR_ERR (qphy->phy); +dev_err (dev,"failed to create phy, %d\n" , ret); + qphy->phy =NULL ;
qphy is inaccessible, and freed after the next line, no need to clear this.
drivers/phy/qualcomm/phy-qcom-m31.c line 231
Quoted 4 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +4
-0+return ret; + } + +dev_set_drvdata (dev, qphy);
This is exactly he same as platform_set_drvdata() above, so per the same logic you can drop this as well.
Quoted 13 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +13
-0+phy_set_drvdata (qphy->phy, qphy); + + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (!IS_ERR (phy_provider)) +dev_info (dev,"Registered M31 USB phy\n" ); + +return PTR_ERR_OR_ZERO (phy_provider); +} + +static const struct m31_priv_data m31_ipq5332_data = { + .ulpi_mode = false, + .regs = m31_ipq5332_regs, + .nregs =ARRAY_SIZE (m31_ipq5332_regs),
drivers/phy/qualcomm/phy-qcom-m31.c line 254
Quoted 10 lines
drivers/phy/qualcomm/phy-qcom-m31.c new file +10
-0+}; + +static const struct of_device_id m31usb_phy_id_table[] = { + { .compatible ="qcom,ipq5332-usb-hsphy" , .data = &m31_ipq5332_data }, + { }, +}; +MODULE_DEVICE_TABLE (of, m31usb_phy_id_table); + +static struct platform_driver m31usb_phy_driver = { + .probe = m31usb_phy_probe,
Please drop the indentation in these.
Regards,
Bjorn
PATCH v5 4/6 arm64: dts: qcom: ipq5332: Add USB related nodes
In reply to Varadarajan NarayananAdd USB phy and controller nodes.
---
v5:
Use generic phy instead of usb-phy
'make CHECK_DTBS=y DT_SCHEMA_FILES=qcom dtbs_check' passed 'DT_CHECKER_FLAGS='-v -m' DT_SCHEMA_FILES=qcom dt_binding_check' passed
v4:
Change node name
Remove blank line
'make CHECK_DTBS=y DT_SCHEMA_FILES=qcom qcom/ipq5332-rdp441.dtb' passed
v1:
Rename phy node
Change compatible from m31,ipq5332-usb-hsphy -> qcom,ipq5332-usb-hsphy Remove 'qscratch' from phy node
Fix alignment and upper-case hex no.s
Add clock definition for the phy
Remove snps,ref-clock-period-ns as it is not used. dwc3_ref_clk_period() in dwc3/core.c takes the frequency from ref clock and calculates fladj as appropriate.
--- arch/arm64/boot/dts/qcom/ipq5332.dtsi | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
arch/arm64/boot/dts/qcom/ipq5332.dtsi +56 -0
@@ -405,6 +405,62 @@ status = "disabled"; }; }; + + usbphy0: usb-phy@7b000 { + compatible = "qcom,ipq5332-usb-hsphy"; + reg = <0x0007b000 0x12c>; + + clocks = <&gcc GCC_USB0_PHY_CFG_AHB_CLK>; + clock-names = "cfg_ahb"; + + resets = <&gcc GCC_QUSB2_0_PHY_BCR>; + + #phy-cells = <0>; + + status = "disabled"; + }; + + usb2: usb2@8a00000 { + compatible = "qcom,ipq5332-dwc3", "qcom,dwc3"; + reg = <0x08af8800 0x400>; + + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "hs_phy_irq"; + + clocks = <&gcc GCC_USB0_MASTER_CLK>, + <&gcc GCC_SNOC_USB_CLK>, + <&gcc GCC_USB0_SLEEP_CLK>, + <&gcc GCC_USB0_MOCK_UTMI_CLK>; + clock-names = "core", + "iface", + "sleep", + "mock_utmi"; + + resets = <&gcc GCC_USB_BCR>; + + qcom,select-utmi-as-pipe-clk; + + #address-cells = <1>; + #size-cells = <1>; + ranges; + + status = "disabled"; + + usb2_0_dwc: usb@8a00000 { + compatible = "snps,dwc3"; + reg = <0x08a00000 0xe000>; + clocks = <&gcc GCC_USB0_MOCK_UTMI_CLK>; + clock-names = "ref"; + interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>; + phy-names = "usb2-phy"; + phys = <&usbphy0>; + tx-fifo-resize; + snps,is-utmi-l1-suspend; + snps,hird-threshold = /bits/ 8 <0x0>; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + }; + }; }; timer {
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Bjorn Andersson
maintainerRe: [PATCH v5 4/6] arm64: dts: qcom: ipq5332: Add USB related nodes
arch/arm64/boot/dts/qcom/ipq5332.dtsi line 409
Quoted 10 lines · Varadarajan Narayanan
arch/arm64/boot/dts/qcom/ipq5332.dtsi +2
-0@@ -405,6 +405,62 @@ status = "disabled"; }; }; + + usbphy0: usb-phy@7b000 {
s/usb-phy/phy/
arch/arm64/boot/dts/qcom/ipq5332.dtsi line 411
Quoted 2 lines
arch/arm64/boot/dts/qcom/ipq5332.dtsi +2
-0+ compatible = "qcom,ipq5332-usb-hsphy"; + reg = <0x0007b000 0x12c>;
Sort your nodes under /soc by their address.
arch/arm64/boot/dts/qcom/ipq5332.dtsi line 423
Quoted 12 lines
arch/arm64/boot/dts/qcom/ipq5332.dtsi +12
-0+ + clocks = <&gcc GCC_USB0_PHY_CFG_AHB_CLK>; + clock-names = "cfg_ahb"; + + resets = <&gcc GCC_QUSB2_0_PHY_BCR>; + + #phy-cells = <0>; + + status = "disabled"; + }; + + usb2: usb2@8a00000 {
usb@... drop the '2' in the node name (not in the label). Although, why does usb2 use the phy labeled usb0?
Regards,
Bjorn
PATCH v5 5/6 arm64: dts: qcom: ipq5332: Enable USB
In reply to Varadarajan NarayananEnable USB2 in host mode.
---
v1:
Enable usb-phy node
--- arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts +12 -0
@@ -79,3 +79,15 @@ bias-pull-up; }; }; + +&usbphy0 { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; + +&usb2_0_dwc { + dr_mode = "host"; +};
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Bjorn Andersson
maintainerRe: [PATCH v5 5/6] arm64: dts: qcom: ipq5332: Enable USB
Quoted 15 lines · Varadarajan Narayanan
Enable USB2 in host mode.
Signed-off-by Varadarajan Narayanan <[email protected]>---
v1:
Enable usb-phy node--- arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts | 12 ++++++++++++ 1 file changed, 12 insertions(+)arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts +0
-0
arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts line 84
Quoted 6 lines
arch/arm64/boot/dts/qcom/ipq5332-rdp468.dts +3
-0@@ -79,3 +79,15 @@ bias-pull-up; }; }; + +&usbphy0 { + status = "okay";
Is this phy not powered? Should there be some regulators controlled?
Regards,
Bjorn
PATCH v5 6/6 arm64: defconfig: Enable M31 USB phy driver
In reply to Varadarajan NarayananEnable M31 USB phy driver present in IPQ5332.
---
v2:
Add full stop to commit log.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -1389,6 +1389,7 @@ CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2=m CONFIG_PHY_QCOM_USB_HS_28NM=m CONFIG_PHY_QCOM_USB_SS=m CONFIG_PHY_QCOM_SGMII_ETH=m +CONFIG_PHY_QCOM_M31_USB=m CONFIG_PHY_R8A779F0_ETHERNET_SERDES=y CONFIG_PHY_RCAR_GEN3_PCIE=y CONFIG_PHY_RCAR_GEN3_USB2=y
Signature · 7 lines
2.7.4 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy