* [PATCH v2 1/3] dt-bindings: phy: Document Renesas Multi-Protocol PHY driver for R-Car X5H
@ 2026-11-29 17:37 Marek Vasut
2026-11-29 17:37 ` [PATCH v2 2/3] phy: renesas: Add " Marek Vasut
2026-11-29 17:37 ` [PATCH v2 3/3] phy: renesas: rcar-gen5-mpphy: Document how to obtain firmware Marek Vasut
0 siblings, 2 replies; 6+ messages in thread
From: Marek Vasut @ 2026-11-29 17:37 UTC (permalink / raw)
To: linux-phy
Cc: Marek Vasut, Arnd Bergmann, Biju Das, Conor Dooley,
Geert Uytterhoeven, Hai Pham, Krzysztof Kozlowski, Magnus Damm,
Manivannan Sadhasivam, Neil Armstrong, Phong Hoang, Rob Herring,
Tam Nguyen, Thanh Quan, Tommaso Merciai, Vinh Nguyen, Vinod Koul,
Yoshihiro Shimoda, devicetree, linux-kernel, linux-renesas-soc
Document Renesas Multi-Protocol PHY present in R-Car X5H (R8A78000) SoC.
This is a multiplexing PHY block with inputs from five IPs, and outputs
to four separate IO blocks. The five inputs are two PCIe4, two USB 3.2,
and ethernet PCS, each connected into the PHY with up to 4 times 2 lanes.
The inputs can be multiplexed to the four IO blocks as needed.
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Hai Pham <hai.pham.ud@renesas.com>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Phong Hoang <phong.hoang.wz@renesas.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Tam Nguyen <tam.nguyen.xa@renesas.com>
Cc: Thanh Quan <thanh.quan.xn@renesas.com>
Cc: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Cc: Vinh Nguyen <vinh.nguyen.xz@renesas.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-phy@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
---
V2: - Clarify clocks, power-domains, resets, which part of the PHY they control
- Drop no longer necessary renesas,num-lanes, the lane count for the PHY
purposes could be inferred from the PHY mode
- Increase #phy-cells to 2, to discern lanes in ethernet mode
---
.../bindings/phy/renesas,rcar-gen5-mpphy.yaml | 128 ++++++++++++++++++
1 file changed, 128 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/renesas,rcar-gen5-mpphy.yaml
diff --git a/Documentation/devicetree/bindings/phy/renesas,rcar-gen5-mpphy.yaml b/Documentation/devicetree/bindings/phy/renesas,rcar-gen5-mpphy.yaml
new file mode 100644
index 0000000000000..f0271eef3e2e8
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/renesas,rcar-gen5-mpphy.yaml
@@ -0,0 +1,128 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/renesas,rcar-gen5-mpphy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas R-Car Generation 5 Multi-Protocol PHY
+
+maintainers:
+ - Marek Vasut <marek.vasut+renesas@mailbox.org>
+ - Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+
+properties:
+ compatible:
+ items:
+ - const: renesas,r8a78000-mpphy # R-Car X5H MPPHY
+ - const: renesas,rcar-gen5-mpphy # R-Car Gen5 MPPHY
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ items:
+ - description: PHY0 module STOP clock gating
+ - description: PHY1 module STOP clock gating
+ - description: PHY2 module STOP clock gating
+ - description: PHY3 module STOP clock gating
+ - description: MPPHY common part module STOP clock gating
+
+ clock-names:
+ items:
+ - const: mpphy01
+ - const: mpphy11
+ - const: mpphy21
+ - const: mpphy31
+ - const: mpphy02
+
+ power-domains:
+ items:
+ - description: PD_MPP0 power domain
+ - description: PD_MPP1 power domain
+ - description: PD_MPP2 power domain
+ - description: PD_MPP3 power domain
+
+ power-domain-names:
+ items:
+ - const: mpp0
+ - const: mpp1
+ - const: mpp2
+ - const: mpp3
+
+ resets:
+ items:
+ - description: PHY0 phy0_phy_reset, and if Ethernet mode also XPCS 0-1 reset
+ - description: PHY1 phy1_phy_reset, and if Ethernet mode also XPCS 2-3 reset
+ - description: PHY2 phy2_phy_reset, and if Ethernet mode also XPCS 4-5 reset
+ - description: PHY3 phy3_phy_reset, and if Ethernet mode also XPCS 6-7 reset
+ - description: MPPHY common part module reset
+
+ reset-names:
+ items:
+ - const: mpphy01
+ - const: mpphy11
+ - const: mpphy21
+ - const: mpphy31
+ - const: mpphy02
+
+ '#phy-cells':
+ const: 2
+
+ renesas,phy-type:
+ description: PHY multiplexing configuration for each output.
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ minItems: 8
+ maxItems: 8
+
+ renesas,external-ref-clock:
+ description: PHY external reference clock select for each output.
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ minItems: 4
+ maxItems: 4
+
+ renesas,output-repeat-ref-clock:
+ description: PHY repeat reference clock select for each output.
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ minItems: 4
+ maxItems: 4
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - power-domains
+ - power-domain-names
+ - resets
+ - reset-names
+ - '#phy-cells'
+ - renesas,phy-type
+ - renesas,external-ref-clock
+ - renesas,output-repeat-ref-clock
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/phy/phy.h>
+
+ phy@c9a00000 {
+ compatible = "renesas,r8a78000-mpphy", "renesas,rcar-gen5-mpphy";
+ reg = <0xc9a00000 0x100000>;
+ #phy-cells = <2>;
+
+ clocks = <&scmi_clk 340>, <&scmi_clk 341>, <&scmi_clk 342>,
+ <&scmi_clk 343>, <&scmi_clk 344>;
+ clock-names = "mpphy01", "mpphy11", "mpphy21", "mpphy31", "mpphy02";
+ power-domains = <&scmi_devpd 17>, <&scmi_devpd 18>,
+ <&scmi_devpd 19>, <&scmi_devpd 20>;
+ power-domain-names = "mpp0", "mpp1", "mpp2", "mpp3";
+ resets = <&scmi_reset 340>, <&scmi_reset 341>, <&scmi_reset 342>,
+ <&scmi_reset 343>, <&scmi_reset 344>;
+ reset-names = "mpphy01", "mpphy11", "mpphy21", "mpphy31", "mpphy02";
+
+ renesas,phy-type = <PHY_TYPE_PCIE 0>, <PHY_TYPE_PCIE 0>,
+ <PHY_TYPE_XPCS 2>, <PHY_TYPE_USB3 1>;
+ renesas,external-ref-clock = <1 1 1 1>;
+ renesas,output-repeat-ref-clock = <0 0 0 0>;
+ };
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H
2026-11-29 17:37 [PATCH v2 1/3] dt-bindings: phy: Document Renesas Multi-Protocol PHY driver for R-Car X5H Marek Vasut
@ 2026-11-29 17:37 ` Marek Vasut
2026-11-30 1:05 ` kernel test robot
` (2 more replies)
2026-11-29 17:37 ` [PATCH v2 3/3] phy: renesas: rcar-gen5-mpphy: Document how to obtain firmware Marek Vasut
1 sibling, 3 replies; 6+ messages in thread
From: Marek Vasut @ 2026-11-29 17:37 UTC (permalink / raw)
To: linux-phy
Cc: Thanh Quan, Phong Hoang, Hai Pham, Yoshihiro Shimoda,
Marek Vasut, Arnd Bergmann, Biju Das, Conor Dooley,
Geert Uytterhoeven, Krzysztof Kozlowski, Magnus Damm,
Manivannan Sadhasivam, Neil Armstrong, Rob Herring, Tam Nguyen,
Tommaso Merciai, Vinh Nguyen, Vinod Koul, devicetree,
linux-kernel, linux-renesas-soc
From: Thanh Quan <thanh.quan.xn@renesas.com>
Add Renesas Multi-Protocol PHY driver for R-Car X5H (R8A78000) SoC.
This is a multiplexing PHY block with inputs from five IPs, and outputs
to four separate IO blocks. The five inputs are two PCIe4, two USB 3.2,
and ethernet PCS, each connected into the PHY with up to 4 times 2 lanes.
The inputs can be multiplexed to the four IO blocks as needed.
The datasheet describes initialization procedure without many information
about registers' name/bits. So, this driver does contain a bit of magic
to initialize the hardware.
Signed-off-by: Thanh Quan <thanh.quan.xn@renesas.com>
Co-developed-by: Phong Hoang <phong.hoang.wz@renesas.com>
Signed-off-by: Phong Hoang <phong.hoang.wz@renesas.com>
Co-developed-by: Hai Pham <hai.pham.ud@renesas.com>
Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
Co-developed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Co-developed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Hai Pham <hai.pham.ud@renesas.com>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Phong Hoang <phong.hoang.wz@renesas.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Tam Nguyen <tam.nguyen.xa@renesas.com>
Cc: Thanh Quan <thanh.quan.xn@renesas.com>
Cc: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Cc: Vinh Nguyen <vinh.nguyen.xz@renesas.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-phy@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
---
V2: - Drop bogus Check if initialized comment
- Realign Note: code comment
- Drop bulk clock num_clks count check
- Drop dev_info() log print on probe
- Clean up PCIe initialization
- Add table of valid configurations and PCIe link widths
- Drop no longer necessary renesas,num-lanes
- Clean up SRAM and firmware loading handling
- Configure TCA, thus far in static mode
- Rework clock and reset ordering and handling during suspend resume
- Always load firmware even for PCIe
---
drivers/phy/renesas/Kconfig | 7 +
drivers/phy/renesas/Makefile | 1 +
drivers/phy/renesas/phy-rcar-gen5-mpphy.c | 933 ++++++++++++++++++++++
3 files changed, 941 insertions(+)
create mode 100644 drivers/phy/renesas/phy-rcar-gen5-mpphy.c
diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig
index 90a9ca2db7fc7..ac903b29cacbc 100644
--- a/drivers/phy/renesas/Kconfig
+++ b/drivers/phy/renesas/Kconfig
@@ -43,6 +43,13 @@ config PHY_RCAR_GEN3_USB3
help
Support for USB 3.0 PHY found on Renesas R-Car generation 3 SoCs.
+config PHY_RCAR_GEN5_MPPHY
+ tristate "Renesas R-Car generation 5 Multi-Protocol PHY driver"
+ depends on ARCH_RENESAS || COMPILE_TEST
+ select GENERIC_PHY
+ help
+ Support for Multi-Protocol PHY found on Renesas R-Car generation 5 SoCs.
+
config PHY_RZ_G3E_USB3
tristate "Renesas RZ/G3E USB 3.0 PHY driver"
depends on ARCH_RENESAS || COMPILE_TEST
diff --git a/drivers/phy/renesas/Makefile b/drivers/phy/renesas/Makefile
index 0e98083f2f0c8..23d413cfa8ce0 100644
--- a/drivers/phy/renesas/Makefile
+++ b/drivers/phy/renesas/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o
obj-$(CONFIG_PHY_RCAR_GEN3_PCIE) += phy-rcar-gen3-pcie.o
obj-$(CONFIG_PHY_RCAR_GEN3_USB2) += phy-rcar-gen3-usb2.o
obj-$(CONFIG_PHY_RCAR_GEN3_USB3) += phy-rcar-gen3-usb3.o
+obj-$(CONFIG_PHY_RCAR_GEN5_MPPHY) += phy-rcar-gen5-mpphy.o
obj-$(CONFIG_PHY_RZ_G3E_USB3) += phy-rzg3e-usb3.o
diff --git a/drivers/phy/renesas/phy-rcar-gen5-mpphy.c b/drivers/phy/renesas/phy-rcar-gen5-mpphy.c
new file mode 100644
index 0000000000000..81071e5e753f3
--- /dev/null
+++ b/drivers/phy/renesas/phy-rcar-gen5-mpphy.c
@@ -0,0 +1,933 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Renesas Multi-Protocol PHY device driver
+ *
+ * Copyright (C) 2025-2026 Renesas Electronics Corporation
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/firmware.h>
+#include <linux/io.h>
+#include <linux/iopoll.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/pm_domain.h>
+#include <linux/regmap.h>
+#include <linux/reset.h>
+#include <linux/types.h>
+
+#include <dt-bindings/phy/phy.h>
+
+#define MPPHY_NUM_CHANNELS 4
+#define MPPHY_NUM_PCIE 2
+
+/* Common registers */
+#define MPPHY_CMNCNT1 0x80000
+#define MPPHY_CMNCNT2 0x80004
+
+/* Channel register base and offsets */
+#define MPPHY_CHAN_BASE(ch) (0x81000 + (ch) * 0x1000)
+#define MPPHY_PXCNTXT1(ch) (MPPHY_CHAN_BASE(ch) + 0x4)
+#define MPPHY_PXCNTXT2(ch) (MPPHY_CHAN_BASE(ch) + 0x8)
+#define MPPHY_PXTEST(ch) (MPPHY_CHAN_BASE(ch) + 0xc)
+#define MPPHY_PXREFCLK(ch) (MPPHY_CHAN_BASE(ch) + 0x14)
+#define MPPHY_PXRXREQ1(ch) (MPPHY_CHAN_BASE(ch) + 0x24)
+#define MPPHY_PXRXCNT(ch) (MPPHY_CHAN_BASE(ch) + 0x38)
+#define MPPHY_PXSRAMCNT(ch) (MPPHY_CHAN_BASE(ch) + 0x40)
+#define MPPHY_PXTXREQ(ch) (MPPHY_CHAN_BASE(ch) + 0x44)
+
+#define MPPHY_PCS0REG1 0x85000
+#define MPPHY_PCS0REG5 0x85010
+
+/* TCA (Type-C Adapter) Register Offsets within MP-PHY base */
+#define TCA_OFFSET(ch) (0x90000 + (((ch) & 1) ? 0x10000 : 0))
+#define TCA_INTR_EN 0x04
+#define TCA_INTR_STS 0x08
+#define TCA_TCPC 0x14
+#define TCA_TCPC_VALID BIT(4)
+#define TCA_TCPC_ORIENTATION_FLIPPED BIT(3)
+#define TCA_TCPC_MUX_CONTRL GENMASK(2, 0)
+#define TCA_TCPC_MUX_CONTRL_NO_CONN 0
+#define TCA_TCPC_MUX_CONTRL_USB_CONN 1
+#define TCA_PSTATE_1 0x54
+
+/* PCS0REG1 register bits */
+#define MPPHY_PCS0REG1_VAL BIT(16)
+
+/* PCS0REG5 register mask and values for each channel */
+#define MPPHY_PCS0REG5_CH(ch) GENMASK(25 + (2 * (ch)), 24 + (2 * (ch)))
+
+/* PXTEST register bit */
+#define MPPHY_PXTEST_BIT BIT(0)
+
+/* PXRXCNT register reset value */
+#define MPPHY_PXRXCNT_RESET_VAL 0x202
+
+/* PXSRAMCNT register bits */
+#define SRAM_EXT_LD_DONE BIT(4)
+#define SRAM_INIT_DONE BIT(5)
+
+/* PXREFCLK register value */
+#define MPPHY_PXREFCLK_VAL_ETH 0x55
+
+/* Firmware update */
+#define MPPHY_FW_BASE 0x10000
+#define MPPHY_FW_CH_OFFSET 0x20000
+#define MPPHY_FW_NAME "rcar_gen5_mp_phy.bin"
+
+struct mp_phy_chan_priv {
+ struct phy *phy;
+ enum phy_mode protocol_id;
+ bool initialized;
+};
+
+struct mp_phy_priv {
+ void __iomem *base;
+ struct device *dev;
+ struct dev_pm_domain_list *pd_list;
+ struct reset_control *reset_core;
+ struct reset_control_bulk_data reset_phy[MPPHY_NUM_CHANNELS];
+ struct clk *clk_core;
+ struct clk_bulk_data *clk_phy;
+ int num_clks;
+ const struct firmware *fw;
+ struct regmap *map;
+ struct mp_phy_chan_priv chan[MPPHY_NUM_CHANNELS];
+ u32 num_lanes[MPPHY_NUM_PCIE];
+ u32 write_cntxt1;
+ u32 pcs0reg5_mask;
+ u32 cmncnt[2];
+ u8 sramcnt[MPPHY_NUM_CHANNELS];
+};
+
+#define MPPHY_PX_RD_RANGE(n) \
+ regmap_reg_range(MPPHY_PXCNTXT1(n), MPPHY_PXCNTXT1(n)), \
+ regmap_reg_range(MPPHY_PXREFCLK(n), MPPHY_PXREFCLK(n)), \
+ regmap_reg_range(MPPHY_PXRXREQ1(n), MPPHY_PXRXREQ1(n)), \
+ regmap_reg_range(MPPHY_PXRXCNT(n), MPPHY_PXRXCNT(n)), \
+ regmap_reg_range(MPPHY_PXSRAMCNT(n), MPPHY_PXTXREQ(n))
+
+static const struct regmap_range mp_phy_readable_range[] = {
+ regmap_reg_range(MPPHY_CMNCNT1, MPPHY_CMNCNT2),
+ MPPHY_PX_RD_RANGE(0), MPPHY_PX_RD_RANGE(1),
+ MPPHY_PX_RD_RANGE(2), MPPHY_PX_RD_RANGE(3),
+ regmap_reg_range(MPPHY_PCS0REG1, MPPHY_PCS0REG1),
+ regmap_reg_range(MPPHY_PCS0REG5, MPPHY_PCS0REG5),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_INTR_EN, TCA_OFFSET(0) + TCA_INTR_STS),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_TCPC, TCA_OFFSET(0) + TCA_TCPC),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_PSTATE_1, TCA_OFFSET(0) + TCA_PSTATE_1),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_INTR_EN, TCA_OFFSET(1) + TCA_INTR_STS),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_TCPC, TCA_OFFSET(1) + TCA_TCPC),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_PSTATE_1, TCA_OFFSET(1) + TCA_PSTATE_1),
+};
+
+static const struct regmap_access_table mp_phy_readable_table = {
+ .yes_ranges = mp_phy_readable_range,
+ .n_yes_ranges = ARRAY_SIZE(mp_phy_readable_range),
+};
+
+#define MPPHY_PX_WR_RANGE(n) \
+ regmap_reg_range(MPPHY_PXCNTXT1(n), MPPHY_PXCNTXT1(n)), \
+ regmap_reg_range(MPPHY_PXREFCLK(n), MPPHY_PXREFCLK(n)), \
+ regmap_reg_range(MPPHY_PXRXCNT(n), MPPHY_PXRXCNT(n)), \
+ regmap_reg_range(MPPHY_PXSRAMCNT(n), MPPHY_PXTXREQ(n))
+
+static const struct regmap_range mp_phy_writeable_range[] = {
+ regmap_reg_range(MPPHY_FW_BASE, MPPHY_FW_BASE + 4 * MPPHY_FW_CH_OFFSET),
+ regmap_reg_range(MPPHY_CMNCNT1, MPPHY_CMNCNT2),
+ MPPHY_PX_WR_RANGE(0), MPPHY_PX_WR_RANGE(1),
+ MPPHY_PX_WR_RANGE(2), MPPHY_PX_WR_RANGE(3),
+ regmap_reg_range(MPPHY_PCS0REG1, MPPHY_PCS0REG1),
+ regmap_reg_range(MPPHY_PCS0REG5, MPPHY_PCS0REG5),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_INTR_EN, TCA_OFFSET(0) + TCA_INTR_EN),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_TCPC, TCA_OFFSET(0) + TCA_TCPC),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_PSTATE_1, TCA_OFFSET(0) + TCA_PSTATE_1),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_INTR_EN, TCA_OFFSET(1) + TCA_INTR_EN),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_TCPC, TCA_OFFSET(1) + TCA_TCPC),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_PSTATE_1, TCA_OFFSET(1) + TCA_PSTATE_1),
+};
+
+static const struct regmap_access_table mp_phy_writeable_table = {
+ .yes_ranges = mp_phy_writeable_range,
+ .n_yes_ranges = ARRAY_SIZE(mp_phy_writeable_range),
+};
+
+#define MPPHY_PX_VL_RANGE(n) \
+ regmap_reg_range(MPPHY_PXRXREQ1(n), MPPHY_PXRXREQ1(n)), \
+ regmap_reg_range(MPPHY_PXSRAMCNT(n), MPPHY_PXTXREQ(n))
+
+static const struct regmap_range mp_phy_volatile_range[] = {
+ MPPHY_PX_VL_RANGE(0), MPPHY_PX_VL_RANGE(1),
+ MPPHY_PX_VL_RANGE(2), MPPHY_PX_VL_RANGE(3),
+ regmap_reg_range(TCA_OFFSET(0) + TCA_INTR_STS, TCA_OFFSET(0) + TCA_INTR_STS),
+ regmap_reg_range(TCA_OFFSET(1) + TCA_PSTATE_1, TCA_OFFSET(1) + TCA_PSTATE_1),
+};
+
+static const struct regmap_access_table mp_phy_volatile_table = {
+ .yes_ranges = mp_phy_volatile_range,
+ .n_yes_ranges = ARRAY_SIZE(mp_phy_volatile_range),
+};
+
+static const struct regmap_config mp_phy_regmap_config = {
+ .fast_io = true,
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+ .max_register = TCA_OFFSET(1) + TCA_PSTATE_1,
+ .name = "mpphy",
+ .rd_table = &mp_phy_readable_table,
+ .wr_table = &mp_phy_writeable_table,
+ .volatile_table = &mp_phy_volatile_table,
+ .cache_type = REGCACHE_MAPLE,
+};
+
+static const struct {
+ u8 phy_type[2 * MPPHY_NUM_CHANNELS];
+ u8 num_lanes[MPPHY_NUM_PCIE];
+} mp_phy_valid_configs[] = {
+ /* PHY0,1,2,3: PCIe.0 x8 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0 }, { 8, 0 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2,3: PCIe.1 x4 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 1, PHY_TYPE_PCIE, 1 }, { 4, 4 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2: PCIe.1 x2 , PHY3: USB.1 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 1, PHY_TYPE_USB3, 1 }, { 4, 2 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2: PCIe.1 x2 , PHY3: ETH.3 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 1, PHY_TYPE_XPCS, 3 }, { 4, 2 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2: USB.0 , PHY3: USB.1 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_USB3, 0, PHY_TYPE_USB3, 1 }, { 4, 0 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2: USB.0 , PHY3: ETH.3 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_USB3, 0, PHY_TYPE_XPCS, 3 }, { 4, 0 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2: ETH.2 , PHY3: USB.1 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 2, PHY_TYPE_USB3, 1 }, { 4, 0 } },
+ /* PHY0,1: PCIe.0 x4 , PHY2: ETH.2 , PHY3: ETH.3 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 2, PHY_TYPE_XPCS, 3 }, { 4, 0 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2,3: PCIe.1 x4 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_PCIE, 1, PHY_TYPE_PCIE, 1 }, { 2, 4 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2 PCIe.1 x2 , PHY3: USB.1 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_PCIE, 1, PHY_TYPE_USB3, 1 }, { 2, 2 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2 PCIe.1 x2 , PHY3: ETH.3 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_PCIE, 1, PHY_TYPE_XPCS, 3 }, { 2, 2 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2 USB.0 , PHY3: USB.1 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_USB3, 0, PHY_TYPE_USB3, 1 }, { 2, 0 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2 USB.0 , PHY3: ETH.3 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_USB3, 0, PHY_TYPE_XPCS, 3 }, { 2, 0 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2 ETH.2 , PHY3: USB.1 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_XPCS, 2, PHY_TYPE_USB3, 1 }, { 2, 0 } },
+ /* PHY0: PCIe.0 x2 , PHY1: ETH.1 , PHY2 ETH.2 , PHY3: ETH.3 */
+ { { PHY_TYPE_PCIE, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_XPCS, 2, PHY_TYPE_XPCS, 3 }, { 2, 0 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2,3: PCIe.1 x4 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_PCIE, 1, PHY_TYPE_PCIE, 1 }, { 0, 4 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2 PCIe.1 x2 , PHY3: USB.1 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_PCIE, 1, PHY_TYPE_USB3, 1 }, { 0, 2 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2 PCIe.1 x2 , PHY3: ETH.3 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_PCIE, 1, PHY_TYPE_XPCS, 3 }, { 0, 2 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2 USB.0 , PHY3: USB.1 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_USB3, 0, PHY_TYPE_USB3, 1 }, { 0, 0 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2 USB.0 , PHY3: ETH.3 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_USB3, 0, PHY_TYPE_XPCS, 3 }, { 0, 0 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2 ETH.2 , PHY3: USB.1 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_XPCS, 2, PHY_TYPE_USB3, 1 }, { 0, 0 } },
+ /* PHY0: ETH.0 , PHY1: ETH.1 , PHY2 ETH.2 , PHY3: ETH.3 */
+ { { PHY_TYPE_XPCS, 0, PHY_TYPE_XPCS, 1, PHY_TYPE_XPCS, 2, PHY_TYPE_XPCS, 3 }, { 0, 0 } },
+};
+
+static int mp_phy_reg_wait(struct mp_phy_priv *priv, u32 offs, u32 mask, u32 expected)
+{
+ u32 val;
+ int ret;
+
+ ret = regmap_read_poll_timeout(priv->map, offs, val,
+ (val & mask) == expected,
+ 0, 1000000);
+ if (ret) {
+ dev_err(priv->dev,
+ "Timeout waiting for offset: 0x%x, mask: 0x%x, expected: 0x%x\n",
+ offs, mask, expected);
+ }
+
+ return ret;
+}
+
+static void mp_phy_update_firmware(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ int i;
+
+ for (i = 0; i < priv->fw->size; i += 2) {
+ writew(priv->fw->data[i] | (priv->fw->data[i + 1] << 8),
+ priv->base + MPPHY_FW_BASE + (MPPHY_FW_CH_OFFSET * phy->id) + i);
+ }
+}
+
+static int mp_phy_update_firmware_sram(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ int ret;
+
+ ret = mp_phy_reg_wait(priv, MPPHY_PXSRAMCNT(phy->id), SRAM_INIT_DONE, SRAM_INIT_DONE);
+ if (ret)
+ return ret;
+
+ mp_phy_update_firmware(phy);
+ regmap_set_bits(priv->map, MPPHY_PXSRAMCNT(phy->id), SRAM_EXT_LD_DONE);
+
+ return 0;
+}
+
+static int mp_phy_init_ethernet(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+
+ regmap_clear_bits(priv->map, MPPHY_PCS0REG5, MPPHY_PCS0REG5_CH(phy->id));
+
+ mp_phy_update_firmware(phy);
+
+ regmap_write(priv->map, MPPHY_PXRXCNT(phy->id), MPPHY_PXRXCNT_RESET_VAL);
+ regmap_set_bits(priv->map, MPPHY_PXREFCLK(phy->id), MPPHY_PXREFCLK_VAL_ETH);
+ regmap_clear_bits(priv->map, MPPHY_PXRXCNT(phy->id), BIT(9) | BIT(1));
+ regmap_set_bits(priv->map, MPPHY_PXTXREQ(phy->id), BIT(19) | BIT(3));
+
+ return 0;
+}
+
+static void mp_phy_init_pcie4_ch_req(struct mp_phy_priv *priv, const int chs, const int chd,
+ const u32 cntxt2, const u32 txreq)
+{
+ int ch;
+
+ for (ch = chs; ch <= chd; ch++) {
+ regmap_set_bits(priv->map, MPPHY_PXCNTXT1(ch), 0x2010002);
+ regmap_set_bits(priv->map, MPPHY_PXCNTXT2(ch), cntxt2);
+ regmap_set_bits(priv->map, MPPHY_PXTXREQ(ch), txreq);
+ }
+}
+
+static void mp_phy_init_pcie4_ch_clk(struct mp_phy_priv *priv, const int chs, const int chd)
+{
+ int ch;
+
+ for (ch = chs; ch <= chd; ch++) {
+ regmap_set_bits(priv->map, MPPHY_PXREFCLK(ch), 0x30);
+ regmap_set_bits(priv->map, MPPHY_PXREFCLK(ch), 0x4);
+ regmap_set_bits(priv->map, MPPHY_PXREFCLK(ch), 0x1);
+ }
+}
+
+static void mp_phy_init_pcie4_ch_rst(struct mp_phy_priv *priv, const int chs, const int chd)
+{
+ int ch;
+
+ for (ch = chs; ch <= chd; ch++)
+ regmap_set_bits(priv->map, MPPHY_PXRXCNT(ch), MPPHY_PXRXCNT_RESET_VAL);
+
+ for (ch = chs; ch <= chd; ch++)
+ regmap_clear_bits(priv->map, MPPHY_PXRXCNT(ch), MPPHY_PXRXCNT_RESET_VAL);
+}
+
+static int mp_phy_init_pcie4(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+
+ if (priv->num_lanes[phy->id] == 2) {
+ if (phy->id == 0) {
+ mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x80004);
+ mp_phy_init_pcie4_ch_clk(priv, 0, 0);
+ mp_phy_init_pcie4_ch_rst(priv, 0, 0);
+ } else if (phy->id == 1) {
+ mp_phy_init_pcie4_ch_req(priv, 2, 2, 0x2020202, 0x8);
+ mp_phy_init_pcie4_ch_clk(priv, 2, 2);
+ mp_phy_init_pcie4_ch_rst(priv, 2, 2);
+ }
+ } else if (priv->num_lanes[phy->id] == 4) {
+ if (phy->id == 0) {
+ mp_phy_init_pcie4_ch_req(priv, 0, 1, 0x2020201, 0x80008);
+ mp_phy_init_pcie4_ch_clk(priv, 0, 1);
+ /* No reset pulse here. */
+ } else if (phy->id == 1) {
+ mp_phy_init_pcie4_ch_req(priv, 2, 3, 0x2020202, 0x8);
+ mp_phy_init_pcie4_ch_clk(priv, 2, 3);
+ mp_phy_init_pcie4_ch_rst(priv, 2, 3);
+ }
+ } else if (priv->num_lanes[phy->id] == 8) {
+ mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x8);
+ mp_phy_init_pcie4_ch_req(priv, 1, 3, 0x2020202, 0x8);
+ /* No clk settings here. */
+ mp_phy_init_pcie4_ch_rst(priv, 0, 3);
+ }
+
+ return 0;
+}
+
+static int mp_phy_init_usb(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ int ret;
+
+ regmap_clear_bits(priv->map, MPPHY_PCS0REG5, MPPHY_PCS0REG5_CH(phy->id));
+
+ ret = mp_phy_update_firmware_sram(phy);
+ if (ret)
+ return ret;
+
+ ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(phy->id), 0x2, 0);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int mp_phy_init(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ struct mp_phy_chan_priv *chan = &priv->chan[phy->id];
+ int ret;
+
+ if (chan->initialized)
+ return 0;
+
+ /*
+ * Note: Current source code support for Ethernet, PCIe initialization
+ * is based on the bare metal code shared by the board team.
+ */
+ ret = pm_runtime_get_sync(priv->pd_list->pd_devs[phy->id]);
+ if (ret < 0) {
+ dev_err(priv->dev,
+ "Failed to power on domain for channel %d: %d\n",
+ phy->id, ret);
+ return ret;
+ }
+
+ if (chan->protocol_id == PHY_MODE_PCIE)
+ ret = mp_phy_init_pcie4(phy);
+ else if (chan->protocol_id == PHY_MODE_ETHERNET)
+ ret = mp_phy_init_ethernet(phy);
+ else
+ ret = mp_phy_init_usb(phy);
+ if (ret)
+ goto err_init;
+
+ chan->initialized = true;
+ dev_dbg(priv->dev,
+ "Channel %d successfully initialized for protocol %d\n",
+ phy->id, chan->protocol_id);
+
+ return 0;
+
+err_init:
+ pm_runtime_put_sync(priv->pd_list->pd_devs[phy->id]);
+ return ret;
+}
+
+static int mp_phy_exit(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ struct mp_phy_chan_priv *chan = &priv->chan[phy->id];
+
+ if (!chan->initialized)
+ return 0;
+
+ chan->initialized = false;
+
+ pm_runtime_put_sync(priv->pd_list->pd_devs[phy->id]);
+
+ return 0;
+}
+
+static int mp_phy_read_poll_pcie4(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ u32 rx_ack, tx_ack;
+
+ if (priv->num_lanes[phy->id] == 2) {
+ tx_ack = readl(priv->base + MPPHY_PXTXREQ(2 * phy->id));
+ rx_ack = readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id));
+ } else if (priv->num_lanes[phy->id] == 4) {
+ tx_ack = readl(priv->base + MPPHY_PXTXREQ(2 * phy->id)) &
+ readl(priv->base + MPPHY_PXTXREQ((2 * phy->id) + 1));
+ rx_ack = readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id)) &
+ readl(priv->base + MPPHY_PXRXREQ1((2 * phy->id) + 1));
+ } else if (priv->num_lanes[phy->id] == 8) {
+ tx_ack = readl(priv->base + MPPHY_PXTXREQ(0)) &
+ readl(priv->base + MPPHY_PXTXREQ(1)) &
+ readl(priv->base + MPPHY_PXTXREQ(2)) &
+ readl(priv->base + MPPHY_PXTXREQ(3));
+ rx_ack = readl(priv->base + MPPHY_PXRXREQ1(0)) &
+ readl(priv->base + MPPHY_PXRXREQ1(1)) &
+ readl(priv->base + MPPHY_PXRXREQ1(2)) &
+ readl(priv->base + MPPHY_PXRXREQ1(3));
+ }
+
+ return !(tx_ack & BIT(9)) && !(rx_ack & BIT(1));
+}
+
+static int mp_phy_power_on_pcie4(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ int i, id, ret;
+ u32 status;
+
+ if (priv->num_lanes[phy->id] == 2 || priv->num_lanes[phy->id] == 4) {
+ for (i = 0; i < priv->num_lanes[phy->id] / 2; i++) {
+ id = (2 * phy->id) + i;
+ ret = mp_phy_update_firmware_sram(priv->chan[id].phy);
+ if (ret)
+ return ret;
+ }
+
+ for (i = 0; i < priv->num_lanes[phy->id] / 2; i++) {
+ id = (2 * phy->id) + i;
+ ret = mp_phy_reg_wait(priv, MPPHY_PXSRAMCNT(id),
+ SRAM_INIT_DONE, SRAM_INIT_DONE);
+ if (ret)
+ return ret;
+ }
+
+ for (i = 0; i < priv->num_lanes[phy->id] / 2; i++) {
+ id = (2 * phy->id) + i;
+ ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(id), 0x2, 0);
+ if (ret)
+ return ret;
+ }
+ } else if (priv->num_lanes[phy->id] == 8) {
+ for (i = 0; i < 4; i++) {
+ ret = mp_phy_update_firmware_sram(priv->chan[phy->id].phy);
+ if (ret)
+ return ret;
+ }
+
+ for (i = 0; i < 4; i++) {
+ ret = mp_phy_reg_wait(priv, MPPHY_PXSRAMCNT(i),
+ SRAM_INIT_DONE, SRAM_INIT_DONE);
+ if (ret)
+ return ret;
+ }
+
+ for (i = 0; i < 4; i++) {
+ ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(i), 0x2, 0);
+ if (ret)
+ return ret;
+ }
+ }
+
+ ret = read_poll_timeout(mp_phy_read_poll_pcie4, status, status,
+ 20, 2000000, false, phy);
+ if (ret)
+ dev_err(priv->dev, "TX/RX ack timeout\n");
+
+ return ret;
+}
+
+static int mp_phy_power_on(struct phy *phy)
+{
+ struct mp_phy_priv *priv = phy_get_drvdata(phy);
+ struct mp_phy_chan_priv *chan = &priv->chan[phy->id];
+ int ret;
+
+ if (!chan->initialized) {
+ dev_err(priv->dev, "Channel %d not initialized\n", phy->id);
+ return -EINVAL;
+ }
+
+ /*
+ * The datasheet describes initialization procedure without full
+ * information about the registers. Therefore, the source code is
+ * based on the bare metal code shared by the board team.
+ */
+ if (chan->protocol_id == PHY_MODE_PCIE) {
+ ret = mp_phy_power_on_pcie4(phy);
+ if (ret)
+ return ret;
+ } else if (chan->protocol_id == PHY_MODE_ETHERNET) {
+ regmap_set_bits(priv->map, MPPHY_PXSRAMCNT(phy->id), SRAM_EXT_LD_DONE);
+ ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(phy->id), 0x2, 0);
+ if (ret)
+ return ret;
+ } else { /* USB */
+ ret = mp_phy_reg_wait(priv, TCA_OFFSET(phy->id) + TCA_PSTATE_1, 0x3, 0x3);
+ if (ret)
+ return ret;
+
+ regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_EN, 0x3);
+ regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_TCPC, TCA_TCPC_VALID);
+ ret = mp_phy_reg_wait(priv, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1, 0x1);
+ if (ret)
+ return ret;
+
+ regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1503);
+ regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_TCPC,
+ TCA_TCPC_VALID |
+ FIELD_PREP(TCA_TCPC_MUX_CONTRL_USB_CONN,
+ TCA_TCPC_MUX_CONTRL_USB_CONN));
+ ret = mp_phy_reg_wait(priv, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1, 0x1);
+ if (ret)
+ return ret;
+
+ regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1503);
+ }
+
+ return 0;
+}
+
+static const struct phy_ops mp_phy_ops = {
+ .init = mp_phy_init,
+ .exit = mp_phy_exit,
+ .power_on = mp_phy_power_on,
+ .owner = THIS_MODULE,
+};
+
+static int mp_phy_suspend(struct device *dev)
+{
+ struct mp_phy_priv *priv = dev_get_drvdata(dev);
+ int i, ret;
+
+ for (i = 0; i < MPPHY_NUM_CHANNELS; i++)
+ priv->chan[i].initialized = false;
+
+ ret = reset_control_bulk_assert(ARRAY_SIZE(priv->reset_phy), priv->reset_phy);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to assert PHY resets\n");
+
+ clk_bulk_disable_unprepare(priv->num_clks, priv->clk_phy);
+
+ return 0;
+}
+
+static int mp_phy_suspend_late(struct device *dev)
+{
+ struct mp_phy_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ ret = pm_runtime_force_suspend(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to force suspend\n");
+
+ ret = reset_control_assert(priv->reset_core);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to assert PHY core reset\n");
+
+ clk_disable_unprepare(priv->clk_core);
+
+ return 0;
+}
+
+static int mp_phy_resume_early(struct device *dev)
+{
+ struct mp_phy_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ ret = clk_prepare_enable(priv->clk_core);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable PHY core clock\n");
+
+ ret = reset_control_reset(priv->reset_core);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to deassert PHY core reset\n");
+
+ return pm_runtime_force_resume(dev);
+}
+
+static int mp_phy_resume(struct device *dev)
+{
+ struct mp_phy_priv *priv = dev_get_drvdata(dev);
+ int i, ret;
+
+ ret = clk_bulk_prepare_enable(priv->num_clks, priv->clk_phy);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable PHY clocks\n");
+
+ ret = reset_control_bulk_reset(ARRAY_SIZE(priv->reset_phy), priv->reset_phy);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to deassert PHY resets\n");
+
+ /* Reload configuration */
+ regmap_set_bits(priv->map, MPPHY_CMNCNT1, priv->cmncnt[0]);
+ regmap_write(priv->map, MPPHY_CMNCNT2, priv->cmncnt[1]);
+
+ for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
+ regmap_set_bits(priv->map, MPPHY_PXTEST(i), MPPHY_PXTEST_BIT);
+ regmap_write(priv->map, MPPHY_PXSRAMCNT(i), priv->sramcnt[i]);
+
+ if (priv->write_cntxt1 & BIT(i)) {
+ regmap_write(priv->map, MPPHY_CHAN_BASE(i) + 0x10c, 0xff0ff);
+ regmap_write(priv->map, MPPHY_PXCNTXT1(i), 0x180023);
+ }
+
+ regmap_clear_bits(priv->map, MPPHY_PXTEST(i), MPPHY_PXTEST_BIT);
+ }
+
+ regmap_clear_bits(priv->map, MPPHY_PCS0REG1, MPPHY_PCS0REG1_VAL);
+ /*
+ * Release only the PCIe PHYs here. Ethernet PCS released while its
+ * PHY is still not initialized blocks the PCIe40 rate change (link
+ * stuck at Gen1).
+ */
+ regmap_clear_bits(priv->map, MPPHY_PCS0REG5, priv->pcs0reg5_mask);
+
+ return 0;
+}
+
+static struct phy *mp_phy_xlate(struct device *dev,
+ const struct of_phandle_args *args)
+{
+ struct mp_phy_priv *priv = dev_get_drvdata(dev);
+ int id;
+
+ if (args->args_count != 2) {
+ dev_err(dev, "Invalid args_count: %d\n", args->args_count);
+ return ERR_PTR(-EINVAL);
+ }
+
+ id = args->args[0];
+
+ if (id > MPPHY_NUM_CHANNELS) {
+ dev_err(dev, "Invalid channel ID: %d\n", id);
+ return ERR_PTR(-EINVAL);
+ }
+
+ return priv->chan[id].phy;
+}
+
+static int mp_phy_parse_dt(struct platform_device *pdev, struct mp_phy_priv *priv)
+{
+ u32 phy_type[2 * MPPHY_NUM_CHANNELS];
+ u32 ext_ref_clk[MPPHY_NUM_CHANNELS];
+ u32 out_ref_clk[MPPHY_NUM_CHANNELS];
+ struct device *dev = &pdev->dev;
+ int i, ret;
+
+ ret = device_property_read_u32_array(dev, "renesas,phy-type", phy_type, 8);
+ if (ret < 0)
+ return dev_err_probe(dev, -EINVAL, "Failed to read PHY configuration\n");
+
+ ret = device_property_read_u32_array(dev, "renesas,external-ref-clock",
+ ext_ref_clk, 4);
+ if (ret < 0)
+ return dev_err_probe(dev, -EINVAL, "Failed to read PHY clock configuration\n");
+
+ ret = device_property_read_u32_array(dev, "renesas,output-repeat-ref-clock",
+ out_ref_clk, 4);
+ if (ret < 0)
+ return dev_err_probe(dev, -EINVAL, "Failed to read PHY clock out configuration\n");
+
+ /* Test whether the supplied configuration is valid. */
+ for (i = 0; i < ARRAY_SIZE(mp_phy_valid_configs); i++) {
+ if (phy_type[0] == mp_phy_valid_configs[i].phy_type[0] &&
+ phy_type[1] == mp_phy_valid_configs[i].phy_type[1] &&
+ phy_type[2] == mp_phy_valid_configs[i].phy_type[2] &&
+ phy_type[3] == mp_phy_valid_configs[i].phy_type[3] &&
+ phy_type[4] == mp_phy_valid_configs[i].phy_type[4] &&
+ phy_type[5] == mp_phy_valid_configs[i].phy_type[5] &&
+ phy_type[6] == mp_phy_valid_configs[i].phy_type[6] &&
+ phy_type[7] == mp_phy_valid_configs[i].phy_type[7])
+ break;
+ }
+
+ if (i == ARRAY_SIZE(mp_phy_valid_configs))
+ return dev_err_probe(dev, -EINVAL, "Incorrect PHY configuration\n");
+
+ /* Infer PCIe lane count from renesas,phy-type DT property. */
+ priv->num_lanes[0] = mp_phy_valid_configs[i].num_lanes[0];
+ priv->num_lanes[1] = mp_phy_valid_configs[i].num_lanes[1];
+
+ priv->cmncnt[0] = 0;
+ priv->cmncnt[1] = 0x33330000; /* All res_{ack,req}_in_sel are 1 */
+
+ for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
+ priv->chan[i].initialized = false;
+ priv->chan[i].protocol_id = PHY_MODE_INVALID;
+
+ if (phy_type[2 * i] == PHY_TYPE_PCIE) {
+ priv->chan[i].protocol_id = PHY_MODE_PCIE;
+ priv->sramcnt[i] = 0x3;
+ priv->pcs0reg5_mask |= MPPHY_PCS0REG5_CH(i);
+ if (phy_type[(2 * i) + 1] == 0) /* Channel 0 */
+ priv->cmncnt[0] |= 0x0 << (i * 8);
+ else /* Channel 1 */
+ priv->cmncnt[0] |= 0x2 << (i * 8);
+ } else if (phy_type[2 * i] == PHY_TYPE_XPCS) {
+ priv->chan[i].protocol_id = PHY_MODE_ETHERNET;
+ priv->sramcnt[i] = 0x0;
+ priv->write_cntxt1 |= BIT(i);
+ priv->cmncnt[0] |= 0x1 << (i * 8);
+ } else if (phy_type[2 * i] == PHY_TYPE_USB3) {
+ priv->chan[i].protocol_id = PHY_MODE_USB_OTG;
+ priv->sramcnt[i] = 0x9;
+ priv->cmncnt[0] |= 0x3 << (i * 8);
+ } else {
+ /* Cannot be reached. */
+ return -EINVAL;
+ }
+
+ if (ext_ref_clk[i])
+ priv->cmncnt[1] |= BIT(i * 4);
+
+ if (out_ref_clk[i])
+ priv->cmncnt[1] |= BIT((i * 4) + 1);
+ }
+
+ return 0;
+}
+
+static void mp_phy_release_fw(void *fw)
+{
+ release_firmware(fw);
+}
+
+static int mp_phy_request_fw(struct platform_device *pdev, struct mp_phy_priv *priv)
+{
+ struct device *dev = &pdev->dev;
+ int ret;
+
+ ret = request_firmware(&priv->fw, MPPHY_FW_NAME, dev);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(dev, mp_phy_release_fw, (void *)(priv->fw));
+ if (ret)
+ return ret;
+
+ /* Firmware blob size must be even. */
+ if (priv->fw->size % 2) {
+ return dev_err_probe(dev, -EINVAL, "Firmware blob size %zu is odd!\n",
+ priv->fw->size);
+ }
+
+ /* Firmware blob size must be even. */
+ if (priv->fw->size > MPPHY_FW_CH_OFFSET) {
+ return dev_err_probe(dev, -EINVAL, "Firmware blob size %zu too large!\n",
+ priv->fw->size);
+ }
+
+ return 0;
+}
+
+static int mp_phy_probe(struct platform_device *pdev)
+{
+ static const char *const pd_names[] = { "mpp0", "mpp1", "mpp2", "mpp3" };
+ const struct dev_pm_domain_attach_data pd_attach_data = {
+ .pd_names = pd_names,
+ .num_pd_names = ARRAY_SIZE(pd_names),
+ .pd_flags = 0,
+ };
+ struct device *dev = &pdev->dev;
+ struct phy_provider *provider;
+ struct mp_phy_priv *priv;
+ int i, ret;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->dev = dev;
+
+ ret = mp_phy_parse_dt(pdev, priv);
+ if (ret)
+ return ret;
+
+ priv->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(priv->base))
+ return dev_err_probe(dev, PTR_ERR(priv->base), "Failed to map PHY registers\n");
+
+ priv->map = devm_regmap_init_mmio(dev, priv->base, &mp_phy_regmap_config);
+ if (IS_ERR(priv->map))
+ return PTR_ERR(priv->map);
+
+ priv->clk_core = devm_clk_get(dev, "mpphy02");
+ if (IS_ERR(priv->clk_core))
+ return dev_err_probe(dev, PTR_ERR(priv->clk_core),
+ "Failed to get PHY core clock\n");
+
+ priv->num_clks = devm_clk_bulk_get_all(dev, &priv->clk_phy);
+ if (priv->num_clks < 0)
+ return dev_err_probe(dev, priv->num_clks, "Failed to get PHY clocks\n");
+
+ priv->reset_core = devm_reset_control_get_exclusive(dev, "mpphy02");
+ if (IS_ERR(priv->reset_core))
+ return dev_err_probe(dev, PTR_ERR(priv->reset_core),
+ "Failed to get PHY core reset\n");
+
+ priv->reset_phy[0].id = "mpphy01";
+ priv->reset_phy[1].id = "mpphy11";
+ priv->reset_phy[2].id = "mpphy21";
+ priv->reset_phy[3].id = "mpphy31";
+ ret = devm_reset_control_bulk_get_exclusive(dev, ARRAY_SIZE(priv->reset_phy),
+ priv->reset_phy);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to get PHY resets\n");
+
+ ret = mp_phy_request_fw(pdev, priv);
+ if (ret)
+ return ret;
+
+ platform_set_drvdata(pdev, priv);
+
+ ret = devm_pm_domain_attach_list(dev, &pd_attach_data, &priv->pd_list);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to attach power domains\n");
+
+ provider = devm_of_phy_provider_register(dev, mp_phy_xlate);
+ if (IS_ERR(provider))
+ return dev_err_probe(dev, PTR_ERR(provider),
+ "Failed to register PHY provider\n");
+
+ for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
+ priv->chan[i].phy = devm_phy_create(dev, NULL, &mp_phy_ops);
+ if (IS_ERR(priv->chan[i].phy)) {
+ return dev_err_probe(dev, PTR_ERR(priv->chan[i].phy),
+ "Failed to create PHY %d\n", i);
+ }
+
+ priv->chan[i].phy->id = i;
+ phy_set_drvdata(priv->chan[i].phy, priv);
+ }
+
+ ret = mp_phy_resume_early(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to resume PHY\n");
+
+ ret = pm_runtime_get_sync(dev);
+ if (ret) {
+ dev_err_probe(dev, ret, "Failed to get runtime PM\n");
+ goto err_resume;
+ }
+
+ return 0;
+
+err_resume:
+ mp_phy_suspend_late(dev);
+ return ret;
+}
+
+static const struct dev_pm_ops mp_phy_pm_ops = {
+ SET_RUNTIME_PM_OPS(mp_phy_suspend, mp_phy_resume, NULL)
+ SET_LATE_SYSTEM_SLEEP_PM_OPS(mp_phy_suspend_late, mp_phy_resume_early)
+};
+
+static const struct of_device_id mp_phy_of_match[] = {
+ { .compatible = "renesas,rcar-gen5-mpphy" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mp_phy_of_match);
+
+static struct platform_driver mp_phy_driver = {
+ .probe = mp_phy_probe,
+ .driver = {
+ .name = "renesas-mpphy",
+ .of_match_table = mp_phy_of_match,
+ .pm = &mp_phy_pm_ops,
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+};
+
+module_platform_driver(mp_phy_driver);
+
+MODULE_AUTHOR("Thanh Quan");
+MODULE_DESCRIPTION("Renesas Multi-Protocol PHY driver");
+MODULE_LICENSE("GPL");
+MODULE_FIRMWARE(MPPHY_FW_NAME);
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] phy: renesas: rcar-gen5-mpphy: Document how to obtain firmware
2026-11-29 17:37 [PATCH v2 1/3] dt-bindings: phy: Document Renesas Multi-Protocol PHY driver for R-Car X5H Marek Vasut
2026-11-29 17:37 ` [PATCH v2 2/3] phy: renesas: Add " Marek Vasut
@ 2026-11-29 17:37 ` Marek Vasut
1 sibling, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2026-11-29 17:37 UTC (permalink / raw)
To: linux-phy
Cc: Marek Vasut, Arnd Bergmann, Biju Das, Conor Dooley,
Geert Uytterhoeven, Hai Pham, Krzysztof Kozlowski, Magnus Damm,
Manivannan Sadhasivam, Neil Armstrong, Phong Hoang, Rob Herring,
Tam Nguyen, Thanh Quan, Tommaso Merciai, Vinh Nguyen, Vinod Koul,
Yoshihiro Shimoda, devicetree, linux-kernel, linux-renesas-soc
Renesas R-Car X5H (r8a78000) contains a Multi-Protocol PHY, which requires
firmware to be downloaded into it. Add documentation on how to obtain the
firmware in correct format.
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Hai Pham <hai.pham.ud@renesas.com>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Phong Hoang <phong.hoang.wz@renesas.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Tam Nguyen <tam.nguyen.xa@renesas.com>
Cc: Thanh Quan <thanh.quan.xn@renesas.com>
Cc: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Cc: Vinh Nguyen <vinh.nguyen.xz@renesas.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-phy@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
---
V2: New patch
---
Documentation/phy/index.rst | 10 ++++++
.../phy/renesas-rcar-gen5-mpphy-firmware.rst | 33 +++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 Documentation/phy/index.rst
create mode 100644 Documentation/phy/renesas-rcar-gen5-mpphy-firmware.rst
diff --git a/Documentation/phy/index.rst b/Documentation/phy/index.rst
new file mode 100644
index 0000000000000..f61cf6f1c459e
--- /dev/null
+++ b/Documentation/phy/index.rst
@@ -0,0 +1,10 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===
+PHY
+===
+
+.. toctree::
+ :maxdepth: 1
+
+ renesas-rcar-gen5-mpphy-firmware
diff --git a/Documentation/phy/renesas-rcar-gen5-mpphy-firmware.rst b/Documentation/phy/renesas-rcar-gen5-mpphy-firmware.rst
new file mode 100644
index 0000000000000..ce2fba03de0da
--- /dev/null
+++ b/Documentation/phy/renesas-rcar-gen5-mpphy-firmware.rst
@@ -0,0 +1,33 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+====================================================
+Firmware of Multi-Protocol PHY for Renesas R-Car X5H
+====================================================
+
+Renesas R-Car X5H (r8a78000) has a Multi-Protocol PHY, requiring a specific
+firmware download during startup.
+
+However, Renesas currently cannot distribute the firmware free of charge.
+
+The firmware file "MPPHY_fw_offsetaddr_data_ver4p01a_patch0a.xlsx" (note that
+the file name might be different between different datasheet revisions) can be
+found in the datasheet encoded as spreadsheet, and as such, the file's content
+must be converted back to binary form. This can be achieved using the following
+example script:
+
+.. code-block:: sh
+
+ $ libreoffice --headless --convert-to csv MPPHY_fw_offsetaddr_data_ver4p01a_patch0a.xlsx
+ $ tail -n +3 MPPHY_fw_offsetaddr_data_ver4p01a_patch0a.csv | cut -d "," -f 3 | \
+ sed 's@0x\(..\)\(..\)@0x\2\1@' | xxd -r -p > rcar_gen5_mp_phy.bin
+
+Once the text content has been converted into a binary firmware file, verify
+its checksum as follows:
+
+.. code-block:: sh
+
+ $ sha256sum rcar_gen5_mp_phy.bin
+ d9352ba55f095b7f5adaa3f2bce93f5c58eee310b0faf39c290cb5885e1aa7b8 rcar_gen5_mp_phy.bin
+
+The resulting binary file called "rcar_gen5_mp_phy.bin" should be placed in
+the "/lib/firmware" directory before the driver runs.
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H
2026-11-29 17:37 ` [PATCH v2 2/3] phy: renesas: Add " Marek Vasut
@ 2026-11-30 1:05 ` kernel test robot
2026-11-30 1:38 ` kernel test robot
2026-11-30 16:42 ` Geert Uytterhoeven
2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-11-30 1:05 UTC (permalink / raw)
To: Marek Vasut, linux-phy
Cc: llvm, oe-kbuild-all, Thanh Quan, Phong Hoang, Hai Pham,
Yoshihiro Shimoda, Marek Vasut, Arnd Bergmann, Biju Das,
Conor Dooley, Geert Uytterhoeven, Krzysztof Kozlowski,
Magnus Damm, Manivannan Sadhasivam, Neil Armstrong, Rob Herring,
Tam Nguyen, Tommaso Merciai, Vinh Nguyen, Vinod Koul, devicetree,
linux-kernel, linux-renesas-soc
Hi Marek,
kernel test robot noticed the following build warnings:
[auto build test WARNING on phy/next]
[also build test WARNING on geert-renesas-devel/next soc/for-next linus/master v7.4-rc4 next-20261127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Marek-Vasut/phy-renesas-Add-Renesas-Multi-Protocol-PHY-driver-for-R-Car-X5H/20261129-183704
base: https://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git next
patch link: https://lore.kernel.org/r/20261129173739.282027-2-marek.vasut%2Brenesas%40mailbox.org
patch subject: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20261130/20261130085824.jctLCHNP-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 04597ff5c4eda9d66da39a536aa26a7bab2fb2dd)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261130/20261130085824.jctLCHNP-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261130085824.jctLCHNP-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/phy/renesas/phy-rcar-gen5-mpphy.c:455:13: warning: variable 'tx_ack' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
455 | } else if (priv->num_lanes[phy->id] == 8) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/phy/renesas/phy-rcar-gen5-mpphy.c:466:11: note: uninitialized use occurs here
466 | return !(tx_ack & BIT(9)) && !(rx_ack & BIT(1));
| ^~~~~~
drivers/phy/renesas/phy-rcar-gen5-mpphy.c:455:9: note: remove the 'if' if its condition is always true
455 | } else if (priv->num_lanes[phy->id] == 8) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/phy/renesas/phy-rcar-gen5-mpphy.c:445:20: note: initialize the variable 'tx_ack' to silence this warning
445 | u32 rx_ack, tx_ack;
| ^
| = 0
drivers/phy/renesas/phy-rcar-gen5-mpphy.c:584:12: warning: unused function 'mp_phy_suspend' [-Wunused-function]
584 | static int mp_phy_suspend(struct device *dev)
| ^~~~~~~~~~~~~~
drivers/phy/renesas/phy-rcar-gen5-mpphy.c:635:12: warning: unused function 'mp_phy_resume' [-Wunused-function]
635 | static int mp_phy_resume(struct device *dev)
| ^~~~~~~~~~~~~
3 warnings generated.
vim +455 drivers/phy/renesas/phy-rcar-gen5-mpphy.c
441
442 static int mp_phy_read_poll_pcie4(struct phy *phy)
443 {
444 struct mp_phy_priv *priv = phy_get_drvdata(phy);
445 u32 rx_ack, tx_ack;
446
447 if (priv->num_lanes[phy->id] == 2) {
448 tx_ack = readl(priv->base + MPPHY_PXTXREQ(2 * phy->id));
449 rx_ack = readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id));
450 } else if (priv->num_lanes[phy->id] == 4) {
451 tx_ack = readl(priv->base + MPPHY_PXTXREQ(2 * phy->id)) &
452 readl(priv->base + MPPHY_PXTXREQ((2 * phy->id) + 1));
453 rx_ack = readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id)) &
454 readl(priv->base + MPPHY_PXRXREQ1((2 * phy->id) + 1));
> 455 } else if (priv->num_lanes[phy->id] == 8) {
456 tx_ack = readl(priv->base + MPPHY_PXTXREQ(0)) &
457 readl(priv->base + MPPHY_PXTXREQ(1)) &
458 readl(priv->base + MPPHY_PXTXREQ(2)) &
459 readl(priv->base + MPPHY_PXTXREQ(3));
460 rx_ack = readl(priv->base + MPPHY_PXRXREQ1(0)) &
461 readl(priv->base + MPPHY_PXRXREQ1(1)) &
462 readl(priv->base + MPPHY_PXRXREQ1(2)) &
463 readl(priv->base + MPPHY_PXRXREQ1(3));
464 }
465
466 return !(tx_ack & BIT(9)) && !(rx_ack & BIT(1));
467 }
468
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H
2026-11-29 17:37 ` [PATCH v2 2/3] phy: renesas: Add " Marek Vasut
2026-11-30 1:05 ` kernel test robot
@ 2026-11-30 1:38 ` kernel test robot
2026-11-30 16:42 ` Geert Uytterhoeven
2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-11-30 1:38 UTC (permalink / raw)
To: Marek Vasut, linux-phy
Cc: oe-kbuild-all, Thanh Quan, Phong Hoang, Hai Pham,
Yoshihiro Shimoda, Marek Vasut, Arnd Bergmann, Biju Das,
Conor Dooley, Geert Uytterhoeven, Krzysztof Kozlowski,
Magnus Damm, Manivannan Sadhasivam, Neil Armstrong, Rob Herring,
Tam Nguyen, Tommaso Merciai, Vinh Nguyen, Vinod Koul, devicetree,
linux-kernel, linux-renesas-soc
Hi Marek,
kernel test robot noticed the following build warnings:
[auto build test WARNING on phy/next]
[also build test WARNING on geert-renesas-devel/next soc/for-next linus/master v7.4-rc4 next-20261127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Marek-Vasut/phy-renesas-Add-Renesas-Multi-Protocol-PHY-driver-for-R-Car-X5H/20261129-183704
base: https://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git next
patch link: https://lore.kernel.org/r/20261129173739.282027-2-marek.vasut%2Brenesas%40mailbox.org
patch subject: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H
config: sparc-randconfig-1001-20261130 (https://download.01.org/0day-ci/archive/20261130/20261130092534.wxcEPXfE-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261130/20261130092534.wxcEPXfE-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261130092534.wxcEPXfE-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/phy/renesas/phy-rcar-gen5-mpphy.c:635:12: warning: 'mp_phy_resume' defined but not used [-Wunused-function]
635 | static int mp_phy_resume(struct device *dev)
| ^~~~~~~~~~~~~
>> drivers/phy/renesas/phy-rcar-gen5-mpphy.c:584:12: warning: 'mp_phy_suspend' defined but not used [-Wunused-function]
584 | static int mp_phy_suspend(struct device *dev)
| ^~~~~~~~~~~~~~
vim +/mp_phy_resume +635 drivers/phy/renesas/phy-rcar-gen5-mpphy.c
583
> 584 static int mp_phy_suspend(struct device *dev)
585 {
586 struct mp_phy_priv *priv = dev_get_drvdata(dev);
587 int i, ret;
588
589 for (i = 0; i < MPPHY_NUM_CHANNELS; i++)
590 priv->chan[i].initialized = false;
591
592 ret = reset_control_bulk_assert(ARRAY_SIZE(priv->reset_phy), priv->reset_phy);
593 if (ret)
594 return dev_err_probe(dev, ret, "Failed to assert PHY resets\n");
595
596 clk_bulk_disable_unprepare(priv->num_clks, priv->clk_phy);
597
598 return 0;
599 }
600
601 static int mp_phy_suspend_late(struct device *dev)
602 {
603 struct mp_phy_priv *priv = dev_get_drvdata(dev);
604 int ret;
605
606 ret = pm_runtime_force_suspend(dev);
607 if (ret)
608 return dev_err_probe(dev, ret, "Failed to force suspend\n");
609
610 ret = reset_control_assert(priv->reset_core);
611 if (ret)
612 return dev_err_probe(dev, ret, "Failed to assert PHY core reset\n");
613
614 clk_disable_unprepare(priv->clk_core);
615
616 return 0;
617 }
618
619 static int mp_phy_resume_early(struct device *dev)
620 {
621 struct mp_phy_priv *priv = dev_get_drvdata(dev);
622 int ret;
623
624 ret = clk_prepare_enable(priv->clk_core);
625 if (ret)
626 return dev_err_probe(dev, ret, "Failed to enable PHY core clock\n");
627
628 ret = reset_control_reset(priv->reset_core);
629 if (ret)
630 return dev_err_probe(dev, ret, "Failed to deassert PHY core reset\n");
631
632 return pm_runtime_force_resume(dev);
633 }
634
> 635 static int mp_phy_resume(struct device *dev)
636 {
637 struct mp_phy_priv *priv = dev_get_drvdata(dev);
638 int i, ret;
639
640 ret = clk_bulk_prepare_enable(priv->num_clks, priv->clk_phy);
641 if (ret)
642 return dev_err_probe(dev, ret, "Failed to enable PHY clocks\n");
643
644 ret = reset_control_bulk_reset(ARRAY_SIZE(priv->reset_phy), priv->reset_phy);
645 if (ret)
646 return dev_err_probe(dev, ret, "Failed to deassert PHY resets\n");
647
648 /* Reload configuration */
649 regmap_set_bits(priv->map, MPPHY_CMNCNT1, priv->cmncnt[0]);
650 regmap_write(priv->map, MPPHY_CMNCNT2, priv->cmncnt[1]);
651
652 for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
653 regmap_set_bits(priv->map, MPPHY_PXTEST(i), MPPHY_PXTEST_BIT);
654 regmap_write(priv->map, MPPHY_PXSRAMCNT(i), priv->sramcnt[i]);
655
656 if (priv->write_cntxt1 & BIT(i)) {
657 regmap_write(priv->map, MPPHY_CHAN_BASE(i) + 0x10c, 0xff0ff);
658 regmap_write(priv->map, MPPHY_PXCNTXT1(i), 0x180023);
659 }
660
661 regmap_clear_bits(priv->map, MPPHY_PXTEST(i), MPPHY_PXTEST_BIT);
662 }
663
664 regmap_clear_bits(priv->map, MPPHY_PCS0REG1, MPPHY_PCS0REG1_VAL);
665 /*
666 * Release only the PCIe PHYs here. Ethernet PCS released while its
667 * PHY is still not initialized blocks the PCIe40 rate change (link
668 * stuck at Gen1).
669 */
670 regmap_clear_bits(priv->map, MPPHY_PCS0REG5, priv->pcs0reg5_mask);
671
672 return 0;
673 }
674
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/3] phy: renesas: Add Renesas Multi-Protocol PHY driver for R-Car X5H
2026-11-29 17:37 ` [PATCH v2 2/3] phy: renesas: Add " Marek Vasut
2026-11-30 1:05 ` kernel test robot
2026-11-30 1:38 ` kernel test robot
@ 2026-11-30 16:42 ` Geert Uytterhoeven
2 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2026-11-30 16:42 UTC (permalink / raw)
To: Marek Vasut
Cc: Thanh Quan, Phong Hoang, Hai Pham, Yoshihiro Shimoda,
Arnd Bergmann, Biju Das, Conor Dooley, Krzysztof Kozlowski,
Magnus Damm, Manivannan Sadhasivam, Neil Armstrong, Rob Herring,
Tam Nguyen, Tommaso Merciai, Vinh Nguyen, Vinod Koul, devicetree,
linux-kernel, linux-renesas-soc, linux-phy
Hi Marek,
On Sun, Nov 29, 2026, at 18:37, Marek Vasut wrote:
> From: Thanh Quan <thanh.quan.xn@renesas.com>
>
> Add Renesas Multi-Protocol PHY driver for R-Car X5H (R8A78000) SoC.
>
> This is a multiplexing PHY block with inputs from five IPs, and outputs
> to four separate IO blocks. The five inputs are two PCIe4, two USB 3.2,
> and ethernet PCS, each connected into the PHY with up to 4 times 2 lanes.
> The inputs can be multiplexed to the four IO blocks as needed.
>
> The datasheet describes initialization procedure without many information
> about registers' name/bits. So, this driver does contain a bit of magic
> to initialize the hardware.
>
> Signed-off-by: Thanh Quan <thanh.quan.xn@renesas.com>
> Co-developed-by: Phong Hoang <phong.hoang.wz@renesas.com>
> Signed-off-by: Phong Hoang <phong.hoang.wz@renesas.com>
> Co-developed-by: Hai Pham <hai.pham.ud@renesas.com>
> Signed-off-by: Hai Pham <hai.pham.ud@renesas.com>
> Co-developed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Co-developed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Thanks for your patch!
> --- /dev/null
> +++ b/drivers/phy/renesas/phy-rcar-gen5-mpphy.c
> @@ -0,0 +1,933 @@
> struct mp_phy_priv {
> void __iomem *base;
> struct device *dev;
> struct dev_pm_domain_list *pd_list;
> struct reset_control *reset_core;
> struct reset_control_bulk_data reset_phy[MPPHY_NUM_CHANNELS];
> struct clk *clk_core;
> struct clk_bulk_data *clk_phy;
> int num_clks;
> const struct firmware *fw;
> struct regmap *map;
> struct mp_phy_chan_priv chan[MPPHY_NUM_CHANNELS];
> u32 num_lanes[MPPHY_NUM_PCIE];
> u32 write_cntxt1;
unsigned int? Although 4 bits is sufficient, u8?
> u32 pcs0reg5_mask;
> u32 cmncnt[2];
> u8 sramcnt[MPPHY_NUM_CHANNELS];
};
> +static void mp_phy_update_firmware(struct phy *phy)
> +{
> + struct mp_phy_priv *priv = phy_get_drvdata(phy);
> + int i;
> +
> + for (i = 0; i < priv->fw->size; i += 2) {
unsigned int i = ...
> + writew(priv->fw->data[i] | (priv->fw->data[i + 1] << 8),
get_unaligned_le16()?
> + priv->base + MPPHY_FW_BASE + (MPPHY_FW_CH_OFFSET * phy->id) +
> i);
> + }
> +}
> +static void mp_phy_init_pcie4_ch_req(struct mp_phy_priv *priv, const int chs, const int chd,
unsigned int first, unsigned int last
> + const u32 cntxt2, const u32 txreq)
No need for all the consts
> +{
> + int ch;
> +
> + for (ch = chs; ch <= chd; ch++) {
unsigned int ch = ...
Or perhaps drop ch and just increase first?
> + regmap_set_bits(priv->map, MPPHY_PXCNTXT1(ch), 0x2010002);
> + regmap_set_bits(priv->map, MPPHY_PXCNTXT2(ch), cntxt2);
> + regmap_set_bits(priv->map, MPPHY_PXTXREQ(ch), txreq);
> + }
> +}
> +
> +static void mp_phy_init_pcie4_ch_clk(struct mp_phy_priv *priv, const int chs, const int chd)
> +{
> + int ch;
> +
> + for (ch = chs; ch <= chd; ch++) {
> + regmap_set_bits(priv->map, MPPHY_PXREFCLK(ch), 0x30);
> + regmap_set_bits(priv->map, MPPHY_PXREFCLK(ch), 0x4);
> + regmap_set_bits(priv->map, MPPHY_PXREFCLK(ch), 0x1);
> + }
Likewise
> +}
> +
> +static void mp_phy_init_pcie4_ch_rst(struct mp_phy_priv *priv, const int chs, const int chd)
> +{
> + int ch;
> +
> + for (ch = chs; ch <= chd; ch++)
> + regmap_set_bits(priv->map, MPPHY_PXRXCNT(ch), MPPHY_PXRXCNT_RESET_VAL);
> +
> + for (ch = chs; ch <= chd; ch++)
> + regmap_clear_bits(priv->map, MPPHY_PXRXCNT(ch), MPPHY_PXRXCNT_RESET_VAL);
> +}
Likewise (more or less)
> +
> +static int mp_phy_init_pcie4(struct phy *phy)
> +{
> + struct mp_phy_priv *priv = phy_get_drvdata(phy);
> +
> + if (priv->num_lanes[phy->id] == 2) {
switch ()?
However, I am wondering if the below can be refactored / simplified.
The loops seem to run from 0 to num_lanes / 2 - 1, with a.o. some
special handling for the first iteration?
> + if (phy->id == 0) {
> + mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x80004);
> + mp_phy_init_pcie4_ch_clk(priv, 0, 0);
> + mp_phy_init_pcie4_ch_rst(priv, 0, 0);
> + } else if (phy->id == 1) {
> + mp_phy_init_pcie4_ch_req(priv, 2, 2, 0x2020202, 0x8);
> + mp_phy_init_pcie4_ch_clk(priv, 2, 2);
> + mp_phy_init_pcie4_ch_rst(priv, 2, 2);
> + }
> + } else if (priv->num_lanes[phy->id] == 4) {
> + if (phy->id == 0) {
> + mp_phy_init_pcie4_ch_req(priv, 0, 1, 0x2020201, 0x80008);
> + mp_phy_init_pcie4_ch_clk(priv, 0, 1);
> + /* No reset pulse here. */
> + } else if (phy->id == 1) {
> + mp_phy_init_pcie4_ch_req(priv, 2, 3, 0x2020202, 0x8);
> + mp_phy_init_pcie4_ch_clk(priv, 2, 3);
> + mp_phy_init_pcie4_ch_rst(priv, 2, 3);
> + }
> + } else if (priv->num_lanes[phy->id] == 8) {
> + mp_phy_init_pcie4_ch_req(priv, 0, 0, 0x2020201, 0x8);
> + mp_phy_init_pcie4_ch_req(priv, 1, 3, 0x2020202, 0x8);
> + /* No clk settings here. */
> + mp_phy_init_pcie4_ch_rst(priv, 0, 3);
> + }
> +
> + return 0;
> +}
> +static int mp_phy_init(struct phy *phy)
> +{
> + struct mp_phy_priv *priv = phy_get_drvdata(phy);
> + struct mp_phy_chan_priv *chan = &priv->chan[phy->id];
> + int ret;
> +
> + if (chan->initialized)
> + return 0;
> +
> + /*
> + * Note: Current source code support for Ethernet, PCIe initialization
> + * is based on the bare metal code shared by the board team.
> + */
> + ret = pm_runtime_get_sync(priv->pd_list->pd_devs[phy->id]);
> + if (ret < 0) {
> + dev_err(priv->dev,
> + "Failed to power on domain for channel %d: %d\n",
> + phy->id, ret);
%pe and ERR_PTR(ret)?
> + return ret;
> + }
> +
> + if (chan->protocol_id == PHY_MODE_PCIE)
switch ()?
> + ret = mp_phy_init_pcie4(phy);
> + else if (chan->protocol_id == PHY_MODE_ETHERNET)
> + ret = mp_phy_init_ethernet(phy);
> + else
> + ret = mp_phy_init_usb(phy);
> + if (ret)
> + goto err_init;
> +
> + chan->initialized = true;
> + dev_dbg(priv->dev,
> + "Channel %d successfully initialized for protocol %d\n",
> + phy->id, chan->protocol_id);
> +
> + return 0;
> +
> +err_init:
> + pm_runtime_put_sync(priv->pd_list->pd_devs[phy->id]);
> + return ret;
> +}
> +
> +static int mp_phy_read_poll_pcie4(struct phy *phy)
> +{
> + struct mp_phy_priv *priv = phy_get_drvdata(phy);
> + u32 rx_ack, tx_ack;
> +
> + if (priv->num_lanes[phy->id] == 2) {
> + tx_ack = readl(priv->base + MPPHY_PXTXREQ(2 * phy->id));
> + rx_ack = readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id));
> + } else if (priv->num_lanes[phy->id] == 4) {
> + tx_ack = readl(priv->base + MPPHY_PXTXREQ(2 * phy->id)) &
> + readl(priv->base + MPPHY_PXTXREQ((2 * phy->id) + 1));
> + rx_ack = readl(priv->base + MPPHY_PXRXREQ1(2 * phy->id)) &
> + readl(priv->base + MPPHY_PXRXREQ1((2 * phy->id) + 1));
> + } else if (priv->num_lanes[phy->id] == 8) {
> + tx_ack = readl(priv->base + MPPHY_PXTXREQ(0)) &
> + readl(priv->base + MPPHY_PXTXREQ(1)) &
> + readl(priv->base + MPPHY_PXTXREQ(2)) &
> + readl(priv->base + MPPHY_PXTXREQ(3));
> + rx_ack = readl(priv->base + MPPHY_PXRXREQ1(0)) &
> + readl(priv->base + MPPHY_PXRXREQ1(1)) &
> + readl(priv->base + MPPHY_PXRXREQ1(2)) &
> + readl(priv->base + MPPHY_PXRXREQ1(3));
> + }
Again, some looping from 0 to num_lanes / 2 - 1?
> +
> + return !(tx_ack & BIT(9)) && !(rx_ack & BIT(1));
> +}
> +
> +static int mp_phy_power_on_pcie4(struct phy *phy)
> +{
> + struct mp_phy_priv *priv = phy_get_drvdata(phy);
> + int i, id, ret;
> + u32 status;
> +
> + if (priv->num_lanes[phy->id] == 2 || priv->num_lanes[phy->id] == 4) {
> + for (i = 0; i < priv->num_lanes[phy->id] / 2; i++) {
unsigned int i = ...
> + id = (2 * phy->id) + i;
> + ret = mp_phy_update_firmware_sram(priv->chan[id].phy);
> + if (ret)
> + return ret;
> + }
> +
> + for (i = 0; i < priv->num_lanes[phy->id] / 2; i++) {
> + id = (2 * phy->id) + i;
> + ret = mp_phy_reg_wait(priv, MPPHY_PXSRAMCNT(id),
> + SRAM_INIT_DONE, SRAM_INIT_DONE);
> + if (ret)
> + return ret;
> + }
> +
> + for (i = 0; i < priv->num_lanes[phy->id] / 2; i++) {
> + id = (2 * phy->id) + i;
> + ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(id), 0x2, 0);
> + if (ret)
> + return ret;
> + }
> + } else if (priv->num_lanes[phy->id] == 8) {
> + for (i = 0; i < 4; i++) {
> + ret = mp_phy_update_firmware_sram(priv->chan[phy->id].phy);
> + if (ret)
> + return ret;
> + }
> +
> + for (i = 0; i < 4; i++) {
> + ret = mp_phy_reg_wait(priv, MPPHY_PXSRAMCNT(i),
> + SRAM_INIT_DONE, SRAM_INIT_DONE);
> + if (ret)
> + return ret;
> + }
> +
> + for (i = 0; i < 4; i++) {
> + ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(i), 0x2, 0);
> + if (ret)
> + return ret;
> + }
> + }
isn't the code in the two branches doing the exact same thing?
> +
> + ret = read_poll_timeout(mp_phy_read_poll_pcie4, status, status,
> + 20, 2000000, false, phy);
> + if (ret)
> + dev_err(priv->dev, "TX/RX ack timeout\n");
> +
> + return ret;
> +}
> +
> +static int mp_phy_power_on(struct phy *phy)
> +{
> + struct mp_phy_priv *priv = phy_get_drvdata(phy);
> + struct mp_phy_chan_priv *chan = &priv->chan[phy->id];
> + int ret;
> +
> + if (!chan->initialized) {
> + dev_err(priv->dev, "Channel %d not initialized\n", phy->id);
> + return -EINVAL;
> + }
> +
> + /*
> + * The datasheet describes initialization procedure without full
> + * information about the registers. Therefore, the source code is
> + * based on the bare metal code shared by the board team.
> + */
> + if (chan->protocol_id == PHY_MODE_PCIE) {
switch ()
> + ret = mp_phy_power_on_pcie4(phy);
> + if (ret)
> + return ret;
> + } else if (chan->protocol_id == PHY_MODE_ETHERNET) {
> + regmap_set_bits(priv->map, MPPHY_PXSRAMCNT(phy->id), SRAM_EXT_LD_DONE);
> + ret = mp_phy_reg_wait(priv, MPPHY_PXRXREQ1(phy->id), 0x2, 0);
> + if (ret)
> + return ret;
> + } else { /* USB */
> + ret = mp_phy_reg_wait(priv, TCA_OFFSET(phy->id) + TCA_PSTATE_1, 0x3, 0x3);
> + if (ret)
> + return ret;
> +
> + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_EN, 0x3);
> + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_TCPC, TCA_TCPC_VALID);
> + ret = mp_phy_reg_wait(priv, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1, 0x1);
> + if (ret)
> + return ret;
> +
> + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1503);
> + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_TCPC,
> + TCA_TCPC_VALID |
> + FIELD_PREP(TCA_TCPC_MUX_CONTRL_USB_CONN,
> + TCA_TCPC_MUX_CONTRL_USB_CONN));
> + ret = mp_phy_reg_wait(priv, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1, 0x1);
> + if (ret)
> + return ret;
> +
> + regmap_set_bits(priv->map, TCA_OFFSET(phy->id) + TCA_INTR_STS, 0x1503);
> + }
> +
> + return 0;
> +}
> +static int mp_phy_suspend(struct device *dev)
> +{
> + struct mp_phy_priv *priv = dev_get_drvdata(dev);
> + int i, ret;
> +
> + for (i = 0; i < MPPHY_NUM_CHANNELS; i++)
unsigned int i = ...
> + priv->chan[i].initialized = false;
> +
> + ret = reset_control_bulk_assert(ARRAY_SIZE(priv->reset_phy),
> priv->reset_phy);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to assert PHY resets\n");
dev_err(), as dev_err_probe() changes the probe error state in sysfs
(everywhere).
> +
> + clk_bulk_disable_unprepare(priv->num_clks, priv->clk_phy);
> +
> + return 0;
> +}
> +static int mp_phy_resume(struct device *dev)
> +{
> + struct mp_phy_priv *priv = dev_get_drvdata(dev);
> + int i, ret;
> +
> + ret = clk_bulk_prepare_enable(priv->num_clks, priv->clk_phy);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to enable PHY clocks\n");
> +
> + ret = reset_control_bulk_reset(ARRAY_SIZE(priv->reset_phy), priv->reset_phy);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to deassert PHY resets\n");
> +
> + /* Reload configuration */
> + regmap_set_bits(priv->map, MPPHY_CMNCNT1, priv->cmncnt[0]);
> + regmap_write(priv->map, MPPHY_CMNCNT2, priv->cmncnt[1]);
> +
> + for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
unsigned int i = ...
> + regmap_set_bits(priv->map, MPPHY_PXTEST(i), MPPHY_PXTEST_BIT);
> + regmap_write(priv->map, MPPHY_PXSRAMCNT(i), priv->sramcnt[i]);
> +
> + if (priv->write_cntxt1 & BIT(i)) {
> + regmap_write(priv->map, MPPHY_CHAN_BASE(i) + 0x10c, 0xff0ff);
> + regmap_write(priv->map, MPPHY_PXCNTXT1(i), 0x180023);
> + }
> +
> + regmap_clear_bits(priv->map, MPPHY_PXTEST(i), MPPHY_PXTEST_BIT);
> + }
> +
> + regmap_clear_bits(priv->map, MPPHY_PCS0REG1, MPPHY_PCS0REG1_VAL);
> + /*
> + * Release only the PCIe PHYs here. Ethernet PCS released while its
> + * PHY is still not initialized blocks the PCIe40 rate change (link
> + * stuck at Gen1).
> + */
> + regmap_clear_bits(priv->map, MPPHY_PCS0REG5, priv->pcs0reg5_mask);
> +
> + return 0;
> +}
> +
> +static struct phy *mp_phy_xlate(struct device *dev,
> + const struct of_phandle_args *args)
> +{
> + struct mp_phy_priv *priv = dev_get_drvdata(dev);
> + int id;
u32
> +
> + if (args->args_count != 2) {
> + dev_err(dev, "Invalid args_count: %d\n", args->args_count);
> + return ERR_PTR(-EINVAL);
> + }
> +
> + id = args->args[0];
> +
> + if (id > MPPHY_NUM_CHANNELS) {
> + dev_err(dev, "Invalid channel ID: %d\n", id);
%u
> + return ERR_PTR(-EINVAL);
> + }
> +
> + return priv->chan[id].phy;
> +}
> +
> +static int mp_phy_parse_dt(struct platform_device *pdev, struct mp_phy_priv *priv)
> +{
> + u32 phy_type[2 * MPPHY_NUM_CHANNELS];
> + u32 ext_ref_clk[MPPHY_NUM_CHANNELS];
> + u32 out_ref_clk[MPPHY_NUM_CHANNELS];
> + struct device *dev = &pdev->dev;
> + int i, ret;
unsigned int i
> +
> + ret = device_property_read_u32_array(dev, "renesas,phy-type", phy_type, 8);
> + if (ret < 0)
> + return dev_err_probe(dev, -EINVAL, "Failed to read PHY configuration\n");
> +
> + ret = device_property_read_u32_array(dev, "renesas,external-ref-clock",
> + ext_ref_clk, 4);
> + if (ret < 0)
> + return dev_err_probe(dev, -EINVAL, "Failed to read PHY clock configuration\n");
> +
> + ret = device_property_read_u32_array(dev, "renesas,output-repeat-ref-clock",
> + out_ref_clk, 4);
> + if (ret < 0)
> + return dev_err_probe(dev, -EINVAL, "Failed to read PHY clock out configuration\n");
> +
> + /* Test whether the supplied configuration is valid. */
> + for (i = 0; i < ARRAY_SIZE(mp_phy_valid_configs); i++) {
> + if (phy_type[0] == mp_phy_valid_configs[i].phy_type[0] &&
> + phy_type[1] == mp_phy_valid_configs[i].phy_type[1] &&
> + phy_type[2] == mp_phy_valid_configs[i].phy_type[2] &&
> + phy_type[3] == mp_phy_valid_configs[i].phy_type[3] &&
> + phy_type[4] == mp_phy_valid_configs[i].phy_type[4] &&
> + phy_type[5] == mp_phy_valid_configs[i].phy_type[5] &&
> + phy_type[6] == mp_phy_valid_configs[i].phy_type[6] &&
> + phy_type[7] == mp_phy_valid_configs[i].phy_type[7])
memcmp()
> + break;
> + }
> +
> + if (i == ARRAY_SIZE(mp_phy_valid_configs))
> + return dev_err_probe(dev, -EINVAL, "Incorrect PHY configuration\n");
> +
> + /* Infer PCIe lane count from renesas,phy-type DT property. */
> + priv->num_lanes[0] = mp_phy_valid_configs[i].num_lanes[0];
> + priv->num_lanes[1] = mp_phy_valid_configs[i].num_lanes[1];
> +
> + priv->cmncnt[0] = 0;
> + priv->cmncnt[1] = 0x33330000; /* All res_{ack,req}_in_sel are 1 */
> +
> + for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
> + priv->chan[i].initialized = false;
> + priv->chan[i].protocol_id = PHY_MODE_INVALID;
> +
> + if (phy_type[2 * i] == PHY_TYPE_PCIE) {
switch ()
> + priv->chan[i].protocol_id = PHY_MODE_PCIE;
> + priv->sramcnt[i] = 0x3;
> + priv->pcs0reg5_mask |= MPPHY_PCS0REG5_CH(i);
> + if (phy_type[(2 * i) + 1] == 0) /* Channel 0 */
> + priv->cmncnt[0] |= 0x0 << (i * 8);
> + else /* Channel 1 */
> + priv->cmncnt[0] |= 0x2 << (i * 8);
> + } else if (phy_type[2 * i] == PHY_TYPE_XPCS) {
> + priv->chan[i].protocol_id = PHY_MODE_ETHERNET;
> + priv->sramcnt[i] = 0x0;
> + priv->write_cntxt1 |= BIT(i);
> + priv->cmncnt[0] |= 0x1 << (i * 8);
> + } else if (phy_type[2 * i] == PHY_TYPE_USB3) {
> + priv->chan[i].protocol_id = PHY_MODE_USB_OTG;
> + priv->sramcnt[i] = 0x9;
> + priv->cmncnt[0] |= 0x3 << (i * 8);
> + } else {
> + /* Cannot be reached. */
> + return -EINVAL;
> + }
> +
> + if (ext_ref_clk[i])
> + priv->cmncnt[1] |= BIT(i * 4);
> +
> + if (out_ref_clk[i])
> + priv->cmncnt[1] |= BIT((i * 4) + 1);
> + }
> +
> + return 0;
> +}
> +static int mp_phy_probe(struct platform_device *pdev)
> +{
> + for (i = 0; i < MPPHY_NUM_CHANNELS; i++) {
unsigned int i = ...
> + priv->chan[i].phy = devm_phy_create(dev, NULL, &mp_phy_ops);
> + if (IS_ERR(priv->chan[i].phy)) {
> + return dev_err_probe(dev, PTR_ERR(priv->chan[i].phy),
> + "Failed to create PHY %d\n", i);
> + }
> +
> + priv->chan[i].phy->id = i;
> + phy_set_drvdata(priv->chan[i].phy, priv);
> + }
> +
> + ret = mp_phy_resume_early(dev);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to resume PHY\n");
> +
> + ret = pm_runtime_get_sync(dev);
> + if (ret) {
> + dev_err_probe(dev, ret, "Failed to get runtime PM\n");
> + goto err_resume;
> + }
> +
> + return 0;
> +
> +err_resume:
> + mp_phy_suspend_late(dev);
> + return ret;
> +}
> +
> +static const struct dev_pm_ops mp_phy_pm_ops = {
> + SET_RUNTIME_PM_OPS(mp_phy_suspend, mp_phy_resume, NULL)
RUNTIME_PM_OPS() (which includes pm_sleep_ptr())
> + SET_LATE_SYSTEM_SLEEP_PM_OPS(mp_phy_suspend_late, mp_phy_resume_early)
LATE_SYSTEM_SLEEP_PM_OPS()
> +};
> +
> +static const struct of_device_id mp_phy_of_match[] = {
> + { .compatible = "renesas,rcar-gen5-mpphy" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mp_phy_of_match);
> +
> +static struct platform_driver mp_phy_driver = {
> + .probe = mp_phy_probe,
> + .driver = {
> + .name = "renesas-mpphy",
> + .of_match_table = mp_phy_of_match,
> + .pm = &mp_phy_pm_ops,
pm_sleep_ptr()
> + .probe_type = PROBE_PREFER_ASYNCHRONOUS,
> + },
> +};
> +
> +module_platform_driver(mp_phy_driver);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-30 16:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 17:37 [PATCH v2 1/3] dt-bindings: phy: Document Renesas Multi-Protocol PHY driver for R-Car X5H Marek Vasut
2026-11-29 17:37 ` [PATCH v2 2/3] phy: renesas: Add " Marek Vasut
2026-11-30 1:05 ` kernel test robot
2026-11-30 1:38 ` kernel test robot
2026-11-30 16:42 ` Geert Uytterhoeven
2026-11-29 17:37 ` [PATCH v2 3/3] phy: renesas: rcar-gen5-mpphy: Document how to obtain firmware Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®