Commit 63407d30 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'phy-fixes-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy

Pull phy fixes from Vinod Koul:

 - static checker (array size, bounds) fix for marvel driver

 - Rockchip rk3588 pcie fixes for bifurcation and mux

 - Qualcomm qmp-compbo fix for VCO, register base and regulator name for
   m31 driver

 - charger det crash fix for ti driver

* tag 'phy-fixes-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy:
  phy: ti: tusb1210: Resolve charger-det crash if charger psy is unregistered
  phy: qcom: qmp-combo: fix VCO div offset on v5_5nm and v6
  phy: phy-rockchip-samsung-hdptx: Select CONFIG_RATIONAL
  phy: qcom: m31: match requested regulator name with dt schema
  phy: qcom: qmp-combo: Fix register base for QSERDES_DP_PHY_MODE
  phy: qcom: qmp-combo: Fix VCO div offset on v3
  phy: rockchip: naneng-combphy: Fix mux on rk3588
  phy: rockchip-snps-pcie3: fix clearing PHP_GRF_PCIESEL_CON bits
  phy: rockchip-snps-pcie3: fix bifurcation on rk3588
  phy: freescale: imx8m-pcie: fix pcie link-up instability
  phy: marvell: a3700-comphy: Fix hardcoded array size
  phy: marvell: a3700-comphy: Fix out of bounds read
parents 5eb4573e bf6e4ee5
...@@ -110,8 +110,10 @@ static int imx8_pcie_phy_power_on(struct phy *phy) ...@@ -110,8 +110,10 @@ static int imx8_pcie_phy_power_on(struct phy *phy)
/* Source clock from SoC internal PLL */ /* Source clock from SoC internal PLL */
writel(ANA_PLL_CLK_OUT_TO_EXT_IO_SEL, writel(ANA_PLL_CLK_OUT_TO_EXT_IO_SEL,
imx8_phy->base + IMX8MM_PCIE_PHY_CMN_REG062); imx8_phy->base + IMX8MM_PCIE_PHY_CMN_REG062);
if (imx8_phy->drvdata->variant != IMX8MM) {
writel(AUX_PLL_REFCLK_SEL_SYS_PLL, writel(AUX_PLL_REFCLK_SEL_SYS_PLL,
imx8_phy->base + IMX8MM_PCIE_PHY_CMN_REG063); imx8_phy->base + IMX8MM_PCIE_PHY_CMN_REG063);
}
val = ANA_AUX_RX_TX_SEL_TX | ANA_AUX_TX_TERM; val = ANA_AUX_RX_TX_SEL_TX | ANA_AUX_TX_TERM;
writel(val | ANA_AUX_RX_TERM_GND_EN, writel(val | ANA_AUX_RX_TERM_GND_EN,
imx8_phy->base + IMX8MM_PCIE_PHY_CMN_REG064); imx8_phy->base + IMX8MM_PCIE_PHY_CMN_REG064);
......
...@@ -603,7 +603,7 @@ static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane, ...@@ -603,7 +603,7 @@ static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane,
u16 val; u16 val;
fix_idx = 0; fix_idx = 0;
for (addr = 0; addr < 512; addr++) { for (addr = 0; addr < ARRAY_SIZE(gbe_phy_init); addr++) {
/* /*
* All PHY register values are defined in full for 3.125Gbps * All PHY register values are defined in full for 3.125Gbps
* SERDES speed. The values required for 1.25 Gbps are almost * SERDES speed. The values required for 1.25 Gbps are almost
...@@ -611,10 +611,11 @@ static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane, ...@@ -611,10 +611,11 @@ static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane,
* comparison to 3.125 Gbps values. These register values are * comparison to 3.125 Gbps values. These register values are
* stored in "gbe_phy_init_fix" array. * stored in "gbe_phy_init_fix" array.
*/ */
if (!is_1gbps && gbe_phy_init_fix[fix_idx].addr == addr) { if (!is_1gbps &&
fix_idx < ARRAY_SIZE(gbe_phy_init_fix) &&
gbe_phy_init_fix[fix_idx].addr == addr) {
/* Use new value */ /* Use new value */
val = gbe_phy_init_fix[fix_idx].value; val = gbe_phy_init_fix[fix_idx].value;
if (fix_idx < ARRAY_SIZE(gbe_phy_init_fix))
fix_idx++; fix_idx++;
} else { } else {
val = gbe_phy_init[addr]; val = gbe_phy_init[addr];
......
...@@ -297,7 +297,7 @@ static int m31usb_phy_probe(struct platform_device *pdev) ...@@ -297,7 +297,7 @@ static int m31usb_phy_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(qphy->phy), return dev_err_probe(dev, PTR_ERR(qphy->phy),
"failed to create phy\n"); "failed to create phy\n");
qphy->vreg = devm_regulator_get(dev, "vdda-phy"); qphy->vreg = devm_regulator_get(dev, "vdd");
if (IS_ERR(qphy->vreg)) if (IS_ERR(qphy->vreg))
return dev_err_probe(dev, PTR_ERR(qphy->vreg), return dev_err_probe(dev, PTR_ERR(qphy->vreg),
"failed to get vreg\n"); "failed to get vreg\n");
......
...@@ -77,6 +77,7 @@ enum qphy_reg_layout { ...@@ -77,6 +77,7 @@ enum qphy_reg_layout {
QPHY_COM_BIAS_EN_CLKBUFLR_EN, QPHY_COM_BIAS_EN_CLKBUFLR_EN,
QPHY_DP_PHY_STATUS, QPHY_DP_PHY_STATUS,
QPHY_DP_PHY_VCO_DIV,
QPHY_TX_TX_POL_INV, QPHY_TX_TX_POL_INV,
QPHY_TX_TX_DRV_LVL, QPHY_TX_TX_DRV_LVL,
...@@ -102,6 +103,7 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { ...@@ -102,6 +103,7 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
[QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN,
[QPHY_DP_PHY_STATUS] = QSERDES_V3_DP_PHY_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V3_DP_PHY_STATUS,
[QPHY_DP_PHY_VCO_DIV] = QSERDES_V3_DP_PHY_VCO_DIV,
[QPHY_TX_TX_POL_INV] = QSERDES_V3_TX_TX_POL_INV, [QPHY_TX_TX_POL_INV] = QSERDES_V3_TX_TX_POL_INV,
[QPHY_TX_TX_DRV_LVL] = QSERDES_V3_TX_TX_DRV_LVL, [QPHY_TX_TX_DRV_LVL] = QSERDES_V3_TX_TX_DRV_LVL,
...@@ -126,6 +128,7 @@ static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { ...@@ -126,6 +128,7 @@ static const unsigned int qmp_v45_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
[QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN,
[QPHY_DP_PHY_STATUS] = QSERDES_V4_DP_PHY_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V4_DP_PHY_STATUS,
[QPHY_DP_PHY_VCO_DIV] = QSERDES_V4_DP_PHY_VCO_DIV,
[QPHY_TX_TX_POL_INV] = QSERDES_V4_TX_TX_POL_INV, [QPHY_TX_TX_POL_INV] = QSERDES_V4_TX_TX_POL_INV,
[QPHY_TX_TX_DRV_LVL] = QSERDES_V4_TX_TX_DRV_LVL, [QPHY_TX_TX_DRV_LVL] = QSERDES_V4_TX_TX_DRV_LVL,
...@@ -150,6 +153,7 @@ static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { ...@@ -150,6 +153,7 @@ static const unsigned int qmp_v5_5nm_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
[QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN, [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V5_COM_BIAS_EN_CLKBUFLR_EN,
[QPHY_DP_PHY_STATUS] = QSERDES_V5_DP_PHY_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V5_DP_PHY_STATUS,
[QPHY_DP_PHY_VCO_DIV] = QSERDES_V5_DP_PHY_VCO_DIV,
[QPHY_TX_TX_POL_INV] = QSERDES_V5_5NM_TX_TX_POL_INV, [QPHY_TX_TX_POL_INV] = QSERDES_V5_5NM_TX_TX_POL_INV,
[QPHY_TX_TX_DRV_LVL] = QSERDES_V5_5NM_TX_TX_DRV_LVL, [QPHY_TX_TX_DRV_LVL] = QSERDES_V5_5NM_TX_TX_DRV_LVL,
...@@ -174,6 +178,7 @@ static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { ...@@ -174,6 +178,7 @@ static const unsigned int qmp_v6_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = {
[QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN, [QPHY_COM_BIAS_EN_CLKBUFLR_EN] = QSERDES_V6_COM_PLL_BIAS_EN_CLK_BUFLR_EN,
[QPHY_DP_PHY_STATUS] = QSERDES_V6_DP_PHY_STATUS, [QPHY_DP_PHY_STATUS] = QSERDES_V6_DP_PHY_STATUS,
[QPHY_DP_PHY_VCO_DIV] = QSERDES_V6_DP_PHY_VCO_DIV,
[QPHY_TX_TX_POL_INV] = QSERDES_V6_TX_TX_POL_INV, [QPHY_TX_TX_POL_INV] = QSERDES_V6_TX_TX_POL_INV,
[QPHY_TX_TX_DRV_LVL] = QSERDES_V6_TX_TX_DRV_LVL, [QPHY_TX_TX_DRV_LVL] = QSERDES_V6_TX_TX_DRV_LVL,
...@@ -2150,9 +2155,9 @@ static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp) ...@@ -2150,9 +2155,9 @@ static bool qmp_combo_configure_dp_mode(struct qmp_combo *qmp)
writel(val, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL); writel(val, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL);
if (reverse) if (reverse)
writel(0x4c, qmp->pcs + QSERDES_DP_PHY_MODE); writel(0x4c, qmp->dp_dp_phy + QSERDES_DP_PHY_MODE);
else else
writel(0x5c, qmp->pcs + QSERDES_DP_PHY_MODE); writel(0x5c, qmp->dp_dp_phy + QSERDES_DP_PHY_MODE);
return reverse; return reverse;
} }
...@@ -2162,6 +2167,7 @@ static int qmp_combo_configure_dp_clocks(struct qmp_combo *qmp) ...@@ -2162,6 +2167,7 @@ static int qmp_combo_configure_dp_clocks(struct qmp_combo *qmp)
const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts; const struct phy_configure_opts_dp *dp_opts = &qmp->dp_opts;
u32 phy_vco_div; u32 phy_vco_div;
unsigned long pixel_freq; unsigned long pixel_freq;
const struct qmp_phy_cfg *cfg = qmp->cfg;
switch (dp_opts->link_rate) { switch (dp_opts->link_rate) {
case 1620: case 1620:
...@@ -2184,7 +2190,7 @@ static int qmp_combo_configure_dp_clocks(struct qmp_combo *qmp) ...@@ -2184,7 +2190,7 @@ static int qmp_combo_configure_dp_clocks(struct qmp_combo *qmp)
/* Other link rates aren't supported */ /* Other link rates aren't supported */
return -EINVAL; return -EINVAL;
} }
writel(phy_vco_div, qmp->dp_dp_phy + QSERDES_V4_DP_PHY_VCO_DIV); writel(phy_vco_div, qmp->dp_dp_phy + cfg->regs[QPHY_DP_PHY_VCO_DIV]);
clk_set_rate(qmp->dp_link_hw.clk, dp_opts->link_rate * 100000); clk_set_rate(qmp->dp_link_hw.clk, dp_opts->link_rate * 100000);
clk_set_rate(qmp->dp_pixel_hw.clk, pixel_freq); clk_set_rate(qmp->dp_pixel_hw.clk, pixel_freq);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define QCOM_PHY_QMP_DP_PHY_V5_H_ #define QCOM_PHY_QMP_DP_PHY_V5_H_
/* Only for QMP V5 PHY - DP PHY registers */ /* Only for QMP V5 PHY - DP PHY registers */
#define QSERDES_V5_DP_PHY_VCO_DIV 0x070
#define QSERDES_V5_DP_PHY_AUX_INTERRUPT_STATUS 0x0d8 #define QSERDES_V5_DP_PHY_AUX_INTERRUPT_STATUS 0x0d8
#define QSERDES_V5_DP_PHY_STATUS 0x0dc #define QSERDES_V5_DP_PHY_STATUS 0x0dc
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define QCOM_PHY_QMP_DP_PHY_V6_H_ #define QCOM_PHY_QMP_DP_PHY_V6_H_
/* Only for QMP V6 PHY - DP PHY registers */ /* Only for QMP V6 PHY - DP PHY registers */
#define QSERDES_V6_DP_PHY_VCO_DIV 0x070
#define QSERDES_V6_DP_PHY_AUX_INTERRUPT_STATUS 0x0e0 #define QSERDES_V6_DP_PHY_AUX_INTERRUPT_STATUS 0x0e0
#define QSERDES_V6_DP_PHY_STATUS 0x0e4 #define QSERDES_V6_DP_PHY_STATUS 0x0e4
......
...@@ -87,6 +87,7 @@ config PHY_ROCKCHIP_SAMSUNG_HDPTX ...@@ -87,6 +87,7 @@ config PHY_ROCKCHIP_SAMSUNG_HDPTX
tristate "Rockchip Samsung HDMI/eDP Combo PHY driver" tristate "Rockchip Samsung HDMI/eDP Combo PHY driver"
depends on (ARCH_ROCKCHIP || COMPILE_TEST) && OF depends on (ARCH_ROCKCHIP || COMPILE_TEST) && OF
select GENERIC_PHY select GENERIC_PHY
select RATIONAL
help help
Enable this to support the Rockchip HDMI/eDP Combo PHY Enable this to support the Rockchip HDMI/eDP Combo PHY
with Samsung IP block. with Samsung IP block.
......
...@@ -125,12 +125,15 @@ struct rockchip_combphy_grfcfg { ...@@ -125,12 +125,15 @@ struct rockchip_combphy_grfcfg {
}; };
struct rockchip_combphy_cfg { struct rockchip_combphy_cfg {
unsigned int num_phys;
unsigned int phy_ids[3];
const struct rockchip_combphy_grfcfg *grfcfg; const struct rockchip_combphy_grfcfg *grfcfg;
int (*combphy_cfg)(struct rockchip_combphy_priv *priv); int (*combphy_cfg)(struct rockchip_combphy_priv *priv);
}; };
struct rockchip_combphy_priv { struct rockchip_combphy_priv {
u8 type; u8 type;
int id;
void __iomem *mmio; void __iomem *mmio;
int num_clks; int num_clks;
struct clk_bulk_data *clks; struct clk_bulk_data *clks;
...@@ -320,7 +323,7 @@ static int rockchip_combphy_probe(struct platform_device *pdev) ...@@ -320,7 +323,7 @@ static int rockchip_combphy_probe(struct platform_device *pdev)
struct rockchip_combphy_priv *priv; struct rockchip_combphy_priv *priv;
const struct rockchip_combphy_cfg *phy_cfg; const struct rockchip_combphy_cfg *phy_cfg;
struct resource *res; struct resource *res;
int ret; int ret, id;
phy_cfg = of_device_get_match_data(dev); phy_cfg = of_device_get_match_data(dev);
if (!phy_cfg) { if (!phy_cfg) {
...@@ -338,6 +341,15 @@ static int rockchip_combphy_probe(struct platform_device *pdev) ...@@ -338,6 +341,15 @@ static int rockchip_combphy_probe(struct platform_device *pdev)
return ret; return ret;
} }
/* find the phy-id from the io address */
priv->id = -ENODEV;
for (id = 0; id < phy_cfg->num_phys; id++) {
if (res->start == phy_cfg->phy_ids[id]) {
priv->id = id;
break;
}
}
priv->dev = dev; priv->dev = dev;
priv->type = PHY_NONE; priv->type = PHY_NONE;
priv->cfg = phy_cfg; priv->cfg = phy_cfg;
...@@ -562,6 +574,12 @@ static const struct rockchip_combphy_grfcfg rk3568_combphy_grfcfgs = { ...@@ -562,6 +574,12 @@ static const struct rockchip_combphy_grfcfg rk3568_combphy_grfcfgs = {
}; };
static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = { static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = {
.num_phys = 3,
.phy_ids = {
0xfe820000,
0xfe830000,
0xfe840000,
},
.grfcfg = &rk3568_combphy_grfcfgs, .grfcfg = &rk3568_combphy_grfcfgs,
.combphy_cfg = rk3568_combphy_cfg, .combphy_cfg = rk3568_combphy_cfg,
}; };
...@@ -578,9 +596,15 @@ static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv) ...@@ -578,9 +596,15 @@ static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv)
rockchip_combphy_param_write(priv->phy_grf, &cfg->con1_for_pcie, true); rockchip_combphy_param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
rockchip_combphy_param_write(priv->phy_grf, &cfg->con2_for_pcie, true); rockchip_combphy_param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
rockchip_combphy_param_write(priv->phy_grf, &cfg->con3_for_pcie, true); rockchip_combphy_param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
switch (priv->id) {
case 1:
rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l0_sel, true); rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l0_sel, true);
break;
case 2:
rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l1_sel, true); rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l1_sel, true);
break; break;
}
break;
case PHY_TYPE_USB3: case PHY_TYPE_USB3:
/* Set SSC downward spread spectrum */ /* Set SSC downward spread spectrum */
rockchip_combphy_updatel(priv, PHYREG32_SSC_MASK, rockchip_combphy_updatel(priv, PHYREG32_SSC_MASK,
...@@ -736,6 +760,12 @@ static const struct rockchip_combphy_grfcfg rk3588_combphy_grfcfgs = { ...@@ -736,6 +760,12 @@ static const struct rockchip_combphy_grfcfg rk3588_combphy_grfcfgs = {
}; };
static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = { static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = {
.num_phys = 3,
.phy_ids = {
0xfee00000,
0xfee10000,
0xfee20000,
},
.grfcfg = &rk3588_combphy_grfcfgs, .grfcfg = &rk3588_combphy_grfcfgs,
.combphy_cfg = rk3588_combphy_cfg, .combphy_cfg = rk3588_combphy_cfg,
}; };
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#define RK3588_BIFURCATION_LANE_0_1 BIT(0) #define RK3588_BIFURCATION_LANE_0_1 BIT(0)
#define RK3588_BIFURCATION_LANE_2_3 BIT(1) #define RK3588_BIFURCATION_LANE_2_3 BIT(1)
#define RK3588_LANE_AGGREGATION BIT(2) #define RK3588_LANE_AGGREGATION BIT(2)
#define RK3588_PCIE1LN_SEL_EN (GENMASK(1, 0) << 16)
#define RK3588_PCIE30_PHY_MODE_EN (GENMASK(2, 0) << 16)
struct rockchip_p3phy_ops; struct rockchip_p3phy_ops;
...@@ -132,7 +134,7 @@ static const struct rockchip_p3phy_ops rk3568_ops = { ...@@ -132,7 +134,7 @@ static const struct rockchip_p3phy_ops rk3568_ops = {
static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv) static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
{ {
u32 reg = 0; u32 reg = 0;
u8 mode = 0; u8 mode = RK3588_LANE_AGGREGATION; /* default */
int ret; int ret;
/* Deassert PCIe PMA output clamp mode */ /* Deassert PCIe PMA output clamp mode */
...@@ -140,31 +142,24 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv) ...@@ -140,31 +142,24 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
/* Set bifurcation if needed */ /* Set bifurcation if needed */
for (int i = 0; i < priv->num_lanes; i++) { for (int i = 0; i < priv->num_lanes; i++) {
if (!priv->lanes[i])
mode |= (BIT(i) << 3);
if (priv->lanes[i] > 1) if (priv->lanes[i] > 1)
mode |= (BIT(i) >> 1); mode &= ~RK3588_LANE_AGGREGATION;
} if (priv->lanes[i] == 3)
mode |= RK3588_BIFURCATION_LANE_0_1;
if (!mode) if (priv->lanes[i] == 4)
reg = RK3588_LANE_AGGREGATION; mode |= RK3588_BIFURCATION_LANE_2_3;
else {
if (mode & (BIT(0) | BIT(1)))
reg |= RK3588_BIFURCATION_LANE_0_1;
if (mode & (BIT(2) | BIT(3)))
reg |= RK3588_BIFURCATION_LANE_2_3;
} }
regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0, (0x7<<16) | reg); reg = mode;
regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0,
RK3588_PCIE30_PHY_MODE_EN | reg);
/* Set pcie1ln_sel in PHP_GRF_PCIESEL_CON */ /* Set pcie1ln_sel in PHP_GRF_PCIESEL_CON */
if (!IS_ERR(priv->pipe_grf)) { if (!IS_ERR(priv->pipe_grf)) {
reg = (mode & (BIT(6) | BIT(7))) >> 6; reg = mode & (RK3588_BIFURCATION_LANE_0_1 | RK3588_BIFURCATION_LANE_2_3);
if (reg) if (reg)
regmap_write(priv->pipe_grf, PHP_GRF_PCIESEL_CON, regmap_write(priv->pipe_grf, PHP_GRF_PCIESEL_CON,
(reg << 16) | reg); RK3588_PCIE1LN_SEL_EN | reg);
} }
reset_control_deassert(priv->p30phy); reset_control_deassert(priv->p30phy);
......
...@@ -69,7 +69,6 @@ struct tusb1210 { ...@@ -69,7 +69,6 @@ struct tusb1210 {
struct delayed_work chg_det_work; struct delayed_work chg_det_work;
struct notifier_block psy_nb; struct notifier_block psy_nb;
struct power_supply *psy; struct power_supply *psy;
struct power_supply *charger;
#endif #endif
}; };
...@@ -236,19 +235,24 @@ static const char * const tusb1210_chargers[] = { ...@@ -236,19 +235,24 @@ static const char * const tusb1210_chargers[] = {
static bool tusb1210_get_online(struct tusb1210 *tusb) static bool tusb1210_get_online(struct tusb1210 *tusb)
{ {
struct power_supply *charger = NULL;
union power_supply_propval val; union power_supply_propval val;
int i; bool online = false;
int i, ret;
for (i = 0; i < ARRAY_SIZE(tusb1210_chargers) && !tusb->charger; i++) for (i = 0; i < ARRAY_SIZE(tusb1210_chargers) && !charger; i++)
tusb->charger = power_supply_get_by_name(tusb1210_chargers[i]); charger = power_supply_get_by_name(tusb1210_chargers[i]);
if (!tusb->charger) if (!charger)
return false; return false;
if (power_supply_get_property(tusb->charger, POWER_SUPPLY_PROP_ONLINE, &val)) ret = power_supply_get_property(charger, POWER_SUPPLY_PROP_ONLINE, &val);
return false; if (ret == 0)
online = val.intval;
power_supply_put(charger);
return val.intval; return online;
} }
static void tusb1210_chg_det_work(struct work_struct *work) static void tusb1210_chg_det_work(struct work_struct *work)
...@@ -473,9 +477,6 @@ static void tusb1210_remove_charger_detect(struct tusb1210 *tusb) ...@@ -473,9 +477,6 @@ static void tusb1210_remove_charger_detect(struct tusb1210 *tusb)
cancel_delayed_work_sync(&tusb->chg_det_work); cancel_delayed_work_sync(&tusb->chg_det_work);
power_supply_unregister(tusb->psy); power_supply_unregister(tusb->psy);
} }
if (tusb->charger)
power_supply_put(tusb->charger);
} }
#else #else
static void tusb1210_probe_charger_detect(struct tusb1210 *tusb) { } static void tusb1210_probe_charger_detect(struct tusb1210 *tusb) { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment