phy: USB and PCIe phy drivers for Qcom chipsets
v3 cover phy: USB and PCIe phy drivers for Qcom chipsets
This patch series adds couple of PHY drivers for Qualcomm chipsets.
a) qcom-qusb2 phy driver: that provides High Speed USB functionality.
b) qcom-qmp phy driver: that is a combo phy providing support for USB3, PCIe, UFS and few other controllers.
The patches are based on next branch of linux-phy tree.
These have been tested on Dragon board db820c hardware with required set of patches on integration tree maintained by Linaro landing team for Qualcomm [1].
Couple of other patches [2,3] for nvmem are also pulled in for testing.
Changes since v2:
- Addressed review comments given by Rob and Stephen for bindings.
- Addressed the review comments given by Stephen for the qusb2 and qmp phy drivers.
Please see individual patches for detailed changelogs.
Changes since v1:
- Moved device tree binding documentation to separate patches, as suggested by Rob.
- Addressed review comment regarding qfprom accesses by qusb2 phy driver, given by Rob.
- Addressed review comments from Kishon.
- Addressed review comments from Srinivas for QMP phy driver.
- Addressed kbuild warning.
[1] https://git.linaro.org/landing-teams/working/qualcomm/kernel.git/log/?h=integration-linux-qcomlt
[2] https://lkml.org/lkml/2016/11/17/21
[3] https://lkml.org/lkml/2016/12/19/18
Vivek Gautam (4):
dt-bindings: phy: Add support for QUSB2 phy
phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips
dt-bindings: phy: Add support for QMP phy
phy: qcom-qmp: new qmp phy driver for qcom-chipsets
.../devicetree/bindings/phy/qcom-qmp-phy.txt | 71 ++ .../devicetree/bindings/phy/qcom-qusb2-phy.txt | 53 + drivers/phy/Kconfig | 18 + drivers/phy/Makefile | 2 + drivers/phy/phy-qcom-qmp.c | 1191 ++++++++++++++++++++ drivers/phy/phy-qcom-qusb2.c | 540 +++++++++ 6 files changed, 1875 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt create mode 100644 Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt create mode 100644 drivers/phy/phy-qcom-qmp.c create mode 100644 drivers/phy/phy-qcom-qusb2.c
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/4 dt-bindings: phy: Add support for QUSB2 phy
Qualcomm chipsets have QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller. Adding dt binding information for the same.
---
Changes since v2:
- Removed binding for "ref_clk_src" since we don't request this clock in the driver.
- Addressed s/vdda-phy-dpdm/vdda-phy-dpdm-supply.
- Addressed s/ref_clk/ref. Don't need to add '_clk' suffix to clock names.
- Addressed s/tune2_hstx_trim_efuse/tune2_hstx_trim. Don't need to add 'efuse' suffix to nvmem cell.
- Addressed s/qusb2phy/phy for the node name.
Changes since v1:
- New patch, forked out of the original driver patch:
"phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips"
- Updated dt bindings to remove 'hstx-trim-bit-offset' and 'hstx-trim-bit-len' bindings.
.../devicetree/bindings/phy/qcom-qusb2-phy.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +53 -0
@@ -0,0 +1,53 @@ +Qualcomm QUSB2 phy controller +============================= + +QUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. + +Required properties: + - compatible: compatible list, contains "qcom,msm8996-qusb2-phy". + - reg: offset and length of the PHY register set. + - #phy-cells: must be 0. + + - clocks: a list of phandles and clock-specifier pairs, + one for each entry in clock-names. + - clock-names: must be "cfg_ahb" for phy config clock, + "ref" for 19.2 MHz ref clk, + "iface" for phy interface clock (Optional). + + - vdd-phy-supply: Phandle to a regulator supply to PHY core block. + - vdda-pll-supply: Phandle to 1.8V regulator supply to PHY refclk pll block. + - vdda-phy-dpdm-supply: Phandle to 3.1V regulator supply to Dp/Dm port signals. + + - resets: a list of phandles and reset controller specifier pairs, + one for each entry in reset-names. + - reset-names: must be "phy" for reset of phy block. + +Optional properties: + - nvmem-cells: a list of phandles to nvmem cells that contain fused + tuning parameters for qusb2 phy, one for each entry + in nvmem-cell-names. + - nvmem-cell-names: must be "tune2_hstx_trim" for cell containing + HS Tx trim value. + + - qcom,tcsr-syscon: Phandle to TCSR syscon register region. + +Example: + hsusb_phy: phy@7411000 { + compatible = "qcom,msm8996-qusb2-phy"; + reg = <0x07411000 0x180>; + #phy-cells = <0>; + + clocks = <&gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>, + <&gcc GCC_RX1_USB2_CLKREF_CLK>, + clock-names = "cfg_ahb", "ref"; + + vdd-phy-supply = <&pm8994_s2>; + vdda-pll-supply = <&pm8994_l12>; + vdda-phy-dpdm-supply = <&pm8994_l24>; + + resets = <&gcc GCC_QUSB2PHY_PRIM_BCR>; + reset-names = "phy"; + + nvmem-cells = <&qusb2p_hstx_trim>; + nvmem-cell-names = "tune2_hstx_trim"; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 2/4 phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips
In reply to Vivek GautamPHY transceiver driver for QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller present on Qualcomm chipsets.
---
Changes since v2:
- Removed selecting 'RESET_CONTROLLER' config.
- Added error handling for clk_prepare_enable paths.
- Removed explicitly setting ref_clk rate to 19.2 MHz. Don't need to do that since 'xo' is modeled as parent to this clock.
- Removed 'ref_clk_src' handling. Driver doesn't need to request and handle this clock.
- Moved nvmem_cell_get() to probe function.
- Simplified phy pll status handling.
- Using of_device_get_match_data() to get match data.
- Uniformly using lowercase for hex numbers.
- Fixed sparse warnings.
- Using shorter variable names in structure and in functions.
- Handling various comment style shortcomings.
Changes since v1:
- removed reference to clk_enabled/pwr_enabled.
- moved clock and regulator enable code to phy_power_on/off() callbacks.
- fixed return on EPROBE_DEFER in qusb2_phy_probe().
- fixed phy create and phy register ordering.
- removed references to non-lkml links from commit message.
- took care of other minor nits.
- Fixed coccinelle warnings -
'PTR_ERR applied after initialization to constant'
- Addressed review comment, regarding qfprom access for tune2 param value. This driver is now based on qfprom patch[1] that allows byte access now.
drivers/phy/Kconfig | 10 + drivers/phy/Makefile | 1 + drivers/phy/phy-qcom-qusb2.c | 540 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 551 insertions(+) create mode 100644 drivers/phy/phy-qcom-qusb2.c
drivers/phy/Kconfig +10 -0
@@ -430,6 +430,16 @@ config PHY_STIH407_USB Enable this support to enable the picoPHY device used by USB2 and USB3 controllers on STMicroelectronics STiH407 SoC families. +config PHY_QCOM_QUSB2 + tristate "Qualcomm QUSB2 PHY Driver" + depends on OF && (ARCH_QCOM || COMPILE_TEST) + select GENERIC_PHY + help + Enable this to support the HighSpeed QUSB2 PHY transceiver for USB + controllers on Qualcomm chips. This driver supports the high-speed + PHY which is usually paired with either the ChipIdea or Synopsys DWC3 + USB IPs on MSM SOCs. + config PHY_QCOM_UFS tristate "Qualcomm UFS PHY driver" depends on OF && ARCH_QCOM
drivers/phy/Makefile +1 -0
@@ -49,6 +49,7 @@ obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-usb.o +obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o
drivers/phy/phy-qcom-qusb2.c new file +540 -0
540 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 3/4 dt-bindings: phy: Add support for QMP phy
In reply to Vivek GautamQualcomm chipsets have QMP phy controller that provides support to a number of controller, viz. PCIe, UFS, and USB. Adding dt binding information for the same.
---
Changes since v2:
- Removed binding for "ref_clk_src" since we don't request this clock in the driver.
- Addressed s/ref_clk/ref. Don't need to add '_clk' suffix to clock names.
- Using 'phy' for the node name.
Changes since v1:
- New patch, forked out of the original driver patch:
"phy: qcom-qmp: new qmp phy driver for qcom-chipsets"
- updated bindings to include mem resource as a list of offset - length pair for serdes block and for each lane.
- added a new binding for 'lane-offsets' that contains offsets to tx, rx and pcs blocks from each lane base address.
.../devicetree/bindings/phy/qcom-qmp-phy.txt | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt new file +71 -0
@@ -0,0 +1,71 @@ +Qualcomm QMP PHY controller +=========================== + +QMP phy controller supports physical layer functionality for a number of +controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. + +Required properties: + - compatible: compatible list, contains: + "qcom,msm8996-qmp-pcie-phy" for 14nm PCIe phy on msm8996, + "qcom,msm8996-qmp-usb3-phy" for 14nm USB3 phy on msm8996. + - reg: list of offset and length pair of the PHY register sets. + at index 0: offset and length of register set for PHY common + serdes block. + from index 1 - N: offset and length of register set for each lane, + for N number of phy lanes (ports). + - lane-offsets: array of offsets to tx, rx and pcs blocks for phy lanes. + - #phy-cells: must be 1 + - Cell after phy phandle should be the port (lane) number. + - clocks: a list of phandles and clock-specifier pairs, + one for each entry in clock-names. + - clock-names: must be "cfg_ahb" for phy config clock, + "aux" for phy aux clock, + "ref" for 19.2 MHz ref clk, + "pipe<port-number>" for pipe clock specific to + each port/lane (Optional). + - resets: a list of phandles and reset controller specifier pairs, + one for each entry in reset-names. + - reset-names: must be "phy" for reset of phy block, + "common" for phy common block reset, + "cfg" for phy's ahb cfg block reset (Optional). + "port<port-number>" for reset specific to + each port/lane (Optional). + - vdda-phy-supply: Phandle to a regulator supply to PHY core block. + - vdda-pll-supply: Phandle to 1.8V regulator supply to PHY refclk pll block. + +Optional properties: + - vddp-ref-clk-supply: Phandle to a regulator supply to any specific refclk + pll block. + +Example: + pcie_phy: phy@34000 { + compatible = "qcom,msm8996-qmp-pcie-phy"; + reg = <0x034000 0x48f>, + <0x035000 0x5bf>, + <0x036000 0x5bf>, + <0x037000 0x5bf>; + /* tx, rx, pcs */ + lane-offsets = <0x0 0x200 0x400>; + #phy-cells = <1>; + + clocks = <&gcc GCC_PCIE_PHY_AUX_CLK>, + <&gcc GCC_PCIE_PHY_CFG_AHB_CLK>, + <&gcc GCC_PCIE_CLKREF_CLK>, + <&gcc GCC_PCIE_0_PIPE_CLK>, + <&gcc GCC_PCIE_1_PIPE_CLK>, + <&gcc GCC_PCIE_2_PIPE_CLK>; + clock-names = "aux", "cfg_ahb", "ref", + "pipe0", "pipe1", "pipe2"; + + vdda-phy-supply = <&pm8994_l28>; + vdda-pll-supply = <&pm8994_l12>; + + resets = <&gcc GCC_PCIE_PHY_BCR>, + <&gcc GCC_PCIE_PHY_COM_BCR>, + <&gcc GCC_PCIE_PHY_COM_NOCSR_BCR>, + <&gcc GCC_PCIE_0_PHY_BCR>, + <&gcc GCC_PCIE_1_PHY_BCR>, + <&gcc GCC_PCIE_2_PHY_BCR>; + reset-names = "phy", "common", "cfg", + "lane0", "lane1", "lane2"; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v3 4/4 phy: qcom-qmp: new qmp phy driver for qcom-chipsets
In reply to Vivek GautamQualcomm SOCs have QMP phy controller that provides support to a number of controller, viz. PCIe, UFS, and USB. Add a new driver, based on generic phy framework, for this phy controller.
---
Changes since v2:
- Removed selecting 'RESET_CONTROLLER' config.
- Added error handling for clk_prepare_enable paths.
- Removed 'ref_clk_src' handling. Driver doesn't need to request and handle this clock.
- Using readl_poll_timeout() to simplify pcs ready status polling. Also fixed the polling condition for pcs block ready status:
'Common block ready status bit is set on phy init completion, while PCS block ready status bit (PHYSTATUS) is reset on phy init completion.'
- Moved out the per-lane phy creation from probe() to separate function.
- Registering pipe clock source as a fixed rate clock that comes out of the PLL block of QMP phy. These source clocks serve as parent to 'pipe_clks' that are requested by pcie or usb3 phys.
- Using of_device_get_match_data() to get match data.
- Fixed sparse warnings for 'static' and 'const'.
- Using shorter variable names in structure and in functions.
- Handling various comment style shortcomings.
Changes since v1:
- Fixed missing mutex_unlock() calls in error cases, reported by Julia Lawall.
- Selecting CONFIG_RESET_CONTROLLER when this driver is enabled.
- Added a boolean property to check if the phy has individual lane reset available.
- Took care or EPROBE_DEFER, dev_vdbg() and other minor nits.
- Removed references to non-lkml links from commit message.
- Moved to use separate iomem resources for each lanes. Tx, Rx and PCS offsets per lane can now come from dt bindings.
drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-qcom-qmp.c | 1191 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1200 insertions(+) create mode 100644 drivers/phy/phy-qcom-qmp.c
drivers/phy/Kconfig +8 -0
@@ -430,6 +430,14 @@ config PHY_STIH407_USB Enable this support to enable the picoPHY device used by USB2 and USB3 controllers on STMicroelectronics STiH407 SoC families. +config PHY_QCOM_QMP + tristate "Qualcomm QMP PHY Driver" + depends on OF && (ARCH_QCOM || COMPILE_TEST) + select GENERIC_PHY + help + Enable this to support the QMP PHY transceiver that is used + with controllers such as PCIe, UFS, and USB on Qualcomm chips. + config PHY_QCOM_QUSB2 tristate "Qualcomm QUSB2 PHY Driver" depends on OF && (ARCH_QCOM || COMPILE_TEST)
drivers/phy/Makefile +1 -0
@@ -50,6 +50,7 @@ obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o obj-$(CONFIG_PHY_STIH407_USB) += phy-stih407-usb.o obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o +obj-$(CONFIG_PHY_QCOM_QMP) += phy-qcom-qmp.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o
drivers/phy/phy-qcom-qmp.c new file +1191 -0
1,191 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 1/4] dt-bindings: phy: Add support for QUSB2 phy
In reply to Vivek GautamQuoted 45 lines · Vivek Gautam
Qualcomm chipsets have QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller. Adding dt binding information for the same.
Signed-off-by Vivek Gautam <[email protected]>---
Changes since v2:
- Removed binding for "ref_clk_src" since we don't request this clock in the driver.
- Addressed s/vdda-phy-dpdm/vdda-phy-dpdm-supply.
- Addressed s/ref_clk/ref. Don't need to add '_clk' suffix to clock names.
- Addressed s/tune2_hstx_trim_efuse/tune2_hstx_trim. Don't need to add 'efuse' suffix to nvmem cell.
- Addressed s/qusb2phy/phy for the node name.Changes since v1:
- New patch, forked out of the original driver patch:
"phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips"
- Updated dt bindings to remove 'hstx-trim-bit-offset' and 'hstx-trim-bit-len' bindings..../devicetree/bindings/phy/qcom-qusb2-phy.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txtDocumentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +13
-0@@ -0,0 +1,53 @@ +Qualcomm QUSB2 phy controller +============================= + +QUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. + +Required properties: + - compatible: compatible list, contains "qcom,msm8996-qusb2-phy". + - reg: offset and length of the PHY register set. + - #phy-cells: must be 0. + + - clocks: a list of phandles and clock-specifier pairs, + one for each entry in clock-names. + - clock-names: must be "cfg_ahb" for phy config clock,
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt line 23
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +10
-0+ "ref" for 19.2 MHz ref clk, + "iface" for phy interface clock (Optional). + + - vdd-phy-supply: Phandle to a regulator supply to PHY core block. + - vdda-pll-supply: Phandle to 1.8V regulator supply to PHY refclk pll block. + - vdda-phy-dpdm-supply: Phandle to 3.1V regulator supply to Dp/Dm port signals. + + - resets: a list of phandles and reset controller specifier pairs, + one for each entry in reset-names. + - reset-names: must be "phy" for reset of phy block.
-names is pointless when only one.
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt line 30
Quoted 7 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +7
-0+ +Optional properties: + - nvmem-cells: a list of phandles to nvmem cells that contain fused + tuning parameters for qusb2 phy, one for each entry + in nvmem-cell-names. + - nvmem-cell-names: must be "tune2_hstx_trim" for cell containing + HS Tx trim value.
ditto.
With those dropped,
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/4] dt-bindings: phy: Add support for QUSB2 phy
Hi Rob,
Quoted 50 lines · Rob Herring
Quoted 49 lines · Vivek Gautam
Qualcomm chipsets have QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller. Adding dt binding information for the same.
Signed-off-by Vivek Gautam <[email protected]>---
Changes since v2:
- Removed binding for "ref_clk_src" since we don't request this clock in the driver.
- Addressed s/vdda-phy-dpdm/vdda-phy-dpdm-supply.
- Addressed s/ref_clk/ref. Don't need to add '_clk' suffix to clock names.
- Addressed s/tune2_hstx_trim_efuse/tune2_hstx_trim. Don't need to add 'efuse' suffix to nvmem cell.
- Addressed s/qusb2phy/phy for the node name.Changes since v1:
- New patch, forked out of the original driver patch:
"phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips"
- Updated dt bindings to remove 'hstx-trim-bit-offset' and 'hstx-trim-bit-len' bindings..../devicetree/bindings/phy/qcom-qusb2-phy.txt | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txtDocumentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +17
-0@@ -0,0 +1,53 @@ +Qualcomm QUSB2 phy controller +============================= + +QUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. + +Required properties: + - compatible: compatible list, contains "qcom,msm8996-qusb2-phy". + - reg: offset and length of the PHY register set. + - #phy-cells: must be 0. + + - clocks: a list of phandles and clock-specifier pairs, + one for each entry in clock-names. + - clock-names: must be "cfg_ahb" for phy config clock, + "ref" for 19.2 MHz ref clk, + "iface" for phy interface clock (Optional). + + - vdd-phy-supply: Phandle to a regulator supply to PHY core block.
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt line 23
Quoted 6 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +6
-0+ - vdda-pll-supply: Phandle to 1.8V regulator supply to PHY refclk pll block. + - vdda-phy-dpdm-supply: Phandle to 3.1V regulator supply to Dp/Dm port signals. + + - resets: a list of phandles and reset controller specifier pairs, + one for each entry in reset-names. + - reset-names: must be "phy" for reset of phy block.-names is pointless when only one.
Sure, will drop the -names property, and get the reset control by index.
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt line 30
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +7
-0+ +Optional properties: + - nvmem-cells: a list of phandles to nvmem cells that contain fused + tuning parameters for qusb2 phy, one for each entry + in nvmem-cell-names. + - nvmem-cell-names: must be "tune2_hstx_trim" for cell containing + HS Tx trim value.ditto.
nvmem doesn't allow, at this point, to get the cells by index. Its APIs take 'const char' cell id and get the cell.
We should add this support to get the cell by index.
Will create a patch for that, and drop the '-names' property from bindings.
Quoted 4 lines
With those dropped,
Acked-by Rob Herring <[email protected]>
Thanks for the Ack.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 1/4] dt-bindings: phy: Add support for QUSB2 phy
Quoted 9 lines · Vivek Gautam
Quoted 9 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt line 30
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +7
-0+ +Optional properties: + - nvmem-cells: a list of phandles to nvmem cells that contain fused + tuning parameters for qusb2 phy, one for each entry + in nvmem-cell-names. + - nvmem-cell-names: must be "tune2_hstx_trim" for cell containing + HS Tx trim value.ditto.
Quoted 6 lines
nvmem doesn't allow, at this point, to get the cells by index. Its APIs take 'const char' cell id and get the cell.
We should add this support to get the cell by index.
Will create a patch for that, and drop the '-names' property from bindings.
If we introduce a cells based API just for this case of one phandle it may make sense to allow the cell id to be NULL and default to whatever cell is there without a names property. We do something similar with clks where a NULL connection id defaults to the first phandle in the list. Then we can avoid having a new set of DT specific APIs here. Of course, documentation should be updated to indicate that a NULL cell_id means use index 0 with DT.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 1/4] dt-bindings: phy: Add support for QUSB2 phy
Quoted 17 lines · Stephen Boyd
Quoted 9 lines · Vivek Gautam
Quoted 9 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt line 30
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom-qusb2-phy.txt new file +7
-0+ +Optional properties: + - nvmem-cells: a list of phandles to nvmem cells that contain fused + tuning parameters for qusb2 phy, one for each entry + in nvmem-cell-names. + - nvmem-cell-names: must be "tune2_hstx_trim" for cell containing + HS Tx trim value.ditto.
Quoted 6 lines
nvmem doesn't allow, at this point, to get the cells by index. Its APIs take 'const char' cell id and get the cell.
We should add this support to get the cell by index.
Will create a patch for that, and drop the '-names' property from bindings.
Quoted 7 lines
If we introduce a cells based API just for this case of one phandle it may make sense to allow the cell id to be NULL and default to whatever cell is there without a names property. We do something similar with clks where a NULL connection id defaults to the first phandle in the list. Then we can avoid having a new set of DT specific APIs here. Of course, documentation should be updated to indicate that a NULL
cell_idmeans use index 0 with DT.
Right. This makes sense. I didn't notice that we do something similar in clocks.
I will post a new change for this (which should be pretty small in comparison to earlier patchset that introduced new dt based APIs).
Quoted 9 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 2/4] phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips
In reply to Vivek GautamQuoted 5 lines · Vivek Gautam
PHY transceiver driver for QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller present on Qualcomm chipsets.
Signed-off-by Vivek Gautam <[email protected]>
One comment below, but otherwise
Quoted 6 lines
drivers/phy/phy-qcom-qusb2.c new file +6
-0+static void qusb2_phy_set_tune2_param (struct qusb2_phy *qphy) +{ +struct device *dev = &qphy->phy->dev; +u8 *val; + +/*
drivers/phy/phy-qcom-qusb2.c line 237
Quoted 10 lines
drivers/phy/phy-qcom-qusb2.c new file +10
-0+* Read efuse register having TUNE2 parameter's high nibble. +* If efuse register shows value as 0x0, or if we fail to find +* a valid efuse register settings, then use default value +* as 0xB for high nibble that we have already set while +* configuring phy. +*/ + val =nvmem_cell_read (qphy->cell,NULL ); +if (IS_ERR (val) || !val[0 ]) { +dev_dbg (dev,"failed to read a valid hs-tx trim value, %ld\n" , +PTR_ERR (val));
If val is 0 PTR_ERR(0) will be junk? I guess that's ok for debug print.
Quoted 6 lines
drivers/phy/phy-qcom-qusb2.c new file +6
-0+return ; + } + +/* Fused TUNE2 value is the higher nibble only */ +qusb2_setbits (qphy->base +QUSB2PHY_PORT_TUNE2 , val[0 ] <<0x4 ); +}
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/4] dt-bindings: phy: Add support for QMP phy
In reply to Vivek GautamQuoted 10 lines · Vivek Gautam
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt new file +10
-0+ +Example: + pcie_phy: phy@34000 { + compatible = "qcom,msm8996-qmp-pcie-phy"; + reg = <0x034000 0x48f>, + <0x035000 0x5bf>, + <0x036000 0x5bf>, + <0x037000 0x5bf>; + /* tx, rx, pcs */ + lane-offsets = <0x0 0x200 0x400>;
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt line 58
Quoted 10 lines
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt new file +10
-0+ #phy-cells = <1>; + + clocks = <&gcc GCC_PCIE_PHY_AUX_CLK>, + <&gcc GCC_PCIE_PHY_CFG_AHB_CLK>, + <&gcc GCC_PCIE_CLKREF_CLK>, + <&gcc GCC_PCIE_0_PIPE_CLK>, + <&gcc GCC_PCIE_1_PIPE_CLK>, + <&gcc GCC_PCIE_2_PIPE_CLK>; + clock-names = "aux", "cfg_ahb", "ref", + "pipe0", "pipe1", "pipe2";
Can we add a #clock-cells = <0> or <1> here given that this is a clk provider? We may want to express the clk circular dependency between this phy node and GCC via the clocks property at some point instead of doing it implicitly via strings in C code.
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
In reply to Vivek GautamQuoted 13 lines · Vivek Gautam
Qualcomm SOCs have QMP phy controller that provides support to a number of controller, viz. PCIe, UFS, and USB. Add a new driver, based on generic phy framework, for this phy controller.
Signed-off-by Vivek Gautam <[email protected]>Tested-by Srinivas Kandagatla <[email protected]>---
drivers/phy/phy-qcom-qmp.c new file +4
-0+ +static struct phy *qcom_qmp_phy_xlate (struct device *dev, +struct of_phandle_args *args) +{
drivers/phy/phy-qcom-qmp.c line 931
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c new file +10
-0+struct qcom_qmp_phy *qphy =dev_get_drvdata (dev); +int i; + +if (WARN_ON (args->args[0 ] >= qphy->cfg->nlanes)) +return ERR_PTR (-ENODEV ); + +for (i =0 ; i < qphy->cfg->nlanes; i++) +/* phys[i]->index */ +if (i == args->args[0 ]) +return qphy->phys[i]->phy;
What's the loop for? If args->arg[0] < qphy->cfg->nlanes then we should be able to directly index the qphy->phys array with that number and return it.
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c new file +4
-0+ +return ERR_PTR (-ENODEV ); +} +
[...]
Quoted 6 lines
drivers/phy/phy-qcom-qmp.c new file +6
-0+ +/* +* The <s>_pipe_clksrc generated by PHY goes to the GCC that gate +* controls it. The <s>_pipe_clk coming out of the GCC is requested +* by the PHY driver for its operations. +* We register the <s>_pipe_clksrc here. The gcc driver takes care
drivers/phy/phy-qcom-qmp.c line 1061
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c new file +10
-0+* of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. +* Below picture shows this relationship. +* +* +--------------+ +* | PHY block |<<---------------------------------------+ +* | | | +* | +-------+ | +-----+ | +* I/P---^-->| PLL |--^--->pipe_clksrc--->| GCC |--->pipe_clk---+ +* clk | +-------+ | +-----+ +* +--------------+
There are mixed tabs and spaces in this diagram causing confusion in my editor. Please make it only spaces so the picture comes out correctly.
drivers/phy/phy-qcom-qmp.c line 1066
Quoted 5 lines
+ *
+ */drivers/phy/phy-qcom-qmp.c new file +3
-0+static int phy_pipe_clk_register (struct qcom_qmp_phy *qphy,int id) +{ +char clk_name[MAX_PROP_NAME ];
I'm not sure MAX_PROP_NAME is the same as some max clk name but ok. We should be able to calculate that the maximum is length of usb3_phy_pipe_clk_src for now though?
Quoted 6 lines
drivers/phy/phy-qcom-qmp.c new file +6
-0+struct clk *clk; + +memset (&clk_name,0 ,sizeof (clk_name)); +switch (qphy->cfg->type) { +case PHY_TYPE_USB3 : +snprintf (clk_name,MAX_PROP_NAME ,"usb3_phy_pipe_clk_src" );
drivers/phy/phy-qcom-qmp.c line 1082
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c new file +10
-0+break ; +case PHY_TYPE_PCIE : +snprintf (clk_name,MAX_PROP_NAME ,"pcie_%d_pipe_clk_src" , id); +break ; +default : +return -EINVAL ; + } + +/* controllers using QMP phys use 125MHz pipe clock interface */ + clk =clk_register_fixed_rate (qphy->dev, clk_name,NULL ,0 ,125000000 );
I was hoping you would be able to calculate the actual output rate by reading hardware. This is ok too though. Just please use clk_hw_register_fixed_rate() instead. And you'll probably need some sort of devm() usage here to handle probe failure, so I would probably roll my own and allocate a fixed_rate clk structure and set the rate/name directly and then call devm_clk_hw_register().
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c new file +2
-0+ +return PTR_ERR_OR_ZERO (clk);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 3/4] dt-bindings: phy: Add support for QMP phy
In reply to Stephen BoydQuoted 18 lines · Stephen Boyd
Quoted 17 lines · Vivek Gautam
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt new file +17
-0+ +Example: + pcie_phy: phy@34000 { + compatible = "qcom,msm8996-qmp-pcie-phy"; + reg = <0x034000 0x48f>, + <0x035000 0x5bf>, + <0x036000 0x5bf>, + <0x037000 0x5bf>; + /* tx, rx, pcs */ + lane-offsets = <0x0 0x200 0x400>; + #phy-cells = <1>; + + clocks = <&gcc GCC_PCIE_PHY_AUX_CLK>, + <&gcc GCC_PCIE_PHY_CFG_AHB_CLK>, + <&gcc GCC_PCIE_CLKREF_CLK>, + <&gcc GCC_PCIE_0_PIPE_CLK>, + <&gcc GCC_PCIE_1_PIPE_CLK>,
Quoted 8 lines
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt line 58
Quoted 3 lines
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt new file +3
-0+ <&gcc GCC_PCIE_2_PIPE_CLK>; + clock-names = "aux", "cfg_ahb", "ref", + "pipe0", "pipe1", "pipe2";Can we add a #clock-cells = <0> or <1> here given that this is a clk provider? We may want to express the clk circular dependency between this phy node and GCC via the clocks property at some point instead of doing it implicitly via strings in C code.
Sure, will add #clock-cells = <1>.
Although phys like USB and PIPE currently have just the pipe_clk being controlled by gcc, the UFS phy has tx/rx symbol clocks that are controlled by gcc but are generated by phy the same way as pipe_clk.
So, i guess #clock-cells = <1 > makes sense.
Thanks
Vivek
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 2/4] phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips
In reply to Stephen BoydQuoted 22 lines · Stephen Boyd
Quoted 5 lines · Vivek Gautam
PHY transceiver driver for QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller present on Qualcomm chipsets.
Signed-off-by Vivek Gautam <[email protected]>One comment below, but otherwise
Reviewed-by Stephen Boyd <[email protected]>Quoted 11 lines
drivers/phy/phy-qcom-qusb2.c new file +11
-0+static void qusb2_phy_set_tune2_param (struct qusb2_phy *qphy) +{ +struct device *dev = &qphy->phy->dev; +u8 *val; + +/* +* Read efuse register having TUNE2 parameter's high nibble. +* If efuse register shows value as 0x0, or if we fail to find +* a valid efuse register settings, then use default value +* as 0xB for high nibble that we have already set while +* configuring phy.
Quoted 8 lines
drivers/phy/phy-qcom-qusb2.c line 237
Quoted 5 lines
drivers/phy/phy-qcom-qusb2.c new file +5
-0+*/ + val =nvmem_cell_read (qphy->cell,NULL ); +if (IS_ERR (val) || !val[0 ]) { +dev_dbg (dev,"failed to read a valid hs-tx trim value, %ld\n" , +PTR_ERR (val));If val is 0
PTR_ERR(0)will be junk? I guess that's ok for debug print.
May be -EINVAL is better for debug print. Even when val[0] is 0, val will still be a valid pointer, and so PTR_ERR(val) will essentially be the pointer casted to long.
Thanks
Vivek
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 2/4] phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips
Hi Stephen,
Quoted 11 lines · Vivek Gautam
Quoted 10 lines · Stephen Boyd
Quoted 5 lines · Vivek Gautam
PHY transceiver driver for QUSB2 phy controller that provides HighSpeed functionality for DWC3 controller present on Qualcomm chipsets.
Signed-off-by Vivek Gautam <[email protected]>One comment below, but otherwise
Reviewed-by Stephen Boyd <[email protected]>
Thanks for the review.
Best Regards
Vivek
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
In reply to Stephen BoydHi Stephen,
Quoted 20 lines · Stephen Boyd
Quoted 19 lines · Vivek Gautam
Qualcomm SOCs have QMP phy controller that provides support to a number of controller, viz. PCIe, UFS, and USB. Add a new driver, based on generic phy framework, for this phy controller.
Signed-off-by Vivek Gautam <[email protected]>Tested-by Srinivas Kandagatla <[email protected]>---
drivers/phy/phy-qcom-qmp.c new file +10
-0+ +static struct phy *qcom_qmp_phy_xlate (struct device *dev, +struct of_phandle_args *args) +{ +struct qcom_qmp_phy *qphy =dev_get_drvdata (dev); +int i; + +if (WARN_ON (args->args[0 ] >= qphy->cfg->nlanes)) +return ERR_PTR (-ENODEV ); +
Quoted 8 lines
drivers/phy/phy-qcom-qmp.c line 931
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c new file +4
-0+for (i =0 ; i < qphy->cfg->nlanes; i++) +/* phys[i]->index */ +if (i == args->args[0 ]) +return qphy->phys[i]->phy;What's the loop for? If args->arg[0] <
qphy->cfg->nlanesthen we should be able to directly index theqphy->physarray with that number and return it.
Right, will do that.
Quoted 18 lines
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c new file +4
-0+ +return ERR_PTR (-ENODEV ); +} +[...]
Quoted 12 lines
drivers/phy/phy-qcom-qmp.c new file +12
-0+ +/* +* The <s>_pipe_clksrc generated by PHY goes to the GCC that gate +* controls it. The <s>_pipe_clk coming out of the GCC is requested +* by the PHY driver for its operations. +* We register the <s>_pipe_clksrc here. The gcc driver takes care +* of assigning this <s>_pipe_clksrc as parent to <s>_pipe_clk. +* Below picture shows this relationship. +* +* +--------------+ +* | PHY block |<<---------------------------------------+ +* | | |
Quoted 8 lines
Quoted 4 lines
+ * | +-------+ | +-----+ |
+ * I/P---^-->| PLL |--^--->pipe_clksrc--->| GCC |--->pipe_clk---+ + * clk | +-------+ | +-----++ * +--------------+
There are mixed tabs and spaces in this diagram causing confusion in my editor. Please make it only spaces so the picture comes out correctly.
Sure, will do that.
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c line 1066
Quoted 6 lines
+ *
+ */drivers/phy/phy-qcom-qmp.c new file +3
-0+static int phy_pipe_clk_register (struct qcom_qmp_phy *qphy,int id) +{ +char clk_name[MAX_PROP_NAME ];I'm not sure
MAX_PROP_NAMEis the same as some max clk name but ok. We should be able to calculate that the maximum is length ofusb3_phy_pipe_clk_srcfor now though?
Yea, i thought of using the same macro, considering that it provides 32 characters :-)
Will rather use the length of usb3_phy_pipe_clk_src for now. May be
#define MAX_CLK_NAME 24
Quoted 12 lines
Quoted 12 lines
drivers/phy/phy-qcom-qmp.c new file +11
-0+struct clk *clk; + +memset (&clk_name,0 ,sizeof (clk_name)); +switch (qphy->cfg->type) { +case PHY_TYPE_USB3 : +snprintf (clk_name,MAX_PROP_NAME ,"usb3_phy_pipe_clk_src" ); +break ; +case PHY_TYPE_PCIE : +snprintf (clk_name,MAX_PROP_NAME ,"pcie_%d_pipe_clk_src" , id); +break ; +default :
Quoted 8 lines
drivers/phy/phy-qcom-qmp.c line 1082
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c new file +5
-0+return -EINVAL ; + } + +/* controllers using QMP phys use 125MHz pipe clock interface */ + clk =clk_register_fixed_rate (qphy->dev, clk_name,NULL ,0 ,125000000 );I was hoping you would be able to calculate the actual output rate by reading hardware. This is ok too though.
Yea, I too was looking to understand the phy registers needed to calculate and re-calibrate the pipe clock rate, but couldn't find much from the IP programming guide. So, I had to fall back to registering a fixed-rate clock, since we are sure that the pipe clock rate is fixed at 125 MHz for the controllers using pipe interface.
Once we find out the required information, we can as well register clk_ops for this clock.
Quoted 6 lines
Just please use
clk_hw_register_fixed_rate()instead. And you'll probably need some sort ofdevm()usage here to handle probe failure, so I would probably roll my own and allocate afixed_rateclk structure and set the rate/name directly and then calldevm_clk_hw_register().
Sure, will do that.
Quoted 6 lines
drivers/phy/phy-qcom-qmp.c line 1084
Quoted 3 lines
drivers/phy/phy-qcom-qmp.c new file +2
-0+ +return PTR_ERR_OR_ZERO (clk);--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Thanks
Vivek
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
Quoted 10 lines · Vivek Gautam
Quoted 9 lines
drivers/phy/phy-qcom-qmp.c line 1066
Quoted 5 lines
+ *
+ */drivers/phy/phy-qcom-qmp.c new file +3
-0+static int phy_pipe_clk_register (struct qcom_qmp_phy *qphy,int id) +{ +char clk_name[MAX_PROP_NAME ];I'm not sure
MAX_PROP_NAMEis the same as some max clk name but ok. We should be able to calculate that the maximum is length ofusb3_phy_pipe_clk_srcfor now though?
Quoted 5 lines
Yea, i thought of using the same macro, considering that it provides 32 characters :-)
Will rather use the length ofusb3_phy_pipe_clk_srcfor now. May be
#defineMAX_CLK_NAME24
Using a macro indicates that the size have some global meaning, but as far as I can see it doesn't. Just write 24 and you will have enough space for 100k pcie pipe clocks. And then use sizeof(clk_name) below.
Quoted 4 lines
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c line 1069
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c new file +3
-0+struct clk *clk; + +memset (&clk_name,0 ,sizeof (clk_name));
There's no point in clearing clk_name, as it will be overwritten and nul-terminated below.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c new file +5
-0+switch (qphy->cfg->type) { +case PHY_TYPE_USB3 : +snprintf (clk_name,MAX_PROP_NAME ,"usb3_phy_pipe_clk_src" ); +break ; +case PHY_TYPE_PCIE :
Quoted 8 lines
Quoted 8 lines
drivers/phy/phy-qcom-qmp.c line 1082
Quoted 8 lines
drivers/phy/phy-qcom-qmp.c new file +8
-0+snprintf (clk_name,MAX_PROP_NAME ,"pcie_%d_pipe_clk_src" , id); +break ; +default : +return -EINVAL ; + } + +/* controllers using QMP phys use 125MHz pipe clock interface */ + clk =clk_register_fixed_rate (qphy->dev, clk_name,NULL ,0 ,125000000 );
Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
Hi,
Quoted 18 lines · Bjorn Andersson
Quoted 10 lines · Vivek Gautam
Quoted 9 lines
drivers/phy/phy-qcom-qmp.c line 1066
Quoted 5 lines
+ *
+ */drivers/phy/phy-qcom-qmp.c new file +3
-0+static int phy_pipe_clk_register (struct qcom_qmp_phy *qphy,int id) +{ +char clk_name[MAX_PROP_NAME ];I'm not sure
MAX_PROP_NAMEis the same as some max clk name but ok. We should be able to calculate that the maximum is length ofusb3_phy_pipe_clk_srcfor now though?Quoted 5 lines
Yea, i thought of using the same macro, considering that it provides 32 characters :-)
Will rather use the length ofusb3_phy_pipe_clk_srcfor now. May be
#defineMAX_CLK_NAME24
Quoted 3 lines
Using a macro indicates that the size have some global meaning, but as far as I can see it doesn't. Just write 24 and you will have enough space for 100k pcie pipe clocks. And then use
sizeof(clk_name)below.
Sure, will do as suggested.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c line 1069
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c new file +3
-0+struct clk *clk; + +memset (&clk_name,0 ,sizeof (clk_name));There's no point in clearing
clk_name, as it will be overwritten and null-terminated below.
Right. Will remove this.
Quoted 15 lines
Quoted 14 lines
Quoted 14 lines
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c new file +3
-0+switch (qphy->cfg->type) { +case PHY_TYPE_USB3 : +snprintf (clk_name,MAX_PROP_NAME ,"usb3_phy_pipe_clk_src" );drivers/phy/phy-qcom-qmp.c line 1082
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c new file +10
-0+break ; +case PHY_TYPE_PCIE : +snprintf (clk_name,MAX_PROP_NAME ,"pcie_%d_pipe_clk_src" , id); +break ; +default : +return -EINVAL ; + } + +/* controllers using QMP phys use 125MHz pipe clock interface */ + clk =clk_register_fixed_rate (qphy->dev, clk_name,NULL ,0 ,125000000 );
Quoted 6 lines
Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Regards
Vivek
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
In reply to Vivek GautamQuoted 1 line · Vivek Gautam
drivers/phy/phy-qcom-qmp.c +0
-0
[..]
Quoted 1 line
+static int
qcom_qmp_phy_poweron(struct phy *phy)
[..]
drivers/phy/phy-qcom-qmp.c
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c +2
-0+ +err3:
Rather than naming your labels errX, it's idiomatic to give them descriptive names, e.g. "disable_ref_clk" here.
Quoted 9 lines
drivers/phy/phy-qcom-qmp.c +9
-0+clk_disable_unprepare (qphy->ref_clk); +err2: +regulator_disable (qphy->vddp_ref_clk); +err1: +regulator_disable (qphy->vdda_pll); +err: +regulator_disable (qphy->vdda_phy); +return ret; +}
[..]
drivers/phy/phy-qcom-qmp.c line 642
Quoted 11 lines
drivers/phy/phy-qcom-qmp.c +11
-0+static int qcom_qmp_phy_com_init (struct qcom_qmp_phy *qphy) +{ +const struct qmp_phy_cfg *cfg = qphy->cfg; +void __iomem *serdes = qphy->serdes; +int ret; + +mutex_lock (&qphy->phy_mutex); +if (qphy->init_count++) { +mutex_unlock (&qphy->phy_mutex); +return 0 ; + }
As far as I can see phy_init() and phy_exit() already keep reference count on the initialization and you only call this function from phy_ops->init, so you should be able to drop this.
[..]
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c +4
-0+ +/* PHY Initialization */ +static int qcom_qmp_phy_init (struct phy *phy) +{
[..]
drivers/phy/phy-qcom-qmp.c line 794
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c +2
-0+/* phy power down delay; given in PCIE phy programming guide only */ +if (qphy->cfg->type ==PHY_TYPE_PCIE )
Rather than basing this off "is this pcie" it's preferred if you have a bool power_down_delay; (or optionally carrying the timeout value) to control this.
drivers/phy/phy-qcom-qmp.c line 807
Quoted 13 lines
drivers/phy/phy-qcom-qmp.c +13
-0+usleep_range (POWER_DOWN_DELAY_US_MIN ,POWER_DOWN_DELAY_US_MAX ); + +/* start SerDes and Phy-Coding-Sublayer */ +qphy_setbits (pcs +QPHY_START_CTRL , cfg->start_ctrl); + +/* Pull PHY out of reset state */ +qphy_clrbits (pcs +QPHY_SW_RESET ,SW_RESET ); + + status = pcs + cfg->regs[QPHY_PCS_READY_STATUS ]; + mask = cfg->mask_pcs_ready; + + ret = !mask ?0 :readl_poll_timeout (status, val, !(val & mask),1 , +PHY_INIT_COMPLETE_TIMEOUT );
I presume it's not okay to read the status register even once for pcie? If it is you can skip the conditional as !(val & 0) will break the poll after the first read.
[..]
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c +2
-0+static int qcom_qmp_phy_exit (struct phy *phy) +{
[..]
drivers/phy/phy-qcom-qmp.c line 205
Quoted 3 lines
drivers/phy/phy-qcom-qmp.c +3
-0+} + +
Extra blank line
Quoted 1 line
+static int
qcom_qmp_phy_regulator_init(struct device *dev)
[..]
Quoted 3 lines
drivers/phy/phy-qcom-qmp.c +3
-0+static +struct qmp_phy_desc *qcom_qmp_phy_create (struct platform_device *pdev,int id) +{
[..]
drivers/phy/phy-qcom-qmp.c line 997
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c +4
-0+ phy_desc->pipe_clk =devm_clk_get (dev, prop_name); +if (IS_ERR (phy_desc->pipe_clk)) { +if (qphy->cfg->type ==PHY_TYPE_PCIE || + qphy->cfg->type ==PHY_TYPE_USB3 ) {
Is this check adding any value?
drivers/phy/phy-qcom-qmp.c line 1005
Quoted 8 lines
drivers/phy/phy-qcom-qmp.c +8
-0+ ret =PTR_ERR (phy_desc->pipe_clk); +if (ret != -EPROBE_DEFER ) +dev_err (dev, +"failed to get lane%d pipe_clk, %d\n" , + id, ret); +return ERR_PTR (ret); + } + phy_desc->pipe_clk =NULL ;
Regards,
Bjorn
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
Hi,
Quoted 10 lines · Bjorn Andersson
Quoted 1 line · Vivek Gautam
drivers/phy/phy-qcom-qmp.c +0
-0[..]
Quoted 1 line
+static int
qcom_qmp_phy_poweron(struct phy *phy)[..]
drivers/phy/phy-qcom-qmp.c
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c +2
-0+ +err3:Rather than naming your labels errX, it's idiomatic to give them descriptive names, e.g. "
disable_ref_clk" here.
Sure will change these labels and any such occurrence further in the code.
Quoted 11 lines
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c +9
-0+clk_disable_unprepare (qphy->ref_clk); +err2: +regulator_disable (qphy->vddp_ref_clk); +err1: +regulator_disable (qphy->vdda_pll); +err: +regulator_disable (qphy->vdda_phy); +return ret; +}[..]
Quoted 14 lines
drivers/phy/phy-qcom-qmp.c line 642
Quoted 11 lines
drivers/phy/phy-qcom-qmp.c +11
-0+static int qcom_qmp_phy_com_init (struct qcom_qmp_phy *qphy) +{ +const struct qmp_phy_cfg *cfg = qphy->cfg; +void __iomem *serdes = qphy->serdes; +int ret; + +mutex_lock (&qphy->phy_mutex); +if (qphy->init_count++) { +mutex_unlock (&qphy->phy_mutex); +return 0 ; + }As far as I can see
phy_init()andphy_exit()already keep reference count on the initialization and you only call this function fromphy_ops->init, so you should be able to drop this.
This is an intermediary function that does the common block initialization. PHYs like PCIe have a separate common block (apart from SerDes) for all phy channels. We shouldn't program this common block multiple times for each channel. That's why this init_count.
Quoted 7 lines
[..]
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c +4
-0+ +/* PHY Initialization */ +static int qcom_qmp_phy_init (struct phy *phy) +{[..]
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c line 794
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c +2
-0+/* phy power down delay; given in PCIE phy programming guide only */ +if (qphy->cfg->type ==PHY_TYPE_PCIE )Rather than basing this off "is this pcie" it's preferred if you have a bool
power_down_delay; (or optionally carrying the timeout value) to control this.
Sure, will modify this.
Quoted 17 lines
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c +3
-0+usleep_range (POWER_DOWN_DELAY_US_MIN ,POWER_DOWN_DELAY_US_MAX ); + +/* start SerDes and Phy-Coding-Sublayer */ drivers/phy/phy-qcom-qmp.c line 807
Quoted 10 lines
drivers/phy/phy-qcom-qmp.c +10
-0+qphy_setbits (pcs +QPHY_START_CTRL , cfg->start_ctrl); + +/* Pull PHY out of reset state */ +qphy_clrbits (pcs +QPHY_SW_RESET ,SW_RESET ); + + status = pcs + cfg->regs[QPHY_PCS_READY_STATUS ]; + mask = cfg->mask_pcs_ready; + + ret = !mask ?0 :readl_poll_timeout (status, val, !(val & mask),1 , +PHY_INIT_COMPLETE_TIMEOUT );I presume it's not okay to read the status register even once for pcie? If it is you can skip the conditional as !(val & 0) will break the poll after the first read.
Yea, it is okay to read the status register for pcie.
Will leave just readl_poll_timeout() that exits on !(val & mask). We anyways don't set mask_pcs_ready for pcie.
Quoted 8 lines
[..]
Quoted 2 lines
drivers/phy/phy-qcom-qmp.c +2
-0+static int qcom_qmp_phy_exit (struct phy *phy) +{[..]
drivers/phy/phy-qcom-qmp.c line 205
Quoted 3 lines
drivers/phy/phy-qcom-qmp.c +3
-0+} + +Extra blank line
Will remove it.
Quoted 7 lines
Quoted 2 lines
+static int
qcom_qmp_phy_regulator_init(struct device *dev)[..]
Quoted 3 lines
drivers/phy/phy-qcom-qmp.c +3
-0+static +struct qmp_phy_desc *qcom_qmp_phy_create (struct platform_device *pdev,int id) +{[..]
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c line 997
Quoted 4 lines
drivers/phy/phy-qcom-qmp.c +4
-0+ phy_desc->pipe_clk =devm_clk_get (dev, prop_name); +if (IS_ERR (phy_desc->pipe_clk)) { +if (qphy->cfg->type ==PHY_TYPE_PCIE || + qphy->cfg->type ==PHY_TYPE_USB3 ) {Is this check adding any value?
The USB3 and PCIe phys are PIPE based phys, and hence the pipe clock is mandatory for them. Other phys don't care about pipe clock.
Quoted 15 lines
drivers/phy/phy-qcom-qmp.c line 1005
Quoted 9 lines
drivers/phy/phy-qcom-qmp.c +8
-0+ ret =PTR_ERR (phy_desc->pipe_clk); +if (ret != -EPROBE_DEFER ) +dev_err (dev, +"failed to get lane%d pipe_clk, %d\n" , + id, ret); +return ERR_PTR (ret); + } + phy_desc->pipe_clk =NULL ;Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Regards
Vivek
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
Quoted 14 lines · Vivek Gautam
Quoted 6 lines
Quoted 6 lines
drivers/phy/phy-qcom-qmp.c new file +6
-0+static int qcom_qmp_phy_com_init (struct qcom_qmp_phy *qphy) +{ +const struct qmp_phy_cfg *cfg = qphy->cfg; +void __iomem *serdes = qphy->serdes; +int ret; +Quoted 8 lines
drivers/phy/phy-qcom-qmp.c line 642
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c new file +5
-0+mutex_lock (&qphy->phy_mutex); +if (qphy->init_count++) { +mutex_unlock (&qphy->phy_mutex); +return 0 ; + }As far as I can see
phy_init()andphy_exit()already keep reference count on the initialization and you only call this function fromphy_ops->init, so you should be able to drop this.
Quoted 5 lines
This is an intermediary function that does the common block initialization. PHYs like PCIe have a separate common block (apart from SerDes) for all phy channels. We shouldn't program this common block multiple times for each channel. That's why this
init_count.
You're right!
Unfortunately it took me several minutes to wrap my head around the phy vs multi-lane and I have a really hard time keeping "qcom_qmp_phy" and "qmp_phy_desc" apart throughout the driver.
If I understand correctly the qcom_qmp_phy is the context representing a "QMP block", while this is a PHY block it's not actually the phy in Linux eyes. The qcom_phy_desc represents a "QMP lane", which in Linux eyes is the phys, but as we think of QMP as the PHY this confused me.
How about naming them "struct qmp" and "struct qmp_lane" (or possibly qmp_phy) instead? That way we remove the confusion of QMP PHY vs Linux PHY and we make the lane part explicit.
Regards,
Bjorn
Re: [PATCH v3 4/4] phy: qcom-qmp: new qmp phy driver for qcom-chipsets
Quoted 24 lines · Bjorn Andersson
Quoted 14 lines · Vivek Gautam
Quoted 6 lines
Quoted 6 lines
drivers/phy/phy-qcom-qmp.c new file +6
-0+static int qcom_qmp_phy_com_init (struct qcom_qmp_phy *qphy) +{ +const struct qmp_phy_cfg *cfg = qphy->cfg; +void __iomem *serdes = qphy->serdes; +int ret; +Quoted 8 lines
drivers/phy/phy-qcom-qmp.c line 642
Quoted 5 lines
drivers/phy/phy-qcom-qmp.c new file +5
-0+mutex_lock (&qphy->phy_mutex); +if (qphy->init_count++) { +mutex_unlock (&qphy->phy_mutex); +return 0 ; + }As far as I can see
phy_init()andphy_exit()already keep reference count on the initialization and you only call this function fromphy_ops->init, so you should be able to drop this.Quoted 5 lines
This is an intermediary function that does the common block initialization. PHYs like PCIe have a separate common block (apart from SerDes) for all phy channels. We shouldn't program this common block multiple times for each channel. That's why this
init_count.You're right!
Quoted 8 lines
Unfortunately it took me several minutes to wrap my head around the phy vs multi-lane and I have a really hard time keeping "
qcom_qmp_phy" and "qmp_phy_desc" apart throughout the driver.If I understand correctly the
qcom_qmp_phyis the context representing a "QMP block", while this is a PHY block it's not actually the phy in Linux eyes. Theqcom_phy_descrepresents a "QMP lane", which in Linux eyes is the phys, but as we think of QMP as the PHY this confused me.
That's correct. The qcom_qmp_phy structure represents the QMP phy block as a whole and not the individual phy lane instances. These phy lanes are represented by qcom_phy_desc, and are the actual PHYs in Linux eyes.
Quoted 4 lines
How about naming them "struct qmp" and "struct
qmp_lane" (or possiblyqmp_phy) instead? That way we remove the confusion of QMP PHY vs Linux PHY and we make the lane part explicit.
Sure, this sounds good to me - "struct qmp" and "struct qmp_phy" (will call the respective variables as qblk for qmp block (struct qmp) and qphy for struct qmp_phy).
Thanks for pointing out. Will change them.
Regards
Vivek
Quoted 8 lines
Regards,
Bjorn--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html