Skip to content

Commit a760b10

Browse files
committed
Merge tag 'phy-fixes-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy
Pull phy fixes from Vinod Koul: - rockchip phy kconfig dependency fix with USB_COMMON and regression fix for old DT - stm32 phy overflow assertion fix - exonysfs phy refclk masks fix and power gate on exit fix - freescale fix for clock dividor valid range - TI regmap syscon register fix - tegra reset registers on init fix * tag 'phy-fixes-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: phy: tegra: xusb: reset VBUS & ID OVERRIDE phy: ti: gmii-sel: Do not use syscon helper to build regmap phy: exynos5-usbdrd: gs101: ensure power is gated to SS phy in phy_exit() phy: freescale: fsl-samsung-hdmi: Limit PLL lock detection clock divider to valid range phy: exynos5-usbdrd: fix MPLL_MULTIPLIER and SSC_REFCLKSEL masks in refclk phy: stm32: Fix constant-value overflow assertion phy: rockchip: naneng-combphy: compatible reset with old DT phy: rockchip: fix Kconfig dependency more
2 parents 1973160 + 55f1a5f commit a760b10

File tree

7 files changed

+73
-35
lines changed

7 files changed

+73
-35
lines changed

drivers/phy/freescale/phy-fsl-samsung-hdmi.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ to_fsl_samsung_hdmi_phy(struct clk_hw *hw)
325325
return container_of(hw, struct fsl_samsung_hdmi_phy, hw);
326326
}
327327

328-
static void
328+
static int
329329
fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
330330
const struct phy_config *cfg)
331331
{
@@ -341,6 +341,9 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
341341
break;
342342
}
343343

344+
if (unlikely(div == 4))
345+
return -EINVAL;
346+
344347
writeb(FIELD_PREP(REG12_CK_DIV_MASK, div), phy->regs + PHY_REG(12));
345348

346349
/*
@@ -364,6 +367,8 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
364367
FIELD_PREP(REG14_RP_CODE_MASK, 2) |
365368
FIELD_PREP(REG14_TG_CODE_HIGH_MASK, fld_tg_code >> 8),
366369
phy->regs + PHY_REG(14));
370+
371+
return 0;
367372
}
368373

369374
static unsigned long fsl_samsung_hdmi_phy_find_pms(unsigned long fout, u8 *p, u16 *m, u8 *s)
@@ -466,7 +471,11 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,
466471
writeb(REG21_SEL_TX_CK_INV | FIELD_PREP(REG21_PMS_S_MASK,
467472
cfg->pll_div_regs[2] >> 4), phy->regs + PHY_REG(21));
468473

469-
fsl_samsung_hdmi_phy_configure_pll_lock_det(phy, cfg);
474+
ret = fsl_samsung_hdmi_phy_configure_pll_lock_det(phy, cfg);
475+
if (ret) {
476+
dev_err(phy->dev, "pixclock too large\n");
477+
return ret;
478+
}
470479

471480
writeb(REG33_FIX_DA | REG33_MODE_SET_DONE, phy->regs + PHY_REG(33));
472481

drivers/phy/rockchip/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ config PHY_ROCKCHIP_USBDP
125125
depends on ARCH_ROCKCHIP && OF
126126
depends on TYPEC
127127
select GENERIC_PHY
128+
select USB_COMMON
128129
help
129130
Enable this to support the Rockchip USB3.0/DP combo PHY with
130131
Samsung IP block. This is required for USB3 support on RK3588.

drivers/phy/rockchip/phy-rockchip-naneng-combphy.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ static int rockchip_combphy_parse_dt(struct device *dev, struct rockchip_combphy
324324

325325
priv->ext_refclk = device_property_present(dev, "rockchip,ext-refclk");
326326

327-
priv->phy_rst = devm_reset_control_get(dev, "phy");
327+
priv->phy_rst = devm_reset_control_get_exclusive(dev, "phy");
328+
/* fallback to old behaviour */
329+
if (PTR_ERR(priv->phy_rst) == -ENOENT)
330+
priv->phy_rst = devm_reset_control_array_get_exclusive(dev);
328331
if (IS_ERR(priv->phy_rst))
329332
return dev_err_probe(dev, PTR_ERR(priv->phy_rst), "failed to get phy reset\n");
330333

drivers/phy/samsung/phy-exynos5-usbdrd.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ exynos5_usbdrd_pipe3_set_refclk(struct phy_usb_instance *inst)
488488
reg |= PHYCLKRST_REFCLKSEL_EXT_REFCLK;
489489

490490
/* FSEL settings corresponding to reference clock */
491-
reg &= ~PHYCLKRST_FSEL_PIPE_MASK |
492-
PHYCLKRST_MPLL_MULTIPLIER_MASK |
493-
PHYCLKRST_SSC_REFCLKSEL_MASK;
491+
reg &= ~(PHYCLKRST_FSEL_PIPE_MASK |
492+
PHYCLKRST_MPLL_MULTIPLIER_MASK |
493+
PHYCLKRST_SSC_REFCLKSEL_MASK);
494494
switch (phy_drd->extrefclk) {
495495
case EXYNOS5_FSEL_50MHZ:
496496
reg |= (PHYCLKRST_MPLL_MULTIPLIER_50M_REF |
@@ -532,9 +532,9 @@ exynos5_usbdrd_utmi_set_refclk(struct phy_usb_instance *inst)
532532
reg &= ~PHYCLKRST_REFCLKSEL_MASK;
533533
reg |= PHYCLKRST_REFCLKSEL_EXT_REFCLK;
534534

535-
reg &= ~PHYCLKRST_FSEL_UTMI_MASK |
536-
PHYCLKRST_MPLL_MULTIPLIER_MASK |
537-
PHYCLKRST_SSC_REFCLKSEL_MASK;
535+
reg &= ~(PHYCLKRST_FSEL_UTMI_MASK |
536+
PHYCLKRST_MPLL_MULTIPLIER_MASK |
537+
PHYCLKRST_SSC_REFCLKSEL_MASK);
538538
reg |= PHYCLKRST_FSEL(phy_drd->extrefclk);
539539

540540
return reg;
@@ -1296,14 +1296,17 @@ static int exynos5_usbdrd_gs101_phy_exit(struct phy *phy)
12961296
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst);
12971297
int ret;
12981298

1299+
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) {
1300+
ret = exynos850_usbdrd_phy_exit(phy);
1301+
if (ret)
1302+
return ret;
1303+
}
1304+
1305+
exynos5_usbdrd_phy_isol(inst, true);
1306+
12991307
if (inst->phy_cfg->id != EXYNOS5_DRDPHY_UTMI)
13001308
return 0;
13011309

1302-
ret = exynos850_usbdrd_phy_exit(phy);
1303-
if (ret)
1304-
return ret;
1305-
1306-
exynos5_usbdrd_phy_isol(inst, true);
13071310
return regulator_bulk_disable(phy_drd->drv_data->n_regulators,
13081311
phy_drd->regulators);
13091312
}

drivers/phy/st/phy-stm32-combophy.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static const struct clk_impedance imp_lookup[] = {
111111
{ 4204000, { 511000, 609000, 706000, 802000 } },
112112
{ 3999000, { 571000, 648000, 726000, 803000 } }
113113
};
114+
#define DEFAULT_IMP_INDEX 3 /* Default impedance is 50 Ohm */
114115

115116
static int stm32_impedance_tune(struct stm32_combophy *combophy)
116117
{
@@ -119,56 +120,53 @@ static int stm32_impedance_tune(struct stm32_combophy *combophy)
119120
u8 imp_of, vswing_of;
120121
u32 max_imp = imp_lookup[0].microohm;
121122
u32 min_imp = imp_lookup[imp_size - 1].microohm;
122-
u32 max_vswing = imp_lookup[imp_size - 1].vswing[vswing_size - 1];
123+
u32 max_vswing;
123124
u32 min_vswing = imp_lookup[0].vswing[0];
124125
u32 val;
125-
u32 regval;
126126

127127
if (!of_property_read_u32(combophy->dev->of_node, "st,output-micro-ohms", &val)) {
128128
if (val < min_imp || val > max_imp) {
129129
dev_err(combophy->dev, "Invalid value %u for output ohm\n", val);
130130
return -EINVAL;
131131
}
132132

133-
regval = 0;
134-
for (imp_of = 0; imp_of < ARRAY_SIZE(imp_lookup); imp_of++) {
135-
if (imp_lookup[imp_of].microohm <= val) {
136-
regval = FIELD_PREP(STM32MP25_PCIEPRG_IMPCTRL_OHM, imp_of);
133+
for (imp_of = 0; imp_of < ARRAY_SIZE(imp_lookup); imp_of++)
134+
if (imp_lookup[imp_of].microohm <= val)
137135
break;
138-
}
139-
}
136+
137+
if (WARN_ON(imp_of == ARRAY_SIZE(imp_lookup)))
138+
return -EINVAL;
140139

141140
dev_dbg(combophy->dev, "Set %u micro-ohms output impedance\n",
142141
imp_lookup[imp_of].microohm);
143142

144143
regmap_update_bits(combophy->regmap, SYSCFG_PCIEPRGCR,
145144
STM32MP25_PCIEPRG_IMPCTRL_OHM,
146-
regval);
147-
} else {
148-
regmap_read(combophy->regmap, SYSCFG_PCIEPRGCR, &val);
149-
imp_of = FIELD_GET(STM32MP25_PCIEPRG_IMPCTRL_OHM, val);
150-
}
145+
FIELD_PREP(STM32MP25_PCIEPRG_IMPCTRL_OHM, imp_of));
146+
} else
147+
imp_of = DEFAULT_IMP_INDEX;
151148

152149
if (!of_property_read_u32(combophy->dev->of_node, "st,output-vswing-microvolt", &val)) {
150+
max_vswing = imp_lookup[imp_of].vswing[vswing_size - 1];
151+
153152
if (val < min_vswing || val > max_vswing) {
154153
dev_err(combophy->dev, "Invalid value %u for output vswing\n", val);
155154
return -EINVAL;
156155
}
157156

158-
regval = 0;
159-
for (vswing_of = 0; vswing_of < ARRAY_SIZE(imp_lookup[imp_of].vswing); vswing_of++) {
160-
if (imp_lookup[imp_of].vswing[vswing_of] >= val) {
161-
regval = FIELD_PREP(STM32MP25_PCIEPRG_IMPCTRL_VSWING, vswing_of);
157+
for (vswing_of = 0; vswing_of < ARRAY_SIZE(imp_lookup[imp_of].vswing); vswing_of++)
158+
if (imp_lookup[imp_of].vswing[vswing_of] >= val)
162159
break;
163-
}
164-
}
160+
161+
if (WARN_ON(vswing_of == ARRAY_SIZE(imp_lookup[imp_of].vswing)))
162+
return -EINVAL;
165163

166164
dev_dbg(combophy->dev, "Set %u microvolt swing\n",
167165
imp_lookup[imp_of].vswing[vswing_of]);
168166

169167
regmap_update_bits(combophy->regmap, SYSCFG_PCIEPRGCR,
170168
STM32MP25_PCIEPRG_IMPCTRL_VSWING,
171-
regval);
169+
FIELD_PREP(STM32MP25_PCIEPRG_IMPCTRL_VSWING, vswing_of));
172170
}
173171

174172
return 0;

drivers/phy/tegra/xusb-tegra186.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,24 @@ static int tegra186_utmi_phy_init(struct phy *phy)
928928
unsigned int index = lane->index;
929929
struct device *dev = padctl->dev;
930930
int err;
931+
u32 reg;
931932

932933
port = tegra_xusb_find_usb2_port(padctl, index);
933934
if (!port) {
934935
dev_err(dev, "no port found for USB2 lane %u\n", index);
935936
return -ENODEV;
936937
}
937938

939+
if (port->mode == USB_DR_MODE_OTG ||
940+
port->mode == USB_DR_MODE_PERIPHERAL) {
941+
/* reset VBUS&ID OVERRIDE */
942+
reg = padctl_readl(padctl, USB2_VBUS_ID);
943+
reg &= ~VBUS_OVERRIDE;
944+
reg &= ~ID_OVERRIDE(~0);
945+
reg |= ID_OVERRIDE_FLOATING;
946+
padctl_writel(padctl, reg, USB2_VBUS_ID);
947+
}
948+
938949
if (port->supply && port->mode == USB_DR_MODE_HOST) {
939950
err = regulator_enable(port->supply);
940951
if (err) {

drivers/phy/ti/phy-gmii-sel.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv)
424424
return 0;
425425
}
426426

427+
static const struct regmap_config phy_gmii_sel_regmap_cfg = {
428+
.reg_bits = 32,
429+
.val_bits = 32,
430+
.reg_stride = 4,
431+
};
432+
427433
static int phy_gmii_sel_probe(struct platform_device *pdev)
428434
{
429435
struct device *dev = &pdev->dev;
@@ -468,7 +474,14 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
468474

469475
priv->regmap = syscon_node_to_regmap(node->parent);
470476
if (IS_ERR(priv->regmap)) {
471-
priv->regmap = device_node_to_regmap(node);
477+
void __iomem *base;
478+
479+
base = devm_platform_ioremap_resource(pdev, 0);
480+
if (IS_ERR(base))
481+
return dev_err_probe(dev, PTR_ERR(base),
482+
"failed to get base memory resource\n");
483+
484+
priv->regmap = regmap_init_mmio(dev, base, &phy_gmii_sel_regmap_cfg);
472485
if (IS_ERR(priv->regmap))
473486
return dev_err_probe(dev, PTR_ERR(priv->regmap),
474487
"Failed to get syscon\n");

0 commit comments

Comments
 (0)