Skip to content

Commit a010613

Browse files
sinthu-rajavinodkoul
authored andcommitted
phy: cadence: cdns-dphy-rx: Add common module reset support
DPHY RX module has a common module reset (RSTB_CMN) which is expected to be released during configuration. In J721E SR1.0 the RSTB_CMN is internally tied to CSI_RX_RST and is hardware controlled, for all other newer platforms the common module reset is software controlled. Add support to control common module reset during configuration and also skip common module reset based on soc_device_match() for J721E SR1.0. Signed-off-by: Sinthu Raja <sinthu.raja@ti.com> Co-developed-by: Vaishnav Achath <vaishnav.a@ti.com> Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com> Reviewed-by: Jai Luthra <j-luthra@ti.com> Link: https://lore.kernel.org/r/20230314073137.2153-1-vaishnav.a@ti.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent ec318c5 commit a010613

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

drivers/phy/cadence/cdns-dphy-rx.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#include <linux/phy/phy.h>
1212
#include <linux/phy/phy-mipi-dphy.h>
1313
#include <linux/platform_device.h>
14+
#include <linux/sys_soc.h>
1415

1516
#define DPHY_PMA_CMN(reg) (reg)
1617
#define DPHY_PCS(reg) (0xb00 + (reg))
1718
#define DPHY_ISO(reg) (0xc00 + (reg))
19+
#define DPHY_WRAP(reg) (0x1000 + (reg))
1820

1921
#define DPHY_CMN_SSM DPHY_PMA_CMN(0x20)
2022
#define DPHY_CMN_RX_MODE_EN BIT(10)
@@ -33,6 +35,9 @@
3335
#define DPHY_POWER_ISLAND_EN_CLK DPHY_PCS(0xc)
3436
#define DPHY_POWER_ISLAND_EN_CLK_VAL 0xaa
3537

38+
#define DPHY_LANE DPHY_WRAP(0x0)
39+
#define DPHY_LANE_RESET_CMN_EN BIT(23)
40+
3641
#define DPHY_ISO_CL_CTRL_L DPHY_ISO(0x10)
3742
#define DPHY_ISO_DL_CTRL_L0 DPHY_ISO(0x14)
3843
#define DPHY_ISO_DL_CTRL_L1 DPHY_ISO(0x20)
@@ -57,6 +62,10 @@ struct cdns_dphy_rx_band {
5762
unsigned int max_rate;
5863
};
5964

65+
struct cdns_dphy_soc_data {
66+
bool has_hw_cmn_rstb;
67+
};
68+
6069
/* Order of bands is important since the index is the band number. */
6170
static const struct cdns_dphy_rx_band bands[] = {
6271
{ 80, 100 }, { 100, 120 }, { 120, 160 }, { 160, 200 }, { 200, 240 },
@@ -142,13 +151,36 @@ static int cdns_dphy_rx_wait_lane_ready(struct cdns_dphy_rx *dphy,
142151
return 0;
143152
}
144153

154+
static struct cdns_dphy_soc_data j721e_soc_data = {
155+
.has_hw_cmn_rstb = true,
156+
};
157+
158+
static const struct soc_device_attribute cdns_dphy_socinfo[] = {
159+
{
160+
.family = "J721E",
161+
.revision = "SR1.0",
162+
.data = &j721e_soc_data,
163+
},
164+
{/* sentinel */}
165+
};
166+
145167
static int cdns_dphy_rx_configure(struct phy *phy,
146168
union phy_configure_opts *opts)
147169
{
148170
struct cdns_dphy_rx *dphy = phy_get_drvdata(phy);
149171
unsigned int reg, lanes = opts->mipi_dphy.lanes;
172+
const struct cdns_dphy_soc_data *soc_data = NULL;
173+
const struct soc_device_attribute *soc;
150174
int band_ctrl, ret;
151175

176+
soc = soc_device_match(cdns_dphy_socinfo);
177+
if (soc && soc->data)
178+
soc_data = soc->data;
179+
if (!soc || (soc_data && !soc_data->has_hw_cmn_rstb)) {
180+
reg = DPHY_LANE_RESET_CMN_EN;
181+
writel(reg, dphy->regs + DPHY_LANE);
182+
}
183+
152184
/* Data lanes. Minimum one lane is mandatory. */
153185
if (lanes < DPHY_LANES_MIN || lanes > DPHY_LANES_MAX)
154186
return -EINVAL;

0 commit comments

Comments
 (0)