Skip to content

Commit 2604351

Browse files
Michael Rieschvinodkoul
authored andcommitted
phy: rockchip: phy-rockchip-inno-csidphy: allow for different reset lines
The RK3588 MIPI CSI-2 DPHY variant requires two reset lines. Add support for different sets of reset lines to the phy-rockchip-inno-csidphy driver as preparation for the introduction of the RK3588 variant. Signed-off-by: Michael Riesch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 8c7c194 commit 2604351

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
#define RK1808_CSIDPHY_CLK_CALIB_EN 0x168
6868
#define RK3568_CSIDPHY_CLK_CALIB_EN 0x168
6969

70+
#define RESETS_MAX 2
71+
7072
/*
7173
* The higher 16-bit of this register is used for write protection
7274
* only if BIT(x + 16) set to 1 the BIT(x) can be written.
@@ -127,14 +129,17 @@ struct dphy_drv_data {
127129
const struct hsfreq_range *hsfreq_ranges;
128130
int num_hsfreq_ranges;
129131
const struct dphy_reg *grf_regs;
132+
const char *const *resets;
133+
unsigned int resets_num;
130134
};
131135

132136
struct rockchip_inno_csidphy {
133137
struct device *dev;
134138
void __iomem *phy_base;
135139
struct clk *pclk;
136140
struct regmap *grf;
137-
struct reset_control *rst;
141+
struct reset_control_bulk_data resets[RESETS_MAX];
142+
unsigned int resets_num;
138143
const struct dphy_drv_data *drv_data;
139144
struct phy_configure_opts_mipi_dphy config;
140145
u8 hsfreq;
@@ -174,6 +179,10 @@ static const struct hsfreq_range rk3368_mipidphy_hsfreq_ranges[] = {
174179
{1249, 0x0c}, {1349, 0x0d}, {1500, 0x0e}
175180
};
176181

182+
static const char *const rk3368_reset_names[] = {
183+
"apb"
184+
};
185+
177186
static void rockchip_inno_csidphy_ths_settle(struct rockchip_inno_csidphy *priv,
178187
int hsfreq, int offset)
179188
{
@@ -344,6 +353,8 @@ static const struct dphy_drv_data rk1808_mipidphy_drv_data = {
344353
.hsfreq_ranges = rk1808_mipidphy_hsfreq_ranges,
345354
.num_hsfreq_ranges = ARRAY_SIZE(rk1808_mipidphy_hsfreq_ranges),
346355
.grf_regs = rk1808_grf_dphy_regs,
356+
.resets = rk3368_reset_names,
357+
.resets_num = ARRAY_SIZE(rk3368_reset_names),
347358
};
348359

349360
static const struct dphy_drv_data rk3326_mipidphy_drv_data = {
@@ -353,6 +364,8 @@ static const struct dphy_drv_data rk3326_mipidphy_drv_data = {
353364
.hsfreq_ranges = rk3326_mipidphy_hsfreq_ranges,
354365
.num_hsfreq_ranges = ARRAY_SIZE(rk3326_mipidphy_hsfreq_ranges),
355366
.grf_regs = rk3326_grf_dphy_regs,
367+
.resets = rk3368_reset_names,
368+
.resets_num = ARRAY_SIZE(rk3368_reset_names),
356369
};
357370

358371
static const struct dphy_drv_data rk3368_mipidphy_drv_data = {
@@ -362,6 +375,8 @@ static const struct dphy_drv_data rk3368_mipidphy_drv_data = {
362375
.hsfreq_ranges = rk3368_mipidphy_hsfreq_ranges,
363376
.num_hsfreq_ranges = ARRAY_SIZE(rk3368_mipidphy_hsfreq_ranges),
364377
.grf_regs = rk3368_grf_dphy_regs,
378+
.resets = rk3368_reset_names,
379+
.resets_num = ARRAY_SIZE(rk3368_reset_names),
365380
};
366381

367382
static const struct dphy_drv_data rk3568_mipidphy_drv_data = {
@@ -371,6 +386,8 @@ static const struct dphy_drv_data rk3568_mipidphy_drv_data = {
371386
.hsfreq_ranges = rk1808_mipidphy_hsfreq_ranges,
372387
.num_hsfreq_ranges = ARRAY_SIZE(rk1808_mipidphy_hsfreq_ranges),
373388
.grf_regs = rk3568_grf_dphy_regs,
389+
.resets = rk3368_reset_names,
390+
.resets_num = ARRAY_SIZE(rk3368_reset_names),
374391
};
375392

376393
static const struct of_device_id rockchip_inno_csidphy_match_id[] = {
@@ -404,6 +421,7 @@ static int rockchip_inno_csidphy_probe(struct platform_device *pdev)
404421
struct device *dev = &pdev->dev;
405422
struct phy_provider *phy_provider;
406423
struct phy *phy;
424+
int ret;
407425

408426
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
409427
if (!priv)
@@ -435,10 +453,18 @@ static int rockchip_inno_csidphy_probe(struct platform_device *pdev)
435453
return PTR_ERR(priv->pclk);
436454
}
437455

438-
priv->rst = devm_reset_control_get(dev, "apb");
439-
if (IS_ERR(priv->rst)) {
456+
if (priv->drv_data->resets_num > RESETS_MAX) {
457+
dev_err(dev, "invalid number of resets\n");
458+
return -EINVAL;
459+
}
460+
priv->resets_num = priv->drv_data->resets_num;
461+
for (unsigned int i = 0; i < priv->resets_num; i++)
462+
priv->resets[i].id = priv->drv_data->resets[i];
463+
ret = devm_reset_control_bulk_get_exclusive(dev, priv->resets_num,
464+
priv->resets);
465+
if (ret) {
440466
dev_err(dev, "failed to get system reset control\n");
441-
return PTR_ERR(priv->rst);
467+
return ret;
442468
}
443469

444470
phy = devm_phy_create(dev, NULL, &rockchip_inno_csidphy_ops);

0 commit comments

Comments
 (0)