Skip to content

Commit adc4bd6

Browse files
committed
phy: cadence: Sierra: Check for PLL lock during PHY power on
Check for PLL lock during PHY power on. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
1 parent b872936 commit adc4bd6

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
5656
#define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
5757
#define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F
58+
#define SIERRA_PLLCTRL_STATUS_PREG 0x044
5859
#define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B
5960
#define SIERRA_DFE_BIASTRIM_PREG 0x04C
6061
#define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
@@ -141,11 +142,14 @@
141142

142143
#define SIERRA_MACRO_ID 0x00007364
143144
#define SIERRA_MAX_LANES 4
145+
#define PLL_LOCK_TIME 100000
144146

145147
static const struct reg_field macro_id_type =
146148
REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
147149
static const struct reg_field phy_pll_cfg_1 =
148150
REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
151+
static const struct reg_field pllctrl_lock =
152+
REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
149153

150154
struct cdns_sierra_inst {
151155
struct phy *phy;
@@ -192,6 +196,7 @@ struct cdns_sierra_phy {
192196
struct regmap *regmap_common_cdb;
193197
struct regmap_field *macro_id_type;
194198
struct regmap_field *phy_pll_cfg_1;
199+
struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
195200
struct clk *clk;
196201
int nsubnodes;
197202
bool autoconf;
@@ -291,10 +296,25 @@ static int cdns_sierra_phy_init(struct phy *gphy)
291296

292297
static int cdns_sierra_phy_on(struct phy *gphy)
293298
{
299+
struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
294300
struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
301+
struct device *dev = sp->dev;
302+
u32 val;
303+
int ret;
295304

296305
/* Take the PHY lane group out of reset */
297-
return reset_control_deassert(ins->lnk_rst);
306+
ret = reset_control_deassert(ins->lnk_rst);
307+
if (ret) {
308+
dev_err(dev, "Failed to take the PHY lane out of reset\n");
309+
return ret;
310+
}
311+
312+
ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
313+
val, val, 1000, PLL_LOCK_TIME);
314+
if (ret < 0)
315+
dev_err(dev, "PLL lock of lane failed\n");
316+
317+
return ret;
298318
}
299319

300320
static int cdns_sierra_phy_off(struct phy *gphy)
@@ -350,6 +370,7 @@ static int cdns_regfield_init(struct cdns_sierra_phy *sp)
350370
struct device *dev = sp->dev;
351371
struct regmap_field *field;
352372
struct regmap *regmap;
373+
int i;
353374

354375
regmap = sp->regmap_common_cdb;
355376
field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
@@ -367,6 +388,16 @@ static int cdns_regfield_init(struct cdns_sierra_phy *sp)
367388
}
368389
sp->phy_pll_cfg_1 = field;
369390

391+
for (i = 0; i < SIERRA_MAX_LANES; i++) {
392+
regmap = sp->regmap_lane_cdb[i];
393+
field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
394+
if (IS_ERR(field)) {
395+
dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
396+
return PTR_ERR(field);
397+
}
398+
sp->pllctrl_lock[i] = field;
399+
}
400+
370401
return 0;
371402
}
372403

0 commit comments

Comments
 (0)