Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management

Add support for selecting the phyrst mux-state using the Linux mux
subsystem in the R-Car Gen3 USB2 PHY driver. This ensures correct hardware
initialization and integration with systems utilizing the mux-state device
tree property.

A temporary wrapper for optional muxes is introduced until native support
is available in the multiplexer subsystem.

Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Link: https://patch.msgid.link/80aafdb2367dcada720b0a9ebeea344764e710fb.1766405010.git.tommaso.merciai.xr@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Tommaso Merciai and committed by
Vinod Koul
8bb92fd7 b6d7dd15

+33
+1
drivers/phy/renesas/Kconfig
··· 30 30 depends on EXTCON || !EXTCON # if EXTCON=m, this cannot be built-in 31 31 depends on USB_SUPPORT 32 32 select GENERIC_PHY 33 + select MULTIPLEXER 33 34 select USB_COMMON 34 35 help 35 36 Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs.
+32
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 17 17 #include <linux/io.h> 18 18 #include <linux/module.h> 19 19 #include <linux/mutex.h> 20 + #include <linux/mux/consumer.h> 20 21 #include <linux/of.h> 21 22 #include <linux/phy/phy.h> 22 23 #include <linux/platform_device.h> ··· 939 938 return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable); 940 939 } 941 940 941 + /* Temporary wrapper until the multiplexer subsystem supports optional muxes */ 942 + static inline struct mux_state * 943 + devm_mux_state_get_optional(struct device *dev, const char *mux_name) 944 + { 945 + if (!of_property_present(dev->of_node, "mux-states")) 946 + return NULL; 947 + 948 + return devm_mux_state_get(dev, mux_name); 949 + } 950 + 951 + static void rcar_gen3_phy_mux_state_deselect(void *data) 952 + { 953 + mux_state_deselect(data); 954 + } 955 + 942 956 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) 943 957 { 944 958 struct device *dev = &pdev->dev; 945 959 struct rcar_gen3_chan *channel; 946 960 struct phy_provider *provider; 961 + struct mux_state *mux_state; 947 962 int ret = 0, i, irq; 948 963 949 964 if (!dev->of_node) { ··· 1034 1017 channel->rphys[i].ch = channel; 1035 1018 channel->rphys[i].int_enable_bits = rcar_gen3_int_enable[i]; 1036 1019 phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]); 1020 + } 1021 + 1022 + mux_state = devm_mux_state_get_optional(dev, NULL); 1023 + if (IS_ERR(mux_state)) 1024 + return PTR_ERR(mux_state); 1025 + if (mux_state) { 1026 + ret = mux_state_select(mux_state); 1027 + if (ret) 1028 + return dev_err_probe(dev, ret, "Failed to select USB mux\n"); 1029 + 1030 + ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect, 1031 + mux_state); 1032 + if (ret) 1033 + return dev_err_probe(dev, ret, 1034 + "Failed to register USB mux state deselect\n"); 1037 1035 } 1038 1036 1039 1037 if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {