Skip to content

Commit 9ccdcc7

Browse files
committed
Merge tag 'phy-fixes-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy into char-misc-next
Vinod writes: phy: fixes for 5.17 Fixes for bunch of drivers: - clk params for dphy - arg fix for mtk-tphy - refcount leak fix for stm32 - bus width fix for zynqmp - sentinel fix ti - PHY_BRCM_USB Kconfig fix - clk fix for usb phy * tag 'phy-fixes-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: phy: dphy: Correct clk_pre parameter phy: phy-mtk-tphy: Fix duplicated argument in phy-mtk-tphy phy: stm32: fix a refcount leak in stm32_usbphyc_pll_enable() phy: xilinx: zynqmp: Fix bus width setting for SGMII phy: cadence: Sierra: fix error handling bugs in probe() phy: ti: Fix missing sentinel for clk_div_table phy: broadcom: Kconfig: Fix PHY_BRCM_USB config option phy: usb: Leave some clocks running during suspend
2 parents c0689e4 + 9a8406b commit 9ccdcc7

File tree

11 files changed

+80
-34
lines changed

11 files changed

+80
-34
lines changed

drivers/gpu/drm/bridge/nwl-dsi.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/bitfield.h>
10+
#include <linux/bits.h>
1011
#include <linux/clk.h>
1112
#include <linux/irq.h>
1213
#include <linux/math64.h>
@@ -196,12 +197,9 @@ static u32 ps2bc(struct nwl_dsi *dsi, unsigned long long ps)
196197
/*
197198
* ui2bc - UI time periods to byte clock cycles
198199
*/
199-
static u32 ui2bc(struct nwl_dsi *dsi, unsigned long long ui)
200+
static u32 ui2bc(unsigned int ui)
200201
{
201-
u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
202-
203-
return DIV64_U64_ROUND_UP(ui * dsi->lanes,
204-
dsi->mode.clock * 1000 * bpp);
202+
return DIV_ROUND_UP(ui, BITS_PER_BYTE);
205203
}
206204

207205
/*
@@ -232,12 +230,12 @@ static int nwl_dsi_config_host(struct nwl_dsi *dsi)
232230
}
233231

234232
/* values in byte clock cycles */
235-
cycles = ui2bc(dsi, cfg->clk_pre);
233+
cycles = ui2bc(cfg->clk_pre);
236234
DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_t_pre: 0x%x\n", cycles);
237235
nwl_dsi_write(dsi, NWL_DSI_CFG_T_PRE, cycles);
238236
cycles = ps2bc(dsi, cfg->lpx + cfg->clk_prepare + cfg->clk_zero);
239237
DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_tx_gap (pre): 0x%x\n", cycles);
240-
cycles += ui2bc(dsi, cfg->clk_pre);
238+
cycles += ui2bc(cfg->clk_pre);
241239
DRM_DEV_DEBUG_DRIVER(dsi->dev, "cfg_t_post: 0x%x\n", cycles);
242240
nwl_dsi_write(dsi, NWL_DSI_CFG_T_POST, cycles);
243241
cycles = ps2bc(dsi, cfg->hs_exit);

drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/bitfield.h>
1111
#include <linux/bitops.h>
12+
#include <linux/bits.h>
1213
#include <linux/clk.h>
1314
#include <linux/delay.h>
1415
#include <linux/io.h>
@@ -250,7 +251,7 @@ static int phy_meson_axg_mipi_dphy_power_on(struct phy *phy)
250251
(DIV_ROUND_UP(priv->config.clk_zero, temp) << 16) |
251252
(DIV_ROUND_UP(priv->config.clk_prepare, temp) << 24));
252253
regmap_write(priv->regmap, MIPI_DSI_CLK_TIM1,
253-
DIV_ROUND_UP(priv->config.clk_pre, temp));
254+
DIV_ROUND_UP(priv->config.clk_pre, BITS_PER_BYTE));
254255

255256
regmap_write(priv->regmap, MIPI_DSI_HS_TIM,
256257
DIV_ROUND_UP(priv->config.hs_exit, temp) |

drivers/phy/broadcom/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ config PHY_BRCM_USB
9797
depends on OF
9898
select GENERIC_PHY
9999
select SOC_BRCMSTB if ARCH_BRCMSTB
100-
default ARCH_BCM4908
101-
default ARCH_BRCMSTB
100+
default ARCH_BCM4908 || ARCH_BRCMSTB
102101
help
103102
Enable this to support the Broadcom STB USB PHY.
104103
This driver is required by the USB XHCI, EHCI and OHCI

drivers/phy/broadcom/phy-brcm-usb.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/soc/brcmstb/brcmstb.h>
1919
#include <dt-bindings/phy/phy.h>
2020
#include <linux/mfd/syscon.h>
21+
#include <linux/suspend.h>
2122

2223
#include "phy-brcm-usb-init.h"
2324

@@ -70,12 +71,35 @@ struct brcm_usb_phy_data {
7071
int init_count;
7172
int wake_irq;
7273
struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX];
74+
struct notifier_block pm_notifier;
75+
bool pm_active;
7376
};
7477

7578
static s8 *node_reg_names[BRCM_REGS_MAX] = {
7679
"crtl", "xhci_ec", "xhci_gbl", "usb_phy", "usb_mdio", "bdc_ec"
7780
};
7881

82+
static int brcm_pm_notifier(struct notifier_block *notifier,
83+
unsigned long pm_event,
84+
void *unused)
85+
{
86+
struct brcm_usb_phy_data *priv =
87+
container_of(notifier, struct brcm_usb_phy_data, pm_notifier);
88+
89+
switch (pm_event) {
90+
case PM_HIBERNATION_PREPARE:
91+
case PM_SUSPEND_PREPARE:
92+
priv->pm_active = true;
93+
break;
94+
case PM_POST_RESTORE:
95+
case PM_POST_HIBERNATION:
96+
case PM_POST_SUSPEND:
97+
priv->pm_active = false;
98+
break;
99+
}
100+
return NOTIFY_DONE;
101+
}
102+
79103
static irqreturn_t brcm_usb_phy_wake_isr(int irq, void *dev_id)
80104
{
81105
struct phy *gphy = dev_id;
@@ -91,6 +115,9 @@ static int brcm_usb_phy_init(struct phy *gphy)
91115
struct brcm_usb_phy_data *priv =
92116
container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
93117

118+
if (priv->pm_active)
119+
return 0;
120+
94121
/*
95122
* Use a lock to make sure a second caller waits until
96123
* the base phy is inited before using it.
@@ -120,6 +147,9 @@ static int brcm_usb_phy_exit(struct phy *gphy)
120147
struct brcm_usb_phy_data *priv =
121148
container_of(phy, struct brcm_usb_phy_data, phys[phy->id]);
122149

150+
if (priv->pm_active)
151+
return 0;
152+
123153
dev_dbg(&gphy->dev, "EXIT\n");
124154
if (phy->id == BRCM_USB_PHY_2_0)
125155
brcm_usb_uninit_eohci(&priv->ini);
@@ -488,6 +518,9 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
488518
if (err)
489519
return err;
490520

521+
priv->pm_notifier.notifier_call = brcm_pm_notifier;
522+
register_pm_notifier(&priv->pm_notifier);
523+
491524
mutex_init(&priv->mutex);
492525

493526
/* make sure invert settings are correct */
@@ -528,7 +561,10 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
528561

529562
static int brcm_usb_phy_remove(struct platform_device *pdev)
530563
{
564+
struct brcm_usb_phy_data *priv = dev_get_drvdata(&pdev->dev);
565+
531566
sysfs_remove_group(&pdev->dev.kobj, &brcm_usb_phy_group);
567+
unregister_pm_notifier(&priv->pm_notifier);
532568

533569
return 0;
534570
}
@@ -539,6 +575,7 @@ static int brcm_usb_phy_suspend(struct device *dev)
539575
struct brcm_usb_phy_data *priv = dev_get_drvdata(dev);
540576

541577
if (priv->init_count) {
578+
dev_dbg(dev, "SUSPEND\n");
542579
priv->ini.wake_enabled = device_may_wakeup(dev);
543580
if (priv->phys[BRCM_USB_PHY_3_0].inited)
544581
brcm_usb_uninit_xhci(&priv->ini);
@@ -578,6 +615,7 @@ static int brcm_usb_phy_resume(struct device *dev)
578615
* Uninitialize anything that wasn't previously initialized.
579616
*/
580617
if (priv->init_count) {
618+
dev_dbg(dev, "RESUME\n");
581619
if (priv->wake_irq >= 0)
582620
disable_irq_wake(priv->wake_irq);
583621
brcm_usb_init_common(&priv->ini);

drivers/phy/cadence/phy-cadence-sierra.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
13381338
struct device *dev = &pdev->dev;
13391339
const struct cdns_sierra_data *data;
13401340
unsigned int id_value;
1341-
int i, ret, node = 0;
1341+
int ret, node = 0;
13421342
void __iomem *base;
13431343
struct device_node *dn = dev->of_node, *child;
13441344

@@ -1416,15 +1416,18 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
14161416
dev_err(dev, "failed to get reset %s\n",
14171417
child->full_name);
14181418
ret = PTR_ERR(sp->phys[node].lnk_rst);
1419-
goto put_child2;
1419+
of_node_put(child);
1420+
goto put_control;
14201421
}
14211422

14221423
if (!sp->autoconf) {
14231424
ret = cdns_sierra_get_optional(&sp->phys[node], child);
14241425
if (ret) {
14251426
dev_err(dev, "missing property in node %s\n",
14261427
child->name);
1427-
goto put_child;
1428+
of_node_put(child);
1429+
reset_control_put(sp->phys[node].lnk_rst);
1430+
goto put_control;
14281431
}
14291432
}
14301433

@@ -1434,7 +1437,9 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
14341437

14351438
if (IS_ERR(gphy)) {
14361439
ret = PTR_ERR(gphy);
1437-
goto put_child;
1440+
of_node_put(child);
1441+
reset_control_put(sp->phys[node].lnk_rst);
1442+
goto put_control;
14381443
}
14391444
sp->phys[node].phy = gphy;
14401445
phy_set_drvdata(gphy, &sp->phys[node]);
@@ -1446,26 +1451,28 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev)
14461451
if (sp->num_lanes > SIERRA_MAX_LANES) {
14471452
ret = -EINVAL;
14481453
dev_err(dev, "Invalid lane configuration\n");
1449-
goto put_child2;
1454+
goto put_control;
14501455
}
14511456

14521457
/* If more than one subnode, configure the PHY as multilink */
14531458
if (!sp->autoconf && sp->nsubnodes > 1) {
14541459
ret = cdns_sierra_phy_configure_multilink(sp);
14551460
if (ret)
1456-
goto put_child2;
1461+
goto put_control;
14571462
}
14581463

14591464
pm_runtime_enable(dev);
14601465
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
1461-
return PTR_ERR_OR_ZERO(phy_provider);
1462-
1463-
put_child:
1464-
node++;
1465-
put_child2:
1466-
for (i = 0; i < node; i++)
1467-
reset_control_put(sp->phys[i].lnk_rst);
1468-
of_node_put(child);
1466+
if (IS_ERR(phy_provider)) {
1467+
ret = PTR_ERR(phy_provider);
1468+
goto put_control;
1469+
}
1470+
1471+
return 0;
1472+
1473+
put_control:
1474+
while (--node >= 0)
1475+
reset_control_put(sp->phys[node].lnk_rst);
14691476
clk_disable:
14701477
cdns_sierra_phy_disable_clocks(sp);
14711478
reset_control_assert(sp->apb_rst);

drivers/phy/mediatek/phy-mtk-tphy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ static int phy_efuse_get(struct mtk_tphy *tphy, struct mtk_phy_instance *instanc
992992
/* no efuse, ignore it */
993993
if (!instance->efuse_intr &&
994994
!instance->efuse_rx_imp &&
995-
!instance->efuse_rx_imp) {
995+
!instance->efuse_tx_imp) {
996996
dev_warn(dev, "no u3 intr efuse, but dts enable it\n");
997997
instance->efuse_sw_en = 0;
998998
break;

drivers/phy/phy-core-mipi-dphy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock,
3636

3737
cfg->clk_miss = 0;
3838
cfg->clk_post = 60000 + 52 * ui;
39-
cfg->clk_pre = 8000;
39+
cfg->clk_pre = 8;
4040
cfg->clk_prepare = 38000;
4141
cfg->clk_settle = 95000;
4242
cfg->clk_term_en = 0;
@@ -97,7 +97,7 @@ int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg)
9797
if (cfg->clk_post < (60000 + 52 * ui))
9898
return -EINVAL;
9999

100-
if (cfg->clk_pre < 8000)
100+
if (cfg->clk_pre < 8)
101101
return -EINVAL;
102102

103103
if (cfg->clk_prepare < 38000 || cfg->clk_prepare > 95000)

drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Author: Wyon Bi <[email protected]>
66
*/
77

8+
#include <linux/bits.h>
89
#include <linux/kernel.h>
910
#include <linux/clk.h>
1011
#include <linux/iopoll.h>
@@ -364,7 +365,7 @@ static void inno_dsidphy_mipi_mode_enable(struct inno_dsidphy *inno)
364365
* The value of counter for HS Tclk-pre
365366
* Tclk-pre = Tpin_txbyteclkhs * value
366367
*/
367-
clk_pre = DIV_ROUND_UP(cfg->clk_pre, t_txbyteclkhs);
368+
clk_pre = DIV_ROUND_UP(cfg->clk_pre, BITS_PER_BYTE);
368369

369370
/*
370371
* The value of counter for HS Tlpx Time

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static int stm32_usbphyc_pll_enable(struct stm32_usbphyc *usbphyc)
304304

305305
ret = __stm32_usbphyc_pll_disable(usbphyc);
306306
if (ret)
307-
return ret;
307+
goto dec_n_pll_cons;
308308
}
309309

310310
ret = stm32_usbphyc_regulators_enable(usbphyc);

drivers/phy/ti/phy-j721e-wiz.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static const struct clk_div_table clk_div_table[] = {
233233
{ .val = 1, .div = 2, },
234234
{ .val = 2, .div = 4, },
235235
{ .val = 3, .div = 8, },
236+
{ /* sentinel */ },
236237
};
237238

238239
static const struct wiz_clk_div_sel clk_div_sel[] = {

0 commit comments

Comments
 (0)