Skip to content

Commit 53c8621

Browse files
committed
Merge tag 'phy-fixes-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy
Pull phy fixes from Vinod Koul: - Out of bound fix for hisilicon phy - Qualcomm synopsis femto phy for keeping clock enabled during suspend and enabling ref clocks - Mediatek driver fixes for upper limit test and error code * tag 'phy-fixes-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: phy: hisilicon: Fix an out of bounds check in hisi_inno_phy_probe() phy: qcom-snps-femto-v2: use qcom_snps_hsphy_suspend/resume error code phy: qcom-snps-femto-v2: properly enable ref clock phy: qcom-snps-femto-v2: keep cfg_ahb_clk enabled during runtime suspend phy: mediatek: hdmi: mt8195: fix prediv bad upper limit test phy: phy-mtk-dp: Fix an error code in probe()
2 parents 64de76c + 13c088c commit 53c8621

File tree

4 files changed

+53
-31
lines changed

4 files changed

+53
-31
lines changed

drivers/phy/hisilicon/phy-hisi-inno-usb2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
184184
phy_set_drvdata(phy, &priv->ports[i]);
185185
i++;
186186

187-
if (i > INNO_PHY_PORT_NUM) {
187+
if (i >= INNO_PHY_PORT_NUM) {
188188
dev_warn(dev, "Support %d ports in maximum\n", i);
189189
of_node_put(child);
190190
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int mtk_dp_phy_probe(struct platform_device *pdev)
169169

170170
regs = *(struct regmap **)dev->platform_data;
171171
if (!regs)
172-
return dev_err_probe(dev, EINVAL,
172+
return dev_err_probe(dev, -EINVAL,
173173
"No data passed, requires struct regmap**\n");
174174

175175
dp_phy = devm_kzalloc(dev, sizeof(*dp_phy), GFP_KERNEL);

drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw,
253253
for (i = 0; i < ARRAY_SIZE(txpredivs); i++) {
254254
ns_hdmipll_ck = 5 * tmds_clk * txposdiv * txpredivs[i];
255255
if (ns_hdmipll_ck >= 5 * GIGA &&
256-
ns_hdmipll_ck <= 1 * GIGA)
256+
ns_hdmipll_ck <= 12 * GIGA)
257257
break;
258258
}
259259
if (i == (ARRAY_SIZE(txpredivs) - 1) &&

drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,27 @@ struct phy_override_seq {
110110
/**
111111
* struct qcom_snps_hsphy - snps hs phy attributes
112112
*
113+
* @dev: device structure
114+
*
113115
* @phy: generic phy
114116
* @base: iomapped memory space for snps hs phy
115117
*
116-
* @cfg_ahb_clk: AHB2PHY interface clock
117-
* @ref_clk: phy reference clock
118+
* @num_clks: number of clocks
119+
* @clks: array of clocks
118120
* @phy_reset: phy reset control
119121
* @vregs: regulator supplies bulk data
120122
* @phy_initialized: if PHY has been initialized correctly
121123
* @mode: contains the current mode the PHY is in
122124
* @update_seq_cfg: tuning parameters for phy init
123125
*/
124126
struct qcom_snps_hsphy {
127+
struct device *dev;
128+
125129
struct phy *phy;
126130
void __iomem *base;
127131

128-
struct clk *cfg_ahb_clk;
129-
struct clk *ref_clk;
132+
int num_clks;
133+
struct clk_bulk_data *clks;
130134
struct reset_control *phy_reset;
131135
struct regulator_bulk_data vregs[SNPS_HS_NUM_VREGS];
132136

@@ -135,6 +139,34 @@ struct qcom_snps_hsphy {
135139
struct phy_override_seq update_seq_cfg[NUM_HSPHY_TUNING_PARAMS];
136140
};
137141

142+
static int qcom_snps_hsphy_clk_init(struct qcom_snps_hsphy *hsphy)
143+
{
144+
struct device *dev = hsphy->dev;
145+
146+
hsphy->num_clks = 2;
147+
hsphy->clks = devm_kcalloc(dev, hsphy->num_clks, sizeof(*hsphy->clks), GFP_KERNEL);
148+
if (!hsphy->clks)
149+
return -ENOMEM;
150+
151+
/*
152+
* TODO: Currently no device tree instantiation of the PHY is using the clock.
153+
* This needs to be fixed in order for this code to be able to use devm_clk_bulk_get().
154+
*/
155+
hsphy->clks[0].id = "cfg_ahb";
156+
hsphy->clks[0].clk = devm_clk_get_optional(dev, "cfg_ahb");
157+
if (IS_ERR(hsphy->clks[0].clk))
158+
return dev_err_probe(dev, PTR_ERR(hsphy->clks[0].clk),
159+
"failed to get cfg_ahb clk\n");
160+
161+
hsphy->clks[1].id = "ref";
162+
hsphy->clks[1].clk = devm_clk_get(dev, "ref");
163+
if (IS_ERR(hsphy->clks[1].clk))
164+
return dev_err_probe(dev, PTR_ERR(hsphy->clks[1].clk),
165+
"failed to get ref clk\n");
166+
167+
return 0;
168+
}
169+
138170
static inline void qcom_snps_hsphy_write_mask(void __iomem *base, u32 offset,
139171
u32 mask, u32 val)
140172
{
@@ -165,22 +197,13 @@ static int qcom_snps_hsphy_suspend(struct qcom_snps_hsphy *hsphy)
165197
0, USB2_AUTO_RESUME);
166198
}
167199

168-
clk_disable_unprepare(hsphy->cfg_ahb_clk);
169200
return 0;
170201
}
171202

172203
static int qcom_snps_hsphy_resume(struct qcom_snps_hsphy *hsphy)
173204
{
174-
int ret;
175-
176205
dev_dbg(&hsphy->phy->dev, "Resume QCOM SNPS PHY, mode\n");
177206

178-
ret = clk_prepare_enable(hsphy->cfg_ahb_clk);
179-
if (ret) {
180-
dev_err(&hsphy->phy->dev, "failed to enable cfg ahb clock\n");
181-
return ret;
182-
}
183-
184207
return 0;
185208
}
186209

@@ -191,8 +214,7 @@ static int __maybe_unused qcom_snps_hsphy_runtime_suspend(struct device *dev)
191214
if (!hsphy->phy_initialized)
192215
return 0;
193216

194-
qcom_snps_hsphy_suspend(hsphy);
195-
return 0;
217+
return qcom_snps_hsphy_suspend(hsphy);
196218
}
197219

198220
static int __maybe_unused qcom_snps_hsphy_runtime_resume(struct device *dev)
@@ -202,8 +224,7 @@ static int __maybe_unused qcom_snps_hsphy_runtime_resume(struct device *dev)
202224
if (!hsphy->phy_initialized)
203225
return 0;
204226

205-
qcom_snps_hsphy_resume(hsphy);
206-
return 0;
227+
return qcom_snps_hsphy_resume(hsphy);
207228
}
208229

209230
static int qcom_snps_hsphy_set_mode(struct phy *phy, enum phy_mode mode,
@@ -374,24 +395,24 @@ static int qcom_snps_hsphy_init(struct phy *phy)
374395
if (ret)
375396
return ret;
376397

377-
ret = clk_prepare_enable(hsphy->cfg_ahb_clk);
398+
ret = clk_bulk_prepare_enable(hsphy->num_clks, hsphy->clks);
378399
if (ret) {
379-
dev_err(&phy->dev, "failed to enable cfg ahb clock, %d\n", ret);
400+
dev_err(&phy->dev, "failed to enable clocks, %d\n", ret);
380401
goto poweroff_phy;
381402
}
382403

383404
ret = reset_control_assert(hsphy->phy_reset);
384405
if (ret) {
385406
dev_err(&phy->dev, "failed to assert phy_reset, %d\n", ret);
386-
goto disable_ahb_clk;
407+
goto disable_clks;
387408
}
388409

389410
usleep_range(100, 150);
390411

391412
ret = reset_control_deassert(hsphy->phy_reset);
392413
if (ret) {
393414
dev_err(&phy->dev, "failed to de-assert phy_reset, %d\n", ret);
394-
goto disable_ahb_clk;
415+
goto disable_clks;
395416
}
396417

397418
qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_CFG0,
@@ -448,8 +469,8 @@ static int qcom_snps_hsphy_init(struct phy *phy)
448469

449470
return 0;
450471

451-
disable_ahb_clk:
452-
clk_disable_unprepare(hsphy->cfg_ahb_clk);
472+
disable_clks:
473+
clk_bulk_disable_unprepare(hsphy->num_clks, hsphy->clks);
453474
poweroff_phy:
454475
regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs);
455476

@@ -461,7 +482,7 @@ static int qcom_snps_hsphy_exit(struct phy *phy)
461482
struct qcom_snps_hsphy *hsphy = phy_get_drvdata(phy);
462483

463484
reset_control_assert(hsphy->phy_reset);
464-
clk_disable_unprepare(hsphy->cfg_ahb_clk);
485+
clk_bulk_disable_unprepare(hsphy->num_clks, hsphy->clks);
465486
regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs);
466487
hsphy->phy_initialized = false;
467488

@@ -554,14 +575,15 @@ static int qcom_snps_hsphy_probe(struct platform_device *pdev)
554575
if (!hsphy)
555576
return -ENOMEM;
556577

578+
hsphy->dev = dev;
579+
557580
hsphy->base = devm_platform_ioremap_resource(pdev, 0);
558581
if (IS_ERR(hsphy->base))
559582
return PTR_ERR(hsphy->base);
560583

561-
hsphy->ref_clk = devm_clk_get(dev, "ref");
562-
if (IS_ERR(hsphy->ref_clk))
563-
return dev_err_probe(dev, PTR_ERR(hsphy->ref_clk),
564-
"failed to get ref clk\n");
584+
ret = qcom_snps_hsphy_clk_init(hsphy);
585+
if (ret)
586+
return dev_err_probe(dev, ret, "failed to initialize clocks\n");
565587

566588
hsphy->phy_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL);
567589
if (IS_ERR(hsphy->phy_reset)) {

0 commit comments

Comments
 (0)