Skip to content

Commit 5a6b1b8

Browse files
bivvyrkhuangtao
authored andcommitted
drm/rockchip: dsi: Add Turn On/Shutdown Peripheral command support
Change-Id: I93ed400ce7db63928cab06b68954ed085b37cdb2 Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
1 parent 4f7296c commit 5a6b1b8

1 file changed

Lines changed: 62 additions & 3 deletions

File tree

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

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@
8686

8787
#define DSI_VID_MODE_CFG 0x38
8888
#define VPG_EN BIT(16)
89+
#define LP_CMD_EN BIT(15)
8990
#define FRAME_BTA_ACK BIT(14)
9091
#define LP_HFP_EN BIT(13)
9192
#define LP_HBP_EN BIT(12)
92-
#define ENABLE_LOW_POWER (0xf << 8)
93-
#define ENABLE_LOW_POWER_MASK (0xf << 8)
93+
#define LP_VACT_EN BIT(11)
94+
#define LP_VFP_EN BIT(10)
95+
#define LP_VBP_EN BIT(9)
96+
#define LP_VSA_EN BIT(8)
9497
#define VID_MODE_TYPE_BURST_SYNC_PULSES 0x0
9598
#define VID_MODE_TYPE_BURST_SYNC_EVENTS 0x1
9699
#define VID_MODE_TYPE_BURST 0x2
@@ -515,6 +518,16 @@ static inline void mipi_dphy_rstz_deassert(struct dw_mipi_dsi *dsi)
515518
udelay(1);
516519
}
517520

521+
static inline void dpishutdn_assert(struct dw_mipi_dsi *dsi)
522+
{
523+
grf_field_write(dsi, DPISHUTDN, 1);
524+
}
525+
526+
static inline void dpishutdn_deassert(struct dw_mipi_dsi *dsi)
527+
{
528+
grf_field_write(dsi, DPISHUTDN, 0);
529+
}
530+
518531
static inline void testif_testclk_assert(struct dw_mipi_dsi *dsi)
519532
{
520533
regmap_update_bits(dsi->regmap, DSI_PHY_TST_CTRL0,
@@ -653,6 +666,24 @@ static void mipi_dphy_power_off(struct dw_mipi_dsi *dsi)
653666
phy_power_off(dsi->dphy.phy);
654667
}
655668

669+
static int dw_mipi_dsi_turn_on_peripheral(struct dw_mipi_dsi *dsi)
670+
{
671+
dpishutdn_assert(dsi);
672+
udelay(20);
673+
dpishutdn_deassert(dsi);
674+
675+
return 0;
676+
}
677+
678+
static int dw_mipi_dsi_shutdown_peripheral(struct dw_mipi_dsi *dsi)
679+
{
680+
dpishutdn_deassert(dsi);
681+
udelay(20);
682+
dpishutdn_assert(dsi);
683+
684+
return 0;
685+
}
686+
656687
static void dw_mipi_dsi_host_power_on(struct dw_mipi_dsi *dsi)
657688
{
658689
regmap_write(dsi->regmap, DSI_PWR_UP, POWERUP);
@@ -923,6 +954,28 @@ static ssize_t dw_mipi_dsi_transfer(struct dw_mipi_dsi *dsi,
923954
int val;
924955
int len = msg->tx_len;
925956

957+
switch (msg->type) {
958+
case MIPI_DSI_SHUTDOWN_PERIPHERAL:
959+
return dw_mipi_dsi_shutdown_peripheral(dsi);
960+
case MIPI_DSI_TURN_ON_PERIPHERAL:
961+
return dw_mipi_dsi_turn_on_peripheral(dsi);
962+
case MIPI_DSI_DCS_SHORT_WRITE:
963+
case MIPI_DSI_DCS_SHORT_WRITE_PARAM:
964+
case MIPI_DSI_DCS_LONG_WRITE:
965+
case MIPI_DSI_DCS_READ:
966+
case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:
967+
case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:
968+
case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:
969+
case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:
970+
case MIPI_DSI_GENERIC_LONG_WRITE:
971+
case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:
972+
case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:
973+
case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:
974+
break;
975+
default:
976+
return -EINVAL;
977+
}
978+
926979
/* create a packet to the DSI protocol */
927980
ret = mipi_dsi_create_packet(&packet, msg);
928981
if (ret) {
@@ -1003,7 +1056,13 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
10031056
{
10041057
u32 val;
10051058

1006-
val = LP_HFP_EN | ENABLE_LOW_POWER;
1059+
val = LP_VACT_EN | LP_VFP_EN | LP_VBP_EN | LP_VSA_EN | LP_CMD_EN;
1060+
1061+
if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_HFP))
1062+
val |= LP_HFP_EN;
1063+
1064+
if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_HBP))
1065+
val |= LP_HBP_EN;
10071066

10081067
if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
10091068
val |= VID_MODE_TYPE_BURST;

0 commit comments

Comments
 (0)