From 096abe646461247b0cbe94ec74c52b4879b9768c Mon Sep 17 00:00:00 2001 From: William Wu Date: Wed, 11 Nov 2020 15:50:30 +0800 Subject: [PATCH] phy: rockchip: naneng-combphy: select pipe to controller for rk3568 RK3568 has three combo phys, and PCIe/USB3/SATA/QSGMII controllers share one pipe interface for each combo phy, here is the diagram of the complex connection. This patch select the pipe to the corresponding controller when set phy mode. +----------------+ | | +------+ | USB3 OTG CTRL0 |---->| | | | | | +------------+ +----------------+ | PIPE | | | | MUX |---->| Combo PHY0 | +----------------+ | | | | | | | | +------------+ | SATA CTRL0 |---->| | | | +------+ +----------------+ +----------------+ | | +------+ | USB3 HOST CTRL1|---->| | | | | | +------------+ +----------------+ | PIPE | | | | MUX |---->| Combo PHY1 | +----------------+ | | | | | |---->| | +------------+ | SATA CTRL1 | -->| | | | | +------+ +----------------+ | | +----------------+ | | | | +------+ | QSGMII CTRL |---->| | | | | | +------------+ +----------------+ | PIPE | | | | MUX |---->| Combo PHY2 | +----------------+ | | | | | |---->| | +------------+ | SATA CTRL2 | -->| | | | | +------+ +----------------+ | | +----------------+ | | | | | PCIe2 1-Lane |--- | | +----------------+ Change-Id: I6ec6dd0a0202119633e594c9a72f361156330b06 Signed-off-by: William Wu --- drivers/phy/rockchip/phy-rockchip-naneng-combphy.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c index a7424555f31d..8e060750b67d 100644 --- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c +++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c @@ -39,6 +39,9 @@ struct rockchip_combphy_grfcfg { struct combphy_reg pipe_txcomp_set; struct combphy_reg pipe_txelec_sel; struct combphy_reg pipe_txelec_set; + struct combphy_reg pipe_sel_usb; + struct combphy_reg pipe_sel_sata; + struct combphy_reg pipe_sel_qsgmii; }; struct rockchip_combphy_priv { @@ -88,11 +91,13 @@ static int rockchip_combphy_set_mode(struct rockchip_combphy_priv *priv) param_write(priv->phy_grf, &cfg->pcie_mode_set, true); break; case PHY_TYPE_USB3: + param_write(priv->phy_grf, &cfg->pipe_sel_usb, true); param_write(priv->phy_grf, &cfg->pipe_txcomp_sel, false); param_write(priv->phy_grf, &cfg->pipe_txelec_sel, false); param_write(priv->phy_grf, &cfg->usb_mode_set, true); break; case PHY_TYPE_SATA: + param_write(priv->phy_grf, &cfg->pipe_sel_sata, true); param_write(priv->phy_grf, &cfg->sata_mode_set, true); break; default: @@ -212,6 +217,9 @@ static const struct rockchip_combphy_grfcfg rk3568_combphy_cfgs = { .pipe_txcomp_set = { 0x0004, 4, 4, 0x00, 0x01 }, .pipe_txelec_sel = { 0x0008, 12, 12, 0x00, 0x01 }, .pipe_txelec_set = { 0x0004, 1, 1, 0x00, 0x01 }, + .pipe_sel_usb = { 0x000c, 14, 13, 0x00, 0x01 }, + .pipe_sel_sata = { 0x000c, 14, 13, 0x00, 0x02 }, + .pipe_sel_qsgmii = { 0x000c, 14, 13, 0x00, 0x03 }, }; static const struct of_device_id rockchip_combphy_of_match[] = {