Skip to content

Commit 3fd490a

Browse files
smaeulvinodkoul
authored andcommitted
phy: allwinner: phy-sun6i-mipi-dphy: Add a variant power-on hook
The A100 variant uses the same values for the timing registers, and it uses the same final power-on sequence, but it needs a different analog register configuration in the middle. Support this by moving the variant-specific parts to a hook provided by the variant. Signed-off-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent cb7f49a commit 3fd490a

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

drivers/phy/allwinner/phy-sun6i-mipi-dphy.c

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ enum sun6i_dphy_direction {
114114
SUN6I_DPHY_DIRECTION_RX,
115115
};
116116

117+
struct sun6i_dphy;
118+
117119
struct sun6i_dphy_variant {
120+
void (*tx_power_on)(struct sun6i_dphy *dphy);
118121
bool rx_supported;
119122
};
120123

@@ -156,33 +159,10 @@ static int sun6i_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
156159
return 0;
157160
}
158161

159-
static int sun6i_dphy_tx_power_on(struct sun6i_dphy *dphy)
162+
static void sun6i_a31_mipi_dphy_tx_power_on(struct sun6i_dphy *dphy)
160163
{
161164
u8 lanes_mask = GENMASK(dphy->config.lanes - 1, 0);
162165

163-
regmap_write(dphy->regs, SUN6I_DPHY_TX_CTL_REG,
164-
SUN6I_DPHY_TX_CTL_HS_TX_CLK_CONT);
165-
166-
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME0_REG,
167-
SUN6I_DPHY_TX_TIME0_LP_CLK_DIV(14) |
168-
SUN6I_DPHY_TX_TIME0_HS_PREPARE(6) |
169-
SUN6I_DPHY_TX_TIME0_HS_TRAIL(10));
170-
171-
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME1_REG,
172-
SUN6I_DPHY_TX_TIME1_CLK_PREPARE(7) |
173-
SUN6I_DPHY_TX_TIME1_CLK_ZERO(50) |
174-
SUN6I_DPHY_TX_TIME1_CLK_PRE(3) |
175-
SUN6I_DPHY_TX_TIME1_CLK_POST(10));
176-
177-
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME2_REG,
178-
SUN6I_DPHY_TX_TIME2_CLK_TRAIL(30));
179-
180-
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME3_REG, 0);
181-
182-
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME4_REG,
183-
SUN6I_DPHY_TX_TIME4_HS_TX_ANA0(3) |
184-
SUN6I_DPHY_TX_TIME4_HS_TX_ANA1(3));
185-
186166
regmap_write(dphy->regs, SUN6I_DPHY_ANA0_REG,
187167
SUN6I_DPHY_ANA0_REG_PWS |
188168
SUN6I_DPHY_ANA0_REG_DMPC |
@@ -214,6 +194,36 @@ static int sun6i_dphy_tx_power_on(struct sun6i_dphy *dphy)
214194
SUN6I_DPHY_ANA3_EN_LDOC |
215195
SUN6I_DPHY_ANA3_EN_LDOD);
216196
udelay(1);
197+
}
198+
199+
static int sun6i_dphy_tx_power_on(struct sun6i_dphy *dphy)
200+
{
201+
u8 lanes_mask = GENMASK(dphy->config.lanes - 1, 0);
202+
203+
regmap_write(dphy->regs, SUN6I_DPHY_TX_CTL_REG,
204+
SUN6I_DPHY_TX_CTL_HS_TX_CLK_CONT);
205+
206+
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME0_REG,
207+
SUN6I_DPHY_TX_TIME0_LP_CLK_DIV(14) |
208+
SUN6I_DPHY_TX_TIME0_HS_PREPARE(6) |
209+
SUN6I_DPHY_TX_TIME0_HS_TRAIL(10));
210+
211+
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME1_REG,
212+
SUN6I_DPHY_TX_TIME1_CLK_PREPARE(7) |
213+
SUN6I_DPHY_TX_TIME1_CLK_ZERO(50) |
214+
SUN6I_DPHY_TX_TIME1_CLK_PRE(3) |
215+
SUN6I_DPHY_TX_TIME1_CLK_POST(10));
216+
217+
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME2_REG,
218+
SUN6I_DPHY_TX_TIME2_CLK_TRAIL(30));
219+
220+
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME3_REG, 0);
221+
222+
regmap_write(dphy->regs, SUN6I_DPHY_TX_TIME4_REG,
223+
SUN6I_DPHY_TX_TIME4_HS_TX_ANA0(3) |
224+
SUN6I_DPHY_TX_TIME4_HS_TX_ANA1(3));
225+
226+
dphy->variant->tx_power_on(dphy);
217227

218228
regmap_update_bits(dphy->regs, SUN6I_DPHY_ANA3_REG,
219229
SUN6I_DPHY_ANA3_EN_VTTC |
@@ -470,6 +480,7 @@ static int sun6i_dphy_probe(struct platform_device *pdev)
470480
}
471481

472482
static const struct sun6i_dphy_variant sun6i_a31_mipi_dphy_variant = {
483+
.tx_power_on = sun6i_a31_mipi_dphy_tx_power_on,
473484
.rx_supported = true,
474485
};
475486

0 commit comments

Comments
 (0)