Skip to content

Commit 8bb92fd

Browse files
Tommaso Merciaivinodkoul
authored andcommitted
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>
1 parent b6d7dd1 commit 8bb92fd

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

drivers/phy/renesas/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ config PHY_RCAR_GEN3_USB2
3030
depends on EXTCON || !EXTCON # if EXTCON=m, this cannot be built-in
3131
depends on USB_SUPPORT
3232
select GENERIC_PHY
33+
select MULTIPLEXER
3334
select USB_COMMON
3435
help
3536
Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs.

drivers/phy/renesas/phy-rcar-gen3-usb2.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/io.h>
1818
#include <linux/module.h>
1919
#include <linux/mutex.h>
20+
#include <linux/mux/consumer.h>
2021
#include <linux/of.h>
2122
#include <linux/phy/phy.h>
2223
#include <linux/platform_device.h>
@@ -938,11 +939,27 @@ static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *cha
938939
return rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(channel, enable);
939940
}
940941

942+
/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
943+
static inline struct mux_state *
944+
devm_mux_state_get_optional(struct device *dev, const char *mux_name)
945+
{
946+
if (!of_property_present(dev->of_node, "mux-states"))
947+
return NULL;
948+
949+
return devm_mux_state_get(dev, mux_name);
950+
}
951+
952+
static void rcar_gen3_phy_mux_state_deselect(void *data)
953+
{
954+
mux_state_deselect(data);
955+
}
956+
941957
static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
942958
{
943959
struct device *dev = &pdev->dev;
944960
struct rcar_gen3_chan *channel;
945961
struct phy_provider *provider;
962+
struct mux_state *mux_state;
946963
int ret = 0, i, irq;
947964

948965
if (!dev->of_node) {
@@ -1019,6 +1036,21 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
10191036
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
10201037
}
10211038

1039+
mux_state = devm_mux_state_get_optional(dev, NULL);
1040+
if (IS_ERR(mux_state))
1041+
return PTR_ERR(mux_state);
1042+
if (mux_state) {
1043+
ret = mux_state_select(mux_state);
1044+
if (ret)
1045+
return dev_err_probe(dev, ret, "Failed to select USB mux\n");
1046+
1047+
ret = devm_add_action_or_reset(dev, rcar_gen3_phy_mux_state_deselect,
1048+
mux_state);
1049+
if (ret)
1050+
return dev_err_probe(dev, ret,
1051+
"Failed to register USB mux state deselect\n");
1052+
}
1053+
10221054
if (channel->phy_data->no_adp_ctrl && channel->is_otg_channel) {
10231055
ret = rcar_gen3_phy_usb2_vbus_regulator_register(channel);
10241056
if (ret)

0 commit comments

Comments
 (0)