Skip to content

Commit 1df398e

Browse files
bivvyrkhuangtao
authored andcommitted
drm/rockchip: dsi: fix phy power-on sequence
Change-Id: I0ceaedb71776747e8951a75409bcc2521252dd18 Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
1 parent 2c659c7 commit 1df398e

1 file changed

Lines changed: 49 additions & 10 deletions

File tree

drivers/gpu/drm/rockchip/dw-mipi-dsi.c

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,10 @@
173173
#define MAX_RD_TIME(lbcc) ((lbcc) & 0x7fff)
174174

175175
#define DSI_PHY_RSTZ 0xa0
176-
#define PHY_DISFORCEPLL 0
177176
#define PHY_ENFORCEPLL BIT(3)
178-
#define PHY_DISABLECLK 0
179177
#define PHY_ENABLECLK BIT(2)
180-
#define PHY_RSTZ 0
181-
#define PHY_UNRSTZ BIT(1)
182-
#define PHY_SHUTDOWNZ 0
183-
#define PHY_UNSHUTDOWNZ BIT(0)
178+
#define PHY_RSTZ BIT(1)
179+
#define PHY_SHUTDOWNZ BIT(0)
184180

185181
#define DSI_PHY_IF_CFG 0xa4
186182
#define N_LANES(n) ((((n) - 1) & 0x3) << 0)
@@ -480,6 +476,44 @@ static int genif_wait_write_fifo_empty(struct dw_mipi_dsi *dsi)
480476
return 0;
481477
}
482478

479+
static inline void mipi_dphy_enableclk_assert(struct dw_mipi_dsi *dsi)
480+
{
481+
regmap_update_bits(dsi->regmap, DSI_PHY_RSTZ,
482+
PHY_ENABLECLK, PHY_ENABLECLK);
483+
udelay(1);
484+
}
485+
486+
static inline void mipi_dphy_enableclk_deassert(struct dw_mipi_dsi *dsi)
487+
{
488+
regmap_update_bits(dsi->regmap, DSI_PHY_RSTZ, PHY_ENABLECLK, 0);
489+
udelay(1);
490+
}
491+
492+
static inline void mipi_dphy_shutdownz_assert(struct dw_mipi_dsi *dsi)
493+
{
494+
regmap_update_bits(dsi->regmap, DSI_PHY_RSTZ, PHY_SHUTDOWNZ, 0);
495+
udelay(1);
496+
}
497+
498+
static inline void mipi_dphy_shutdownz_deassert(struct dw_mipi_dsi *dsi)
499+
{
500+
regmap_update_bits(dsi->regmap, DSI_PHY_RSTZ,
501+
PHY_SHUTDOWNZ, PHY_SHUTDOWNZ);
502+
udelay(1);
503+
}
504+
505+
static inline void mipi_dphy_rstz_assert(struct dw_mipi_dsi *dsi)
506+
{
507+
regmap_update_bits(dsi->regmap, DSI_PHY_RSTZ, PHY_RSTZ, 0);
508+
udelay(1);
509+
}
510+
511+
static inline void mipi_dphy_rstz_deassert(struct dw_mipi_dsi *dsi)
512+
{
513+
regmap_update_bits(dsi->regmap, DSI_PHY_RSTZ, PHY_RSTZ, PHY_RSTZ);
514+
udelay(1);
515+
}
516+
483517
static inline void testif_testclk_assert(struct dw_mipi_dsi *dsi)
484518
{
485519
regmap_update_bits(dsi->regmap, DSI_PHY_TST_CTRL0,
@@ -583,8 +617,8 @@ static int mipi_dphy_power_on(struct dw_mipi_dsi *dsi)
583617
unsigned int val, mask;
584618
int ret;
585619

586-
regmap_write(dsi->regmap, DSI_PHY_RSTZ, PHY_ENFORCEPLL |
587-
PHY_ENABLECLK | PHY_UNRSTZ | PHY_UNSHUTDOWNZ);
620+
mipi_dphy_shutdownz_deassert(dsi);
621+
mipi_dphy_rstz_deassert(dsi);
588622
usleep_range(1500, 2000);
589623

590624
if (dsi->dphy.phy)
@@ -598,6 +632,8 @@ static int mipi_dphy_power_on(struct dw_mipi_dsi *dsi)
598632
return ret;
599633
}
600634

635+
usleep_range(100, 200);
636+
601637
mask = PHY_STOPSTATELANE;
602638
ret = regmap_read_poll_timeout(dsi->regmap, DSI_PHY_STATUS,
603639
val, (val & mask) == mask,
@@ -1002,6 +1038,9 @@ static void mipi_dphy_init(struct dw_mipi_dsi *dsi)
10021038
{
10031039
u32 map[] = {0x1, 0x3, 0x7, 0xf};
10041040

1041+
mipi_dphy_shutdownz_assert(dsi);
1042+
mipi_dphy_rstz_assert(dsi);
1043+
10051044
/* Configures DPHY to work as a Master */
10061045
grf_field_write(dsi, MASTERSLAVEZ, 1);
10071046

@@ -1023,15 +1062,15 @@ static void mipi_dphy_init(struct dw_mipi_dsi *dsi)
10231062

10241063
/* Enable Clock Lane Module */
10251064
grf_field_write(dsi, ENABLECLK, 1);
1065+
1066+
mipi_dphy_enableclk_assert(dsi);
10261067
}
10271068

10281069
static void dw_mipi_dsi_init(struct dw_mipi_dsi *dsi)
10291070
{
10301071
u32 esc_clk_div;
10311072

10321073
regmap_write(dsi->regmap, DSI_PWR_UP, RESET);
1033-
regmap_write(dsi->regmap, DSI_PHY_RSTZ, PHY_DISFORCEPLL |
1034-
PHY_DISABLECLK | PHY_RSTZ | PHY_SHUTDOWNZ);
10351074

10361075
/* The maximum value of the escape clock frequency is 20MHz */
10371076
esc_clk_div = DIV_ROUND_UP(dsi->lane_mbps >> 3, 20);

0 commit comments

Comments
 (0)