diff options
| author | Aravind Venkateswaran <aravindh@codeaurora.org> | 2014-03-17 12:38:13 -0700 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-23 20:28:16 -0700 |
| commit | ec96ea593c2170207e6c64a02c03afd5890dee64 (patch) | |
| tree | be3d230e81a72eae99309fb6a878dfc7f640cd6f | |
| parent | 12c90ec9513ce93c4c32fe89049a6c561a4d05d2 (diff) | |
msm: mdss: Cleanup handling of dual dsi broadcast mode
When broadcast mode is enabled for dual dsi panels, the two dsi
controllers act in a master-slave configuration. A lot of configuration
in the driver requires special handling in such scenarios. Current
implementation has a lot of redundant code to check for broadcast mode
configurations. Rework the code to remove these and add a unified set of
APIs to query broadcast mode configurations.
Change-Id: I634f94266e8dce28bcaa897ef39e7c3ca9b558e5
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
| -rw-r--r-- | drivers/video/fbdev/msm/mdss_dsi.c | 23 | ||||
| -rw-r--r-- | drivers/video/fbdev/msm/mdss_dsi.h | 53 | ||||
| -rw-r--r-- | drivers/video/fbdev/msm/mdss_dsi_host.c | 303 | ||||
| -rw-r--r-- | drivers/video/fbdev/msm/mdss_dsi_panel.c | 25 | ||||
| -rw-r--r-- | drivers/video/fbdev/msm/msm_mdss_io_8974.c | 86 |
5 files changed, 269 insertions, 221 deletions
diff --git a/drivers/video/fbdev/msm/mdss_dsi.c b/drivers/video/fbdev/msm/mdss_dsi.c index f1402a14d0c2..0aa6ba2fd3d2 100644 --- a/drivers/video/fbdev/msm/mdss_dsi.c +++ b/drivers/video/fbdev/msm/mdss_dsi.c @@ -535,26 +535,31 @@ static int mdss_dsi_ulps_config(struct mdss_dsi_ctrl_pdata *ctrl, int enable) { int rc; - struct mdss_dsi_ctrl_pdata *sctrl = NULL; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; if (&ctrl->mmss_misc_io == NULL) { pr_err("%s: mmss_misc_io is NULL. ULPS not valid\n", __func__); return -EINVAL; } - if (ctrl->flags & DSI_FLAG_CLOCK_MASTER) - sctrl = mdss_dsi_ctrl_slave(ctrl); + if (mdss_dsi_is_slave_ctrl(ctrl)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (!mctrl) { + pr_err("%s: Unable to get master control\n", __func__); + return -EINVAL; + } + } - if (sctrl) { - pr_debug("%s: configuring ulps (%s) for slave ctrl\n", - __func__, (enable ? "on" : "off")); - rc = mdss_dsi_ulps_config_sub(sctrl, enable); + if (mctrl) { + pr_debug("%s: configuring ulps (%s) for master ctrl%d\n", + __func__, (enable ? "on" : "off"), ctrl->ndx); + rc = mdss_dsi_ulps_config_sub(mctrl, enable); if (rc) return rc; } - pr_debug("%s: configuring ulps (%s) for master ctrl\n", - __func__, (enable ? "on" : "off")); + pr_debug("%s: configuring ulps (%s) for ctrl%d\n", + __func__, (enable ? "on" : "off"), ctrl->ndx); return mdss_dsi_ulps_config_sub(ctrl, enable); } diff --git a/drivers/video/fbdev/msm/mdss_dsi.h b/drivers/video/fbdev/msm/mdss_dsi.h index aa596bbc4309..373e01e9a513 100644 --- a/drivers/video/fbdev/msm/mdss_dsi.h +++ b/drivers/video/fbdev/msm/mdss_dsi.h @@ -150,6 +150,7 @@ enum dsi_lane_map_type { extern struct device dsi_dev; extern int mdss_dsi_clk_on; extern u32 dsi_irq; +extern struct mdss_dsi_ctrl_pdata *ctrl_list[]; struct dsiphy_pll_divider_config { u32 clk_rate; @@ -226,12 +227,14 @@ enum { DSI_CTRL_MAX, }; +/* DSI controller #0 is always treated as a master in broadcast mode */ +#define DSI_CTRL_MASTER DSI_CTRL_0 +#define DSI_CTRL_SLAVE DSI_CTRL_1 + #define DSI_EV_PLL_UNLOCKED 0x0001 #define DSI_EV_MDP_FIFO_UNDERFLOW 0x0002 #define DSI_EV_MDP_BUSY_RELEASE 0x80000000 -#define DSI_FLAG_CLOCK_MASTER 0x80000000 - struct mdss_dsi_ctrl_pdata { int ndx; /* panel_num */ int (*on) (struct mdss_panel_data *pdata); @@ -331,9 +334,6 @@ void mdss_dsi_controller_cfg(int enable, struct mdss_panel_data *pdata); void mdss_dsi_sw_reset(struct mdss_panel_data *pdata); -struct mdss_dsi_ctrl_pdata *mdss_dsi_ctrl_slave( - struct mdss_dsi_ctrl_pdata *ctrl); - irqreturn_t mdss_dsi_isr(int irq, void *ptr); void mdss_dsi_irq_handler_config(struct mdss_dsi_ctrl_pdata *ctrl_pdata); @@ -364,4 +364,47 @@ bool __mdss_dsi_clk_enabled(struct mdss_dsi_ctrl_pdata *ctrl); int mdss_dsi_panel_init(struct device_node *node, struct mdss_dsi_ctrl_pdata *ctrl_pdata, bool cmd_cfg_cont_splash); + +static inline bool mdss_dsi_broadcast_mode_enabled(void) +{ + return ctrl_list[DSI_CTRL_MASTER]->shared_pdata.broadcast_enable && + ctrl_list[DSI_CTRL_SLAVE] && + ctrl_list[DSI_CTRL_SLAVE]->shared_pdata.broadcast_enable; +} + +static inline struct mdss_dsi_ctrl_pdata *mdss_dsi_get_master_ctrl(void) +{ + if (mdss_dsi_broadcast_mode_enabled()) + return ctrl_list[DSI_CTRL_MASTER]; + else + return NULL; +} + +static inline struct mdss_dsi_ctrl_pdata *mdss_dsi_get_slave_ctrl(void) +{ + if (mdss_dsi_broadcast_mode_enabled()) + return ctrl_list[DSI_CTRL_SLAVE]; + else + return NULL; +} + +static inline bool mdss_dsi_is_master_ctrl(struct mdss_dsi_ctrl_pdata *ctrl) +{ + return mdss_dsi_broadcast_mode_enabled() && + (ctrl->ndx == DSI_CTRL_MASTER); +} + +static inline bool mdss_dsi_is_slave_ctrl(struct mdss_dsi_ctrl_pdata *ctrl) +{ + return mdss_dsi_broadcast_mode_enabled() && + (ctrl->ndx == DSI_CTRL_SLAVE); +} + +static inline struct mdss_dsi_ctrl_pdata *mdss_dsi_get_ctrl_by_index(int ndx) +{ + if (ndx >= DSI_CTRL_MAX) + return NULL; + + return ctrl_list[ndx]; +} #endif /* MDSS_DSI_H */ diff --git a/drivers/video/fbdev/msm/mdss_dsi_host.c b/drivers/video/fbdev/msm/mdss_dsi_host.c index 339cbba91196..7d6abec16ada 100644 --- a/drivers/video/fbdev/msm/mdss_dsi_host.c +++ b/drivers/video/fbdev/msm/mdss_dsi_host.c @@ -29,10 +29,7 @@ #define VSYNC_PERIOD 17 -static struct mdss_dsi_ctrl_pdata *left_ctrl_pdata; - -static struct mdss_dsi_ctrl_pdata *ctrl_list[DSI_CTRL_MAX]; - +struct mdss_dsi_ctrl_pdata *ctrl_list[DSI_CTRL_MAX]; struct mdss_hw mdss_dsi0_hw = { .hw_ndx = MDSS_HW_DSI0, @@ -72,14 +69,6 @@ static int dsi_event_thread(void *data); void mdss_dsi_ctrl_init(struct mdss_dsi_ctrl_pdata *ctrl) { - if (ctrl->shared_pdata.broadcast_enable) - if (ctrl->panel_data.panel_info.pdest - == DISPLAY_1) { - pr_debug("%s: Broadcast mode enabled.\n", - __func__); - left_ctrl_pdata = ctrl; - } - if (ctrl->panel_data.panel_info.pdest == DISPLAY_1) { mdss_dsi0_hw.ptr = (void *)(ctrl); ctrl->dsi_hw = &mdss_dsi0_hw; @@ -94,10 +83,6 @@ void mdss_dsi_ctrl_init(struct mdss_dsi_ctrl_pdata *ctrl) ctrl_list[ctrl->ndx] = ctrl; /* keep it */ - if (ctrl->shared_pdata.broadcast_enable) - if (ctrl->ndx == DSI_CTRL_1) - ctrl->flags |= DSI_FLAG_CLOCK_MASTER; - if (mdss_register_irq(ctrl->dsi_hw)) pr_err("%s: mdss_register_irq failed.\n", __func__); @@ -123,22 +108,6 @@ void mdss_dsi_ctrl_init(struct mdss_dsi_ctrl_pdata *ctrl) } } -struct mdss_dsi_ctrl_pdata *mdss_dsi_ctrl_slave( - struct mdss_dsi_ctrl_pdata *ctrl) -{ - int ndx; - struct mdss_dsi_ctrl_pdata *sctrl = NULL; - - /* only two controllers */ - ndx = ctrl->ndx; - ndx += 1; - ndx %= DSI_CTRL_MAX; - sctrl = ctrl_list[ndx]; - - return sctrl; - -} - void mdss_dsi_clk_req(struct mdss_dsi_ctrl_pdata *ctrl, int enable) { if (enable == 0) { @@ -341,7 +310,7 @@ void mdss_dsi_host_init(struct mdss_panel_data *pdata) /* from frame buffer, low power mode */ /* DSI_COMMAND_MODE_DMA_CTRL */ - if (ctrl_pdata->shared_pdata.broadcast_enable) + if (mdss_dsi_broadcast_mode_enabled()) MIPI_OUTP(ctrl_pdata->ctrl_base + 0x3C, 0x94000000); else MIPI_OUTP(ctrl_pdata->ctrl_base + 0x3C, 0x14000000); @@ -544,6 +513,7 @@ void mdss_dsi_op_mode_config(int mode, { u32 dsi_ctrl, intr_ctrl; struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; if (pdata == NULL) { pr_err("%s: Invalid input data\n", __func__); @@ -553,12 +523,15 @@ void mdss_dsi_op_mode_config(int mode, ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data); - if (ctrl_pdata->shared_pdata.broadcast_enable) - if (pdata->panel_info.pdest == DISPLAY_1) { - pr_debug("%s: Broadcast mode. 1st ctrl\n", - __func__); - return; - } + /* + * In broadcast mode, the configuration for master controller + * would be done when the slave controller is configured + */ + if (mdss_dsi_is_master_ctrl(ctrl_pdata)) { + pr_debug("%s: Broadcast mode enabled. skipping config for ctrl%d\n", + __func__, ctrl_pdata->ndx); + return; + } dsi_ctrl = MIPI_INP((ctrl_pdata->ctrl_base) + 0x0004); /*If Video enabled, Keep Video and Cmd mode ON */ @@ -579,17 +552,22 @@ void mdss_dsi_op_mode_config(int mode, DSI_INTR_CMD_MDP_DONE_MASK | DSI_INTR_BTA_DONE_MASK; } - if (ctrl_pdata->shared_pdata.broadcast_enable) - if ((pdata->panel_info.pdest == DISPLAY_2) - && (left_ctrl_pdata != NULL)) { - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0110, - intr_ctrl); /* DSI_INTL_CTRL */ - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0004, - dsi_ctrl); + /* Ensure that for slave controller, master is also configured */ + if (mdss_dsi_is_slave_ctrl(ctrl_pdata)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (mctrl) { + pr_debug("%s: configuring ctrl%d\n", __func__, + mctrl->ndx); + MIPI_OUTP(mctrl->ctrl_base + 0x0110, intr_ctrl); + MIPI_OUTP(mctrl->ctrl_base + 0x0004, dsi_ctrl); + } else { + pr_warn("%s: Unable to get master control\n", + __func__); } + } - MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0110, - intr_ctrl); /* DSI_INTL_CTRL */ + pr_debug("%s: configuring ctrl%d\n", __func__, ctrl_pdata->ndx); + MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0110, intr_ctrl); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0004, dsi_ctrl); wmb(); } @@ -744,6 +722,40 @@ static int mdss_dsi_cmds2buf_tx(struct mdss_dsi_ctrl_pdata *ctrl, return tot; } +/** + * __mdss_dsi_cmd_mode_config() - Enable/disable command mode engine + * @ctrl: pointer to the dsi controller structure + * @enable: true to enable command mode, false to disable command mode + * + * This function can be used to temporarily enable the command mode + * engine (even for video mode panels) so as to transfer any dma commands to + * the panel. It can also be used to disable the command mode engine + * when no longer needed. + * + * Return: true, if there was a mode switch to command mode for video mode + * panels. + */ +static inline bool __mdss_dsi_cmd_mode_config( + struct mdss_dsi_ctrl_pdata *ctrl, bool enable) +{ + bool mode_changed = false; + u32 dsi_ctrl; + + dsi_ctrl = MIPI_INP((ctrl->ctrl_base) + 0x0004); + /* if currently in video mode, enable command mode */ + if (enable) { + if ((dsi_ctrl) & BIT(1)) { + MIPI_OUTP((ctrl->ctrl_base) + 0x0004, + dsi_ctrl | BIT(2)); + mode_changed = true; + } + } else { + MIPI_OUTP((ctrl->ctrl_base) + 0x0004, dsi_ctrl & ~BIT(2)); + } + + return mode_changed; +} + /* * mdss_dsi_cmds_tx: * thread context only @@ -751,61 +763,49 @@ static int mdss_dsi_cmds2buf_tx(struct mdss_dsi_ctrl_pdata *ctrl, int mdss_dsi_cmds_tx(struct mdss_dsi_ctrl_pdata *ctrl, struct dsi_cmd_desc *cmds, int cnt) { - u32 dsi_ctrl, data; - int video_mode, ret = 0; - u32 left_dsi_ctrl = 0; - bool left_ctrl_restore = false; - - if (ctrl->shared_pdata.broadcast_enable) { - if (ctrl->ndx == DSI_CTRL_0) { - pr_debug("%s: Broadcast mode. 1st ctrl\n", - __func__); - return 0; - } - } + int ret = 0; + bool ctrl_restore = false, mctrl_restore = false; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; - if (ctrl->shared_pdata.broadcast_enable) { - if ((ctrl->ndx == DSI_CTRL_1) - && (left_ctrl_pdata != NULL)) { - left_dsi_ctrl = MIPI_INP(left_ctrl_pdata->ctrl_base - + 0x0004); - video_mode = - left_dsi_ctrl & 0x02; /* VIDEO_MODE_EN */ - if (video_mode) { - data = left_dsi_ctrl | 0x04; /* CMD_MODE_EN */ - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0004, - data); - left_ctrl_restore = true; - } - } + /* + * In broadcast mode, the configuration for master controller + * would be done when the slave controller is configured + */ + if (mdss_dsi_is_master_ctrl(ctrl)) { + pr_debug("%s: Broadcast mode enabled. skipping config for ctrl%d\n", + __func__, ctrl->ndx); + return 0; } - /* turn on cmd mode - * for video mode, do not send cmds more than - * one pixel line, since it only transmit it - * during BLLP. - */ - dsi_ctrl = MIPI_INP((ctrl->ctrl_base) + 0x0004); - video_mode = dsi_ctrl & 0x02; /* VIDEO_MODE_EN */ - if (video_mode) { - data = dsi_ctrl | 0x04; /* CMD_MODE_EN */ - MIPI_OUTP((ctrl->ctrl_base) + 0x0004, data); + /* + * Turn on cmd mode in order to transmit the commands. + * For video mode, do not send cmds more than one pixel line, + * since it only transmit it during BLLP. + * Ensure that for slave controller, master is also configured + */ + if (mdss_dsi_is_slave_ctrl(ctrl)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (!mctrl) + pr_warn("%s: Unable to get master control\n", + __func__); + else + mctrl_restore = __mdss_dsi_cmd_mode_config(mctrl, 1); } + ctrl_restore = __mdss_dsi_cmd_mode_config(ctrl, 1); + ret = mdss_dsi_cmds2buf_tx(ctrl, cmds, cnt); if (IS_ERR_VALUE(ret)) { - pr_err("%s: failed to call\n", - __func__); + pr_err("%s: failed to call\n", __func__); cnt = -EINVAL; } - if (left_ctrl_restore) - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0004, - left_dsi_ctrl); /*restore */ + if (mctrl_restore) + __mdss_dsi_cmd_mode_config(mctrl, 0); + + if (ctrl_restore) + __mdss_dsi_cmd_mode_config(ctrl, 0); - if (video_mode) - MIPI_OUTP((ctrl->ctrl_base) + 0x0004, - dsi_ctrl); /* restore */ return cnt; } @@ -838,46 +838,36 @@ int mdss_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl, int short_response, diff, pkt_size, ret = 0; struct dsi_buf *tp, *rp; char cmd; - u32 dsi_ctrl, data; - int video_mode; - u32 left_dsi_ctrl = 0; - bool left_ctrl_restore = false; - - if (ctrl->shared_pdata.broadcast_enable) { - if (ctrl->ndx == DSI_CTRL_0) { - pr_debug("%s: Broadcast mode. 1st ctrl\n", - __func__); - return 0; - } - } + bool ctrl_restore = false, mctrl_restore = false; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; - if (ctrl->shared_pdata.broadcast_enable) { - if ((ctrl->ndx == DSI_CTRL_1) - && (left_ctrl_pdata != NULL)) { - left_dsi_ctrl = MIPI_INP(left_ctrl_pdata->ctrl_base - + 0x0004); - video_mode = left_dsi_ctrl & 0x02; /* VIDEO_MODE_EN */ - if (video_mode) { - data = left_dsi_ctrl | 0x04; /* CMD_MODE_EN */ - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0004, - data); - left_ctrl_restore = true; - } - } + /* + * In broadcast mode, the configuration for master controller + * would be done when the slave controller is configured + */ + if (mdss_dsi_is_master_ctrl(ctrl)) { + pr_debug("%s: Broadcast mode enabled. skipping config for ctrl%d\n", + __func__, ctrl->ndx); + return 0; } - /* turn on cmd mode - * for video mode, do not send cmds more than - * one pixel line, since it only transmit it - * during BLLP. - */ - dsi_ctrl = MIPI_INP((ctrl->ctrl_base) + 0x0004); - video_mode = dsi_ctrl & 0x02; /* VIDEO_MODE_EN */ - if (video_mode) { - data = dsi_ctrl | 0x04; /* CMD_MODE_EN */ - MIPI_OUTP((ctrl->ctrl_base) + 0x0004, data); + /* + * Turn on cmd mode in order to transmit the commands. + * For video mode, do not send cmds more than one pixel line, + * since it only transmit it during BLLP. + * Ensure that for slave controller, master is also configured + */ + if (mdss_dsi_is_slave_ctrl(ctrl)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (!mctrl) + pr_warn("%s: Unable to get master control\n", + __func__); + else + mctrl_restore = __mdss_dsi_cmd_mode_config(mctrl, 1); } + ctrl_restore = __mdss_dsi_cmd_mode_config(ctrl, 1); + if (rlen == 0) { short_response = 1; rx_byte = 4; @@ -1004,12 +994,11 @@ int mdss_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl, rp->len = 0; } end: - if (left_ctrl_restore) - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0004, - left_dsi_ctrl); /*restore */ - if (video_mode) - MIPI_OUTP((ctrl->ctrl_base) + 0x0004, - dsi_ctrl); /* restore */ + if (mctrl_restore) + __mdss_dsi_cmd_mode_config(mctrl, 0); + + if (ctrl_restore) + __mdss_dsi_cmd_mode_config(ctrl, 0); return rp->len; } @@ -1024,6 +1013,7 @@ static int mdss_dsi_cmd_dma_tx(struct mdss_dsi_ctrl_pdata *ctrl, char *bp; unsigned long size; dma_addr_t addr; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; bp = tp->data; @@ -1045,24 +1035,27 @@ static int mdss_dsi_cmd_dma_tx(struct mdss_dsi_ctrl_pdata *ctrl, INIT_COMPLETION(ctrl->dma_comp); - if (ctrl->shared_pdata.broadcast_enable) - if ((ctrl->ndx == DSI_CTRL_1) - && (left_ctrl_pdata != NULL)) { - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x048, addr); - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x04c, len); + /* Ensure that for slave controller, master is also configured */ + if (mdss_dsi_is_slave_ctrl(ctrl)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (mctrl) { + MIPI_OUTP(mctrl->ctrl_base + 0x048, addr); + MIPI_OUTP(mctrl->ctrl_base + 0x04c, len); + } else { + pr_warn("%s: Unable to get master control\n", + __func__); } + } MIPI_OUTP((ctrl->ctrl_base) + 0x048, addr); MIPI_OUTP((ctrl->ctrl_base) + 0x04c, len); wmb(); - if (ctrl->shared_pdata.broadcast_enable) - if ((ctrl->ndx == DSI_CTRL_1) - && (left_ctrl_pdata != NULL)) { - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x090, 0x01); - } + /* Trigger on master controller as well */ + if (mctrl) + MIPI_OUTP(mctrl->ctrl_base + 0x090, 0x01); - MIPI_OUTP((ctrl->ctrl_base) + 0x090, 0x01); /* trigger */ + MIPI_OUTP((ctrl->ctrl_base) + 0x090, 0x01); wmb(); ret = wait_for_completion_timeout(&ctrl->dma_comp, @@ -1212,13 +1205,11 @@ int mdss_dsi_cmdlist_rx(struct mdss_dsi_ctrl_pdata *ctrl, len = mdss_dsi_cmds_rx(ctrl, req->cmds, req->rlen); memcpy(req->rbuf, rp->data, rp->len); /* - * For dual DSI cases, early return of controller - 0 + * For dual DSI cases, early return of master ctrl * is valid. Hence, for those cases the return value * is zero even though we don't send any commands. - * */ - if ((ctrl->shared_pdata.broadcast_enable && - ctrl->ndx == DSI_CTRL_0) || (len != 0)) + if (mdss_dsi_is_master_ctrl(ctrl) || (len != 0)) ret = 0; } else { pr_err("%s: No rx buffer provided\n", __func__); @@ -1467,6 +1458,7 @@ irqreturn_t mdss_dsi_isr(int irq, void *ptr) u32 isr; struct mdss_dsi_ctrl_pdata *ctrl = (struct mdss_dsi_ctrl_pdata *)ptr; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; if (!ctrl->ctrl_base) { pr_err("%s:%d DSI base adr no Initialized", @@ -1477,16 +1469,19 @@ irqreturn_t mdss_dsi_isr(int irq, void *ptr) isr = MIPI_INP(ctrl->ctrl_base + 0x0110);/* DSI_INTR_CTRL */ MIPI_OUTP(ctrl->ctrl_base + 0x0110, isr); - if (ctrl->shared_pdata.broadcast_enable) - if ((ctrl->panel_data.panel_info.pdest == DISPLAY_2) - && (left_ctrl_pdata != NULL)) { + if (mdss_dsi_is_slave_ctrl(ctrl)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (mctrl) { u32 isr0; - isr0 = MIPI_INP(left_ctrl_pdata->ctrl_base - + 0x0110);/* DSI_INTR_CTRL */ + isr0 = MIPI_INP(mctrl->ctrl_base + 0x0110); if (isr0 & DSI_INTR_CMD_DMA_DONE) - MIPI_OUTP(left_ctrl_pdata->ctrl_base + 0x0110, + MIPI_OUTP(mctrl->ctrl_base + 0x0110, DSI_INTR_CMD_DMA_DONE); + } else { + pr_warn("%s: Unable to get master control\n", + __func__); } + } pr_debug("%s: ndx=%d isr=%x\n", __func__, ctrl->ndx, isr); diff --git a/drivers/video/fbdev/msm/mdss_dsi_panel.c b/drivers/video/fbdev/msm/mdss_dsi_panel.c index 660eaeb7ce99..9dbe999d65d8 100644 --- a/drivers/video/fbdev/msm/mdss_dsi_panel.c +++ b/drivers/video/fbdev/msm/mdss_dsi_panel.c @@ -336,17 +336,6 @@ static int mdss_dsi_panel_partial_update(struct mdss_panel_data *pdata) return rc; } -static struct mdss_dsi_ctrl_pdata *get_rctrl_data(struct mdss_panel_data *pdata) -{ - if (!pdata || !pdata->next) { - pr_err("%s: Invalid panel data\n", __func__); - return NULL; - } - - return container_of(pdata->next, struct mdss_dsi_ctrl_pdata, - panel_data); -} - static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata, u32 bl_level) { @@ -378,15 +367,15 @@ static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata, break; case BL_DCS_CMD: mdss_dsi_panel_bklt_dcs(ctrl_pdata, bl_level); - if (ctrl_pdata->shared_pdata.broadcast_enable && - ctrl_pdata->ndx == DSI_CTRL_0) { - struct mdss_dsi_ctrl_pdata *rctrl_pdata = NULL; - rctrl_pdata = get_rctrl_data(pdata); - if (!rctrl_pdata) { - pr_err("%s: Right ctrl data NULL\n", __func__); + if (mdss_dsi_is_master_ctrl(ctrl_pdata)) { + struct mdss_dsi_ctrl_pdata *sctrl = + mdss_dsi_get_slave_ctrl(); + if (!sctrl) { + pr_err("%s: Invalid slave ctrl data\n", + __func__); return; } - mdss_dsi_panel_bklt_dcs(rctrl_pdata, bl_level); + mdss_dsi_panel_bklt_dcs(sctrl, bl_level); } break; default: diff --git a/drivers/video/fbdev/msm/msm_mdss_io_8974.c b/drivers/video/fbdev/msm/msm_mdss_io_8974.c index ee920b4a7cb1..a349d69c741e 100644 --- a/drivers/video/fbdev/msm/msm_mdss_io_8974.c +++ b/drivers/video/fbdev/msm/msm_mdss_io_8974.c @@ -26,7 +26,6 @@ #define SW_RESET_PLL BIT(0) #define PWRDN_B BIT(7) -static struct mdss_dsi_ctrl_pdata *left_ctrl; static struct dsi_clk_desc dsi_pclk; int mdss_dsi_clk_init(struct platform_device *pdev, @@ -102,15 +101,6 @@ int mdss_dsi_clk_init(struct platform_device *pdev, goto mdss_dsi_clk_err; } - if (ctrl->shared_pdata.broadcast_enable) { - if (ctrl->panel_data.panel_info.pdest - == DISPLAY_1) { - pr_debug("%s: Broadcast mode enabled.\n", - __func__); - left_ctrl = ctrl; - } - } - mdss_dsi_clk_err: if (rc) mdss_dsi_clk_deinit(ctrl); @@ -556,7 +546,18 @@ bool __mdss_dsi_clk_enabled(struct mdss_dsi_ctrl_pdata *ctrl) void mdss_dsi_clk_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, int enable) { int changed = 0; - struct mdss_dsi_ctrl_pdata *sctrl = NULL; + struct mdss_dsi_ctrl_pdata *mctrl = NULL; + + /* + * In broadcast mode, we need to enable clocks for the + * master controller as well when enabling clocks for the + * slave controller + */ + if (mdss_dsi_is_slave_ctrl(ctrl)) { + mctrl = mdss_dsi_get_master_ctrl(); + if (!mctrl) + pr_warn("%s: Unable to get master control\n", __func__); + } mutex_lock(&dsi_clk_lock); if (enable) { @@ -575,17 +576,15 @@ void mdss_dsi_clk_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, int enable) pr_debug("%s: ndx=%d clk_cnt=%d changed=%d enable=%d\n", __func__, ctrl->ndx, ctrl->clk_cnt, changed, enable); - if (ctrl->flags & DSI_FLAG_CLOCK_MASTER) - sctrl = mdss_dsi_ctrl_slave(ctrl); if (changed) { - if (enable && sctrl) - mdss_dsi_clk_ctrl_sub(sctrl, enable); + if (enable && mctrl) + mdss_dsi_clk_ctrl_sub(mctrl, enable); mdss_dsi_clk_ctrl_sub(ctrl, enable); - if (!enable && sctrl) - mdss_dsi_clk_ctrl_sub(sctrl, enable); + if (!enable && mctrl) + mdss_dsi_clk_ctrl_sub(mctrl, enable); } mutex_unlock(&dsi_clk_lock); } @@ -604,21 +603,35 @@ void mdss_dsi_phy_sw_reset(unsigned char *ctrl_base) void mdss_dsi_phy_disable(struct mdss_dsi_ctrl_pdata *ctrl) { + struct mdss_dsi_ctrl_pdata *ctrl0 = NULL; + if (ctrl == NULL) { pr_err("%s: Invalid input data\n", __func__); return; } - if (left_ctrl && - (ctrl->panel_data.panel_info.pdest == DISPLAY_1)) + /* + * In dual-dsi configuration, the phy should be disabled for the + * first controller only when the second controller is disabled. + * This is true regardless of whether broadcast mode is enabled + * or not. + */ + if ((ctrl->ndx == DSI_CTRL_0) && + mdss_dsi_get_ctrl_by_index(DSI_CTRL_1)) { + pr_debug("%s: Dual dsi detected. skipping config for ctrl%d\n", + __func__, ctrl->ndx); return; + } - if (left_ctrl && - (ctrl->panel_data.panel_info.pdest - == - DISPLAY_2)) { - MIPI_OUTP(left_ctrl->phy_io.base + 0x0170, 0x000); - MIPI_OUTP(left_ctrl->phy_io.base + 0x0298, 0x000); + if (ctrl->ndx == DSI_CTRL_1) { + ctrl0 = mdss_dsi_get_ctrl_by_index(DSI_CTRL_0); + if (ctrl0) { + MIPI_OUTP(ctrl0->phy_io.base + 0x0170, 0x000); + MIPI_OUTP(ctrl0->phy_io.base + 0x0298, 0x000); + } else { + pr_warn("%s: Unable to get control%d\n", + __func__, DSI_CTRL_0); + } } MIPI_OUTP(ctrl->phy_io.base + 0x0170, 0x000); @@ -643,22 +656,25 @@ void mdss_dsi_phy_init(struct mdss_panel_data *pdata) pr_err("%s: Invalid input data\n", __func__); return; } + temp_ctrl = ctrl_pdata; pd = &(((ctrl_pdata->panel_data).panel_info.mipi).dsi_phy_db); /* Strength ctrl 0 */ MIPI_OUTP((ctrl_pdata->phy_io.base) + 0x0184, pd->strength[0]); - /* phy regulator ctrl settings. Both the DSI controller - have one regulator */ - if ((ctrl_pdata->panel_data).panel_info.pdest == DISPLAY_1) - temp_ctrl = ctrl_pdata; - else if (left_ctrl && (pdata->panel_info.pdest == DISPLAY_2)) - temp_ctrl = left_ctrl; - - if (!temp_ctrl) { - pr_err("%s: Invalid ctrl data\n", __func__); - return; + /* + * Phy regulator ctrl settings. + * In dual dsi configuration, the second controller also uses + * the regulators of the first controller, irrespective of whether + * broadcast mode is enabled or not. + */ + if (ctrl_pdata->ndx == DSI_CTRL_1) { + temp_ctrl = mdss_dsi_get_ctrl_by_index(DSI_CTRL_0); + if (!temp_ctrl) { + pr_err("%s: Unable to get master ctrl\n", __func__); + return; + } } /* Regulator ctrl 0 */ |
