Skip to content

Commit dceac34

Browse files
Hai Lirobclark
authored andcommitted
drm/msm/dsi: Return more timings from PHY to host
The DSI host is required to configure more timings calculated in PHY. By introducing a shared structure, this change allows more timing information passed from PHY to host. Signed-off-by: Hai Li <[email protected]> Signed-off-by: Archit Taneja <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 25c45d8 commit dceac34

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

drivers/gpu/drm/msm/dsi/dsi.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define DSI_1 1
2828
#define DSI_MAX 2
2929

30+
struct msm_dsi_phy_shared_timings;
31+
3032
enum msm_dsi_phy_type {
3133
MSM_DSI_PHY_28NM_HPM,
3234
MSM_DSI_PHY_28NM_LP,
@@ -86,7 +88,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id);
8688
struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
8789
int msm_dsi_manager_phy_enable(int id,
8890
const unsigned long bit_rate, const unsigned long esc_rate,
89-
u32 *clk_pre, u32 *clk_post);
91+
struct msm_dsi_phy_shared_timings *shared_timing);
9092
void msm_dsi_manager_phy_disable(int id);
9193
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
9294
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
@@ -165,13 +167,18 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi);
165167

166168
/* dsi phy */
167169
struct msm_dsi_phy;
170+
struct msm_dsi_phy_shared_timings {
171+
u32 clk_post;
172+
u32 clk_pre;
173+
bool clk_pre_inc_by_2;
174+
};
168175
void msm_dsi_phy_driver_register(void);
169176
void msm_dsi_phy_driver_unregister(void);
170177
int msm_dsi_phy_enable(struct msm_dsi_phy *phy, int src_pll_id,
171178
const unsigned long bit_rate, const unsigned long esc_rate);
172179
void msm_dsi_phy_disable(struct msm_dsi_phy *phy);
173-
void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
174-
u32 *clk_pre, u32 *clk_post);
180+
void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
181+
struct msm_dsi_phy_shared_timings *shared_timing);
175182
struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy);
176183

177184
#endif /* __DSI_CONNECTOR_H__ */

drivers/gpu/drm/msm/dsi/dsi_host.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ static inline enum dsi_cmd_dst_format dsi_get_cmd_fmt(
756756
}
757757

758758
static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable,
759-
u32 clk_pre, u32 clk_post)
759+
struct msm_dsi_phy_shared_timings *phy_shared_timings)
760760
{
761761
u32 flags = msm_host->mode_flags;
762762
enum mipi_dsi_pixel_format mipi_fmt = msm_host->format;
@@ -819,10 +819,16 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable,
819819
data |= DSI_TRIG_CTRL_BLOCK_DMA_WITHIN_FRAME;
820820
dsi_write(msm_host, REG_DSI_TRIG_CTRL, data);
821821

822-
data = DSI_CLKOUT_TIMING_CTRL_T_CLK_POST(clk_post) |
823-
DSI_CLKOUT_TIMING_CTRL_T_CLK_PRE(clk_pre);
822+
data = DSI_CLKOUT_TIMING_CTRL_T_CLK_POST(phy_shared_timings->clk_post) |
823+
DSI_CLKOUT_TIMING_CTRL_T_CLK_PRE(phy_shared_timings->clk_pre);
824824
dsi_write(msm_host, REG_DSI_CLKOUT_TIMING_CTRL, data);
825825

826+
if ((cfg_hnd->major == MSM_DSI_VER_MAJOR_6G) &&
827+
(cfg_hnd->minor > MSM_DSI_6G_VER_MINOR_V1_0) &&
828+
phy_shared_timings->clk_pre_inc_by_2)
829+
dsi_write(msm_host, REG_DSI_T_CLK_PRE_EXTEND,
830+
DSI_T_CLK_PRE_EXTEND_INC_BY_2_BYTECLK);
831+
826832
data = 0;
827833
if (!(flags & MIPI_DSI_MODE_EOT_PACKET))
828834
data |= DSI_EOT_PACKET_CTRL_TX_EOT_APPEND;
@@ -2170,7 +2176,7 @@ static void msm_dsi_sfpb_config(struct msm_dsi_host *msm_host, bool enable)
21702176
int msm_dsi_host_power_on(struct mipi_dsi_host *host)
21712177
{
21722178
struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
2173-
u32 clk_pre = 0, clk_post = 0;
2179+
struct msm_dsi_phy_shared_timings phy_shared_timings;
21742180
int ret = 0;
21752181

21762182
mutex_lock(&msm_host->dev_mutex);
@@ -2204,7 +2210,7 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host)
22042210
ret = msm_dsi_manager_phy_enable(msm_host->id,
22052211
msm_host->byte_clk_rate * 8,
22062212
msm_host->esc_clk_rate,
2207-
&clk_pre, &clk_post);
2213+
&phy_shared_timings);
22082214
dsi_bus_clk_disable(msm_host);
22092215
if (ret) {
22102216
pr_err("%s: failed to enable phy, %d\n", __func__, ret);
@@ -2226,7 +2232,7 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host)
22262232

22272233
dsi_timing_setup(msm_host);
22282234
dsi_sw_reset(msm_host);
2229-
dsi_ctrl_config(msm_host, true, clk_pre, clk_post);
2235+
dsi_ctrl_config(msm_host, true, &phy_shared_timings);
22302236

22312237
if (msm_host->disp_en_gpio)
22322238
gpiod_set_value(msm_host->disp_en_gpio, 1);
@@ -2255,7 +2261,7 @@ int msm_dsi_host_power_off(struct mipi_dsi_host *host)
22552261
goto unlock_ret;
22562262
}
22572263

2258-
dsi_ctrl_config(msm_host, false, 0, 0);
2264+
dsi_ctrl_config(msm_host, false, NULL);
22592265

22602266
if (msm_host->disp_en_gpio)
22612267
gpiod_set_value(msm_host->disp_en_gpio, 0);

drivers/gpu/drm/msm/dsi/dsi_manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge)
660660

661661
int msm_dsi_manager_phy_enable(int id,
662662
const unsigned long bit_rate, const unsigned long esc_rate,
663-
u32 *clk_pre, u32 *clk_post)
663+
struct msm_dsi_phy_shared_timings *shared_timings)
664664
{
665665
struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
666666
struct msm_dsi_phy *phy = msm_dsi->phy;
@@ -688,7 +688,7 @@ int msm_dsi_manager_phy_enable(int id,
688688
}
689689

690690
msm_dsi->phy_enabled = true;
691-
msm_dsi_phy_get_clk_pre_post(phy, clk_pre, clk_post);
691+
msm_dsi_phy_get_shared_timings(phy, shared_timings);
692692

693693
return 0;
694694
}

drivers/gpu/drm/msm/dsi/phy/dsi_phy.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,30 @@ int msm_dsi_dphy_timing_calc(struct msm_dsi_dphy_timing *timing,
115115
temp = ((timing->hs_exit >> 1) + 1) * 2 * ui;
116116
temp = 60 * coeff + 52 * ui - 24 * ui - temp;
117117
tmin = S_DIV_ROUND_UP(temp, 8 * ui) - 1;
118-
timing->clk_post = linear_inter(tmax, tmin, pcnt2, 0, false);
119-
118+
timing->shared_timings.clk_post = linear_inter(tmax, tmin, pcnt2, 0,
119+
false);
120120
tmax = 63;
121121
temp = ((timing->clk_prepare >> 1) + 1) * 2 * ui;
122122
temp += ((timing->clk_zero >> 1) + 1) * 2 * ui;
123123
temp += 8 * ui + lpx;
124124
tmin = S_DIV_ROUND_UP(temp, 8 * ui) - 1;
125125
if (tmin > tmax) {
126126
temp = linear_inter(2 * tmax, tmin, pcnt2, 0, false);
127-
timing->clk_pre = temp >> 1;
127+
timing->shared_timings.clk_pre = temp >> 1;
128+
timing->shared_timings.clk_pre_inc_by_2 = true;
128129
} else {
129-
timing->clk_pre = linear_inter(tmax, tmin, pcnt2, 0, false);
130+
timing->shared_timings.clk_pre =
131+
linear_inter(tmax, tmin, pcnt2, 0, false);
132+
timing->shared_timings.clk_pre_inc_by_2 = false;
130133
}
131134

132135
timing->ta_go = 3;
133136
timing->ta_sure = 0;
134137
timing->ta_get = 4;
135138

136-
DBG("PHY timings: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
137-
timing->clk_pre, timing->clk_post, timing->clk_zero,
139+
DBG("PHY timings: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
140+
timing->shared_timings.clk_pre, timing->shared_timings.clk_post,
141+
timing->shared_timings.clk_pre_inc_by_2, timing->clk_zero,
138142
timing->clk_trail, timing->clk_prepare, timing->hs_exit,
139143
timing->hs_zero, timing->hs_prepare, timing->hs_trail,
140144
timing->hs_rqst);
@@ -460,16 +464,11 @@ void msm_dsi_phy_disable(struct msm_dsi_phy *phy)
460464
dsi_phy_regulator_disable(phy);
461465
}
462466

463-
void msm_dsi_phy_get_clk_pre_post(struct msm_dsi_phy *phy,
464-
u32 *clk_pre, u32 *clk_post)
467+
void msm_dsi_phy_get_shared_timings(struct msm_dsi_phy *phy,
468+
struct msm_dsi_phy_shared_timings *shared_timings)
465469
{
466-
if (!phy)
467-
return;
468-
469-
if (clk_pre)
470-
*clk_pre = phy->timing.clk_pre;
471-
if (clk_post)
472-
*clk_post = phy->timing.clk_post;
470+
memcpy(shared_timings, &phy->timing.shared_timings,
471+
sizeof(*shared_timings));
473472
}
474473

475474
struct msm_dsi_pll *msm_dsi_phy_get_pll(struct msm_dsi_phy *phy)

drivers/gpu/drm/msm/dsi/phy/dsi_phy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ struct msm_dsi_dphy_timing {
6262
u32 ta_go;
6363
u32 ta_sure;
6464
u32 ta_get;
65+
66+
struct msm_dsi_phy_shared_timings shared_timings;
6567
};
6668

6769
struct msm_dsi_phy {

0 commit comments

Comments
 (0)