Lines Matching full:dsi

7 #define DSS_SUBSYS_NAME "DSI"
47 /* DSI Protocol Engine */
111 #define REG_GET(dsi, idx, start, end) \ argument
112 FLD_GET(dsi_read_reg(dsi, idx), start, end)
114 #define REG_FLD_MOD(dsi, idx, val, start, end) \ argument
115 dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, end))
207 static int dsi_display_init_dispc(struct dsi_data *dsi);
208 static void dsi_display_uninit_dispc(struct dsi_data *dsi);
210 static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
212 /* DSI PLL HSDIV indices */
273 struct dsi_data *dsi; member
302 DSI_QUIRK_PLL_PWR_BUG = (1 << 0), /* DSI-PLL power command 0x3 is not working */
421 struct dsi_data *dsi; member
435 static inline void dsi_write_reg(struct dsi_data *dsi, in dsi_write_reg() argument
441 case DSI_PROTO: base = dsi->proto_base; break; in dsi_write_reg()
442 case DSI_PHY: base = dsi->phy_base; break; in dsi_write_reg()
443 case DSI_PLL: base = dsi->pll_base; break; in dsi_write_reg()
450 static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx) in dsi_read_reg() argument
455 case DSI_PROTO: base = dsi->proto_base; break; in dsi_read_reg()
456 case DSI_PHY: base = dsi->phy_base; break; in dsi_read_reg()
457 case DSI_PLL: base = dsi->pll_base; break; in dsi_read_reg()
466 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_bus_lock() local
468 down(&dsi->bus_lock); in dsi_bus_lock()
473 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_bus_unlock() local
475 up(&dsi->bus_lock); in dsi_bus_unlock()
478 static bool dsi_bus_is_locked(struct dsi_data *dsi) in dsi_bus_is_locked() argument
480 return dsi->bus_lock.count == 0; in dsi_bus_is_locked()
488 static inline bool wait_for_bit_change(struct dsi_data *dsi, in wait_for_bit_change() argument
499 if (REG_GET(dsi, idx, bitnum, bitnum) == value) in wait_for_bit_change()
506 if (REG_GET(dsi, idx, bitnum, bitnum) == value) in wait_for_bit_change()
534 static void dsi_perf_mark_setup(struct dsi_data *dsi) in dsi_perf_mark_setup() argument
536 dsi->perf_setup_time = ktime_get(); in dsi_perf_mark_setup()
539 static void dsi_perf_mark_start(struct dsi_data *dsi) in dsi_perf_mark_start() argument
541 dsi->perf_start_time = ktime_get(); in dsi_perf_mark_start()
544 static void dsi_perf_show(struct dsi_data *dsi, const char *name) in dsi_perf_show() argument
555 setup_time = ktime_sub(dsi->perf_start_time, dsi->perf_setup_time); in dsi_perf_show()
560 trans_time = ktime_sub(t, dsi->perf_start_time); in dsi_perf_show()
567 total_bytes = dsi->update_bytes; in dsi_perf_show()
569 pr_info("DSI(%s): %u us + %u us = %u us (%uHz), %u bytes, %u kbytes/sec\n", in dsi_perf_show()
579 static inline void dsi_perf_mark_setup(struct dsi_data *dsi) in dsi_perf_mark_setup() argument
583 static inline void dsi_perf_mark_start(struct dsi_data *dsi) in dsi_perf_mark_start() argument
587 static inline void dsi_perf_show(struct dsi_data *dsi, const char *name) in dsi_perf_show() argument
604 pr_debug("DSI IRQ: 0x%x: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", in print_irq_status()
636 pr_debug("DSI VC(%d) IRQ 0x%x: %s%s%s%s%s%s%s%s%s\n", in print_irq_status_vc()
658 pr_debug("DSI CIO IRQ 0x%x: %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", in print_irq_status_cio()
684 static void dsi_collect_irq_stats(struct dsi_data *dsi, u32 irqstatus, in dsi_collect_irq_stats() argument
689 spin_lock(&dsi->irq_stats_lock); in dsi_collect_irq_stats()
691 dsi->irq_stats.irq_count++; in dsi_collect_irq_stats()
692 dss_collect_irq_stats(irqstatus, dsi->irq_stats.dsi_irqs); in dsi_collect_irq_stats()
695 dss_collect_irq_stats(vcstatus[i], dsi->irq_stats.vc_irqs[i]); in dsi_collect_irq_stats()
697 dss_collect_irq_stats(ciostatus, dsi->irq_stats.cio_irqs); in dsi_collect_irq_stats()
699 spin_unlock(&dsi->irq_stats_lock); in dsi_collect_irq_stats()
702 #define dsi_collect_irq_stats(dsi, irqstatus, vcstatus, ciostatus) argument
707 static void dsi_handle_irq_errors(struct dsi_data *dsi, u32 irqstatus, in dsi_handle_irq_errors() argument
713 DSSERR("DSI error, irqstatus %x\n", irqstatus); in dsi_handle_irq_errors()
715 spin_lock(&dsi->errors_lock); in dsi_handle_irq_errors()
716 dsi->errors |= irqstatus & DSI_IRQ_ERROR_MASK; in dsi_handle_irq_errors()
717 spin_unlock(&dsi->errors_lock); in dsi_handle_irq_errors()
724 DSSERR("DSI VC(%d) error, vc irqstatus %x\n", in dsi_handle_irq_errors()
733 DSSERR("DSI CIO error, cio irqstatus %x\n", ciostatus); in dsi_handle_irq_errors()
778 struct dsi_data *dsi = arg; in omap_dsi_irq_handler() local
782 if (!dsi->is_enabled) in omap_dsi_irq_handler()
785 spin_lock(&dsi->irq_lock); in omap_dsi_irq_handler()
787 irqstatus = dsi_read_reg(dsi, DSI_IRQSTATUS); in omap_dsi_irq_handler()
791 spin_unlock(&dsi->irq_lock); in omap_dsi_irq_handler()
795 dsi_write_reg(dsi, DSI_IRQSTATUS, irqstatus & ~DSI_IRQ_CHANNEL_MASK); in omap_dsi_irq_handler()
797 dsi_read_reg(dsi, DSI_IRQSTATUS); in omap_dsi_irq_handler()
805 vcstatus[i] = dsi_read_reg(dsi, DSI_VC_IRQSTATUS(i)); in omap_dsi_irq_handler()
807 dsi_write_reg(dsi, DSI_VC_IRQSTATUS(i), vcstatus[i]); in omap_dsi_irq_handler()
809 dsi_read_reg(dsi, DSI_VC_IRQSTATUS(i)); in omap_dsi_irq_handler()
813 ciostatus = dsi_read_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS); in omap_dsi_irq_handler()
815 dsi_write_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS, ciostatus); in omap_dsi_irq_handler()
817 dsi_read_reg(dsi, DSI_COMPLEXIO_IRQ_STATUS); in omap_dsi_irq_handler()
824 del_timer(&dsi->te_timer); in omap_dsi_irq_handler()
829 memcpy(&dsi->isr_tables_copy, &dsi->isr_tables, in omap_dsi_irq_handler()
830 sizeof(dsi->isr_tables)); in omap_dsi_irq_handler()
832 spin_unlock(&dsi->irq_lock); in omap_dsi_irq_handler()
834 dsi_handle_isrs(&dsi->isr_tables_copy, irqstatus, vcstatus, ciostatus); in omap_dsi_irq_handler()
836 dsi_handle_irq_errors(dsi, irqstatus, vcstatus, ciostatus); in omap_dsi_irq_handler()
838 dsi_collect_irq_stats(dsi, irqstatus, vcstatus, ciostatus); in omap_dsi_irq_handler()
843 /* dsi->irq_lock has to be locked by the caller */
844 static void _omap_dsi_configure_irqs(struct dsi_data *dsi, in _omap_dsi_configure_irqs() argument
867 old_mask = dsi_read_reg(dsi, enable_reg); in _omap_dsi_configure_irqs()
869 dsi_write_reg(dsi, status_reg, (mask ^ old_mask) & mask); in _omap_dsi_configure_irqs()
870 dsi_write_reg(dsi, enable_reg, mask); in _omap_dsi_configure_irqs()
873 dsi_read_reg(dsi, enable_reg); in _omap_dsi_configure_irqs()
874 dsi_read_reg(dsi, status_reg); in _omap_dsi_configure_irqs()
877 /* dsi->irq_lock has to be locked by the caller */
878 static void _omap_dsi_set_irqs(struct dsi_data *dsi) in _omap_dsi_set_irqs() argument
884 _omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table, in _omap_dsi_set_irqs()
885 ARRAY_SIZE(dsi->isr_tables.isr_table), mask, in _omap_dsi_set_irqs()
889 /* dsi->irq_lock has to be locked by the caller */
890 static void _omap_dsi_set_irqs_vc(struct dsi_data *dsi, int vc) in _omap_dsi_set_irqs_vc() argument
892 _omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table_vc[vc], in _omap_dsi_set_irqs_vc()
893 ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]), in _omap_dsi_set_irqs_vc()
898 /* dsi->irq_lock has to be locked by the caller */
899 static void _omap_dsi_set_irqs_cio(struct dsi_data *dsi) in _omap_dsi_set_irqs_cio() argument
901 _omap_dsi_configure_irqs(dsi, dsi->isr_tables.isr_table_cio, in _omap_dsi_set_irqs_cio()
902 ARRAY_SIZE(dsi->isr_tables.isr_table_cio), in _omap_dsi_set_irqs_cio()
907 static void _dsi_initialize_irq(struct dsi_data *dsi) in _dsi_initialize_irq() argument
912 spin_lock_irqsave(&dsi->irq_lock, flags); in _dsi_initialize_irq()
914 memset(&dsi->isr_tables, 0, sizeof(dsi->isr_tables)); in _dsi_initialize_irq()
916 _omap_dsi_set_irqs(dsi); in _dsi_initialize_irq()
918 _omap_dsi_set_irqs_vc(dsi, vc); in _dsi_initialize_irq()
919 _omap_dsi_set_irqs_cio(dsi); in _dsi_initialize_irq()
921 spin_unlock_irqrestore(&dsi->irq_lock, flags); in _dsi_initialize_irq()
980 static int dsi_register_isr(struct dsi_data *dsi, omap_dsi_isr_t isr, in dsi_register_isr() argument
986 spin_lock_irqsave(&dsi->irq_lock, flags); in dsi_register_isr()
988 r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table, in dsi_register_isr()
989 ARRAY_SIZE(dsi->isr_tables.isr_table)); in dsi_register_isr()
992 _omap_dsi_set_irqs(dsi); in dsi_register_isr()
994 spin_unlock_irqrestore(&dsi->irq_lock, flags); in dsi_register_isr()
999 static int dsi_unregister_isr(struct dsi_data *dsi, omap_dsi_isr_t isr, in dsi_unregister_isr() argument
1005 spin_lock_irqsave(&dsi->irq_lock, flags); in dsi_unregister_isr()
1007 r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table, in dsi_unregister_isr()
1008 ARRAY_SIZE(dsi->isr_tables.isr_table)); in dsi_unregister_isr()
1011 _omap_dsi_set_irqs(dsi); in dsi_unregister_isr()
1013 spin_unlock_irqrestore(&dsi->irq_lock, flags); in dsi_unregister_isr()
1018 static int dsi_register_isr_vc(struct dsi_data *dsi, int channel, in dsi_register_isr_vc() argument
1024 spin_lock_irqsave(&dsi->irq_lock, flags); in dsi_register_isr_vc()
1027 dsi->isr_tables.isr_table_vc[channel], in dsi_register_isr_vc()
1028 ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel])); in dsi_register_isr_vc()
1031 _omap_dsi_set_irqs_vc(dsi, channel); in dsi_register_isr_vc()
1033 spin_unlock_irqrestore(&dsi->irq_lock, flags); in dsi_register_isr_vc()
1038 static int dsi_unregister_isr_vc(struct dsi_data *dsi, int channel, in dsi_unregister_isr_vc() argument
1044 spin_lock_irqsave(&dsi->irq_lock, flags); in dsi_unregister_isr_vc()
1047 dsi->isr_tables.isr_table_vc[channel], in dsi_unregister_isr_vc()
1048 ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel])); in dsi_unregister_isr_vc()
1051 _omap_dsi_set_irqs_vc(dsi, channel); in dsi_unregister_isr_vc()
1053 spin_unlock_irqrestore(&dsi->irq_lock, flags); in dsi_unregister_isr_vc()
1058 static int dsi_register_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr, in dsi_register_isr_cio() argument
1064 spin_lock_irqsave(&dsi->irq_lock, flags); in dsi_register_isr_cio()
1066 r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio, in dsi_register_isr_cio()
1067 ARRAY_SIZE(dsi->isr_tables.isr_table_cio)); in dsi_register_isr_cio()
1070 _omap_dsi_set_irqs_cio(dsi); in dsi_register_isr_cio()
1072 spin_unlock_irqrestore(&dsi->irq_lock, flags); in dsi_register_isr_cio()
1077 static int dsi_unregister_isr_cio(struct dsi_data *dsi, omap_dsi_isr_t isr, in dsi_unregister_isr_cio() argument
1083 spin_lock_irqsave(&dsi->irq_lock, flags); in dsi_unregister_isr_cio()
1085 r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio, in dsi_unregister_isr_cio()
1086 ARRAY_SIZE(dsi->isr_tables.isr_table_cio)); in dsi_unregister_isr_cio()
1089 _omap_dsi_set_irqs_cio(dsi); in dsi_unregister_isr_cio()
1091 spin_unlock_irqrestore(&dsi->irq_lock, flags); in dsi_unregister_isr_cio()
1096 static u32 dsi_get_errors(struct dsi_data *dsi) in dsi_get_errors() argument
1101 spin_lock_irqsave(&dsi->errors_lock, flags); in dsi_get_errors()
1102 e = dsi->errors; in dsi_get_errors()
1103 dsi->errors = 0; in dsi_get_errors()
1104 spin_unlock_irqrestore(&dsi->errors_lock, flags); in dsi_get_errors()
1108 static int dsi_runtime_get(struct dsi_data *dsi) in dsi_runtime_get() argument
1114 r = pm_runtime_get_sync(dsi->dev); in dsi_runtime_get()
1119 static void dsi_runtime_put(struct dsi_data *dsi) in dsi_runtime_put() argument
1125 r = pm_runtime_put_sync(dsi->dev); in dsi_runtime_put()
1129 static void _dsi_print_reset_status(struct dsi_data *dsi) in _dsi_print_reset_status() argument
1135 * required after DSIPHY reset to complete the reset of the DSI complex in _dsi_print_reset_status()
1137 l = dsi_read_reg(dsi, DSI_DSIPHY_CFG5); in _dsi_print_reset_status()
1139 if (dsi->data->quirks & DSI_QUIRK_REVERSE_TXCLKESC) { in _dsi_print_reset_status()
1150 FLD_GET(dsi_read_reg(dsi, DSI_##fld), start, end) in _dsi_print_reset_status()
1152 pr_debug("DSI resets: PLL (%d) CIO (%d) PHY (%x%x%x, %d, %d, %d)\n", in _dsi_print_reset_status()
1165 static inline int dsi_if_enable(struct dsi_data *dsi, bool enable) in dsi_if_enable() argument
1170 REG_FLD_MOD(dsi, DSI_CTRL, enable, 0, 0); /* IF_EN */ in dsi_if_enable()
1172 if (!wait_for_bit_change(dsi, DSI_CTRL, 0, enable)) { in dsi_if_enable()
1180 static unsigned long dsi_get_pll_hsdiv_dispc_rate(struct dsi_data *dsi) in dsi_get_pll_hsdiv_dispc_rate() argument
1182 return dsi->pll.cinfo.clkout[HSDIV_DISPC]; in dsi_get_pll_hsdiv_dispc_rate()
1185 static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct dsi_data *dsi) in dsi_get_pll_hsdiv_dsi_rate() argument
1187 return dsi->pll.cinfo.clkout[HSDIV_DSI]; in dsi_get_pll_hsdiv_dsi_rate()
1190 static unsigned long dsi_get_txbyteclkhs(struct dsi_data *dsi) in dsi_get_txbyteclkhs() argument
1192 return dsi->pll.cinfo.clkdco / 16; in dsi_get_txbyteclkhs()
1195 static unsigned long dsi_fclk_rate(struct dsi_data *dsi) in dsi_fclk_rate() argument
1200 source = dss_get_dsi_clk_source(dsi->dss, dsi->module_id); in dsi_fclk_rate()
1202 /* DSI FCLK source is DSS_CLK_FCK */ in dsi_fclk_rate()
1203 r = clk_get_rate(dsi->dss_clk); in dsi_fclk_rate()
1205 /* DSI FCLK source is dsi_pll_hsdiv_dsi_clk */ in dsi_fclk_rate()
1206 r = dsi_get_pll_hsdiv_dsi_rate(dsi); in dsi_fclk_rate()
1231 static int dsi_set_lp_clk_divisor(struct dsi_data *dsi) in dsi_set_lp_clk_divisor() argument
1236 unsigned int lpdiv_max = dsi->data->max_pll_lpdiv; in dsi_set_lp_clk_divisor()
1239 lp_clk_div = dsi->user_lp_cinfo.lp_clk_div; in dsi_set_lp_clk_divisor()
1244 dsi_fclk = dsi_fclk_rate(dsi); in dsi_set_lp_clk_divisor()
1249 dsi->current_lp_cinfo.lp_clk = lp_clk; in dsi_set_lp_clk_divisor()
1250 dsi->current_lp_cinfo.lp_clk_div = lp_clk_div; in dsi_set_lp_clk_divisor()
1253 REG_FLD_MOD(dsi, DSI_CLK_CTRL, lp_clk_div, 12, 0); in dsi_set_lp_clk_divisor()
1256 REG_FLD_MOD(dsi, DSI_CLK_CTRL, dsi_fclk > 30000000 ? 1 : 0, 21, 21); in dsi_set_lp_clk_divisor()
1261 static void dsi_enable_scp_clk(struct dsi_data *dsi) in dsi_enable_scp_clk() argument
1263 if (dsi->scp_clk_refcount++ == 0) in dsi_enable_scp_clk()
1264 REG_FLD_MOD(dsi, DSI_CLK_CTRL, 1, 14, 14); /* CIO_CLK_ICG */ in dsi_enable_scp_clk()
1267 static void dsi_disable_scp_clk(struct dsi_data *dsi) in dsi_disable_scp_clk() argument
1269 WARN_ON(dsi->scp_clk_refcount == 0); in dsi_disable_scp_clk()
1270 if (--dsi->scp_clk_refcount == 0) in dsi_disable_scp_clk()
1271 REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 14, 14); /* CIO_CLK_ICG */ in dsi_disable_scp_clk()
1281 static int dsi_pll_power(struct dsi_data *dsi, enum dsi_pll_power_state state) in dsi_pll_power() argument
1285 /* DSI-PLL power command 0x3 is not working */ in dsi_pll_power()
1286 if ((dsi->data->quirks & DSI_QUIRK_PLL_PWR_BUG) && in dsi_pll_power()
1291 REG_FLD_MOD(dsi, DSI_CLK_CTRL, state, 31, 30); in dsi_pll_power()
1294 while (FLD_GET(dsi_read_reg(dsi, DSI_CLK_CTRL), 29, 28) != state) { in dsi_pll_power()
1296 DSSERR("Failed to set DSI PLL power mode to %d\n", in dsi_pll_power()
1307 static void dsi_pll_calc_dsi_fck(struct dsi_data *dsi, in dsi_pll_calc_dsi_fck() argument
1312 max_dsi_fck = dsi->data->max_fck_freq; in dsi_pll_calc_dsi_fck()
1320 struct dsi_data *dsi = container_of(pll, struct dsi_data, pll); in dsi_pll_enable() local
1325 r = dsi_runtime_get(dsi); in dsi_pll_enable()
1332 dsi_enable_scp_clk(dsi); in dsi_pll_enable()
1334 r = regulator_enable(dsi->vdds_dsi_reg); in dsi_pll_enable()
1339 dispc_pck_free_enable(dsi->dss->dispc, 1); in dsi_pll_enable()
1341 if (!wait_for_bit_change(dsi, DSI_PLL_STATUS, 0, 1)) { in dsi_pll_enable()
1344 dispc_pck_free_enable(dsi->dss->dispc, 0); in dsi_pll_enable()
1350 dispc_pck_free_enable(dsi->dss->dispc, 0); in dsi_pll_enable()
1352 r = dsi_pll_power(dsi, DSI_PLL_POWER_ON_ALL); in dsi_pll_enable()
1361 regulator_disable(dsi->vdds_dsi_reg); in dsi_pll_enable()
1363 dsi_disable_scp_clk(dsi); in dsi_pll_enable()
1364 dsi_runtime_put(dsi); in dsi_pll_enable()
1370 struct dsi_data *dsi = container_of(pll, struct dsi_data, pll); in dsi_pll_disable() local
1372 dsi_pll_power(dsi, DSI_PLL_POWER_OFF); in dsi_pll_disable()
1374 regulator_disable(dsi->vdds_dsi_reg); in dsi_pll_disable()
1376 dsi_disable_scp_clk(dsi); in dsi_pll_disable()
1377 dsi_runtime_put(dsi); in dsi_pll_disable()
1384 struct dsi_data *dsi = s->private; in dsi_dump_dsi_clocks() local
1385 struct dss_pll_clock_info *cinfo = &dsi->pll.cinfo; in dsi_dump_dsi_clocks()
1387 int dsi_module = dsi->module_id; in dsi_dump_dsi_clocks()
1388 struct dss_pll *pll = &dsi->pll; in dsi_dump_dsi_clocks()
1390 dispc_clk_src = dss_get_dispc_clk_source(dsi->dss); in dsi_dump_dsi_clocks()
1391 dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module); in dsi_dump_dsi_clocks()
1393 if (dsi_runtime_get(dsi)) in dsi_dump_dsi_clocks()
1396 seq_printf(s, "- DSI%d PLL -\n", dsi_module + 1); in dsi_dump_dsi_clocks()
1398 seq_printf(s, "dsi pll clkin\t%lu\n", clk_get_rate(pll->clkin)); in dsi_dump_dsi_clocks()
1423 seq_printf(s, "- DSI%d -\n", dsi_module + 1); in dsi_dump_dsi_clocks()
1425 seq_printf(s, "dsi fclk source = %s\n", in dsi_dump_dsi_clocks()
1428 seq_printf(s, "DSI_FCLK\t%lu\n", dsi_fclk_rate(dsi)); in dsi_dump_dsi_clocks()
1433 seq_printf(s, "TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsi)); in dsi_dump_dsi_clocks()
1435 seq_printf(s, "LP_CLK\t\t%lu\n", dsi->current_lp_cinfo.lp_clk); in dsi_dump_dsi_clocks()
1437 dsi_runtime_put(dsi); in dsi_dump_dsi_clocks()
1445 struct dsi_data *dsi = s->private; in dsi_dump_dsi_irqs() local
1449 spin_lock_irqsave(&dsi->irq_stats_lock, flags); in dsi_dump_dsi_irqs()
1451 stats = dsi->irq_stats; in dsi_dump_dsi_irqs()
1452 memset(&dsi->irq_stats, 0, sizeof(dsi->irq_stats)); in dsi_dump_dsi_irqs()
1453 dsi->irq_stats.last_reset = jiffies; in dsi_dump_dsi_irqs()
1455 spin_unlock_irqrestore(&dsi->irq_stats_lock, flags); in dsi_dump_dsi_irqs()
1464 seq_printf(s, "-- DSI%d interrupts --\n", dsi->module_id + 1); in dsi_dump_dsi_irqs()
1536 struct dsi_data *dsi = s->private; in dsi_dump_dsi_regs() local
1538 if (dsi_runtime_get(dsi)) in dsi_dump_dsi_regs()
1540 dsi_enable_scp_clk(dsi); in dsi_dump_dsi_regs()
1542 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsi, r)) in dsi_dump_dsi_regs()
1614 dsi_disable_scp_clk(dsi); in dsi_dump_dsi_regs()
1615 dsi_runtime_put(dsi); in dsi_dump_dsi_regs()
1626 static int dsi_cio_power(struct dsi_data *dsi, enum dsi_cio_power_state state) in dsi_cio_power() argument
1631 REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG1, state, 28, 27); in dsi_cio_power()
1634 while (FLD_GET(dsi_read_reg(dsi, DSI_COMPLEXIO_CFG1), in dsi_cio_power()
1647 static unsigned int dsi_get_line_buf_size(struct dsi_data *dsi) in dsi_get_line_buf_size() argument
1655 if (!(dsi->data->quirks & DSI_QUIRK_GNQ)) in dsi_get_line_buf_size()
1658 val = REG_GET(dsi, DSI_GNQ, 14, 12); /* VP1_LINE_BUFFER_SIZE */ in dsi_get_line_buf_size()
1681 static int dsi_set_lane_config(struct dsi_data *dsi) in dsi_set_lane_config() argument
1694 r = dsi_read_reg(dsi, DSI_COMPLEXIO_CFG1); in dsi_set_lane_config()
1696 for (i = 0; i < dsi->num_lanes_used; ++i) { in dsi_set_lane_config()
1701 for (t = 0; t < dsi->num_lanes_supported; ++t) in dsi_set_lane_config()
1702 if (dsi->lanes[t].function == functions[i]) in dsi_set_lane_config()
1705 if (t == dsi->num_lanes_supported) in dsi_set_lane_config()
1709 polarity = dsi->lanes[t].polarity; in dsi_set_lane_config()
1716 for (; i < dsi->num_lanes_supported; ++i) { in dsi_set_lane_config()
1723 dsi_write_reg(dsi, DSI_COMPLEXIO_CFG1, r); in dsi_set_lane_config()
1728 static inline unsigned int ns2ddr(struct dsi_data *dsi, unsigned int ns) in ns2ddr() argument
1731 unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4; in ns2ddr()
1736 static inline unsigned int ddr2ns(struct dsi_data *dsi, unsigned int ddr) in ddr2ns() argument
1738 unsigned long ddr_clk = dsi->pll.cinfo.clkdco / 4; in ddr2ns()
1743 static void dsi_cio_timings(struct dsi_data *dsi) in dsi_cio_timings() argument
1755 ths_prepare = ns2ddr(dsi, 70) + 2; in dsi_cio_timings()
1758 ths_prepare_ths_zero = ns2ddr(dsi, 175) + 2; in dsi_cio_timings()
1761 ths_trail = ns2ddr(dsi, 60) + 5; in dsi_cio_timings()
1764 ths_exit = ns2ddr(dsi, 145); in dsi_cio_timings()
1767 tlpx_half = ns2ddr(dsi, 25); in dsi_cio_timings()
1770 tclk_trail = ns2ddr(dsi, 60) + 2; in dsi_cio_timings()
1773 tclk_prepare = ns2ddr(dsi, 65); in dsi_cio_timings()
1776 tclk_zero = ns2ddr(dsi, 260); in dsi_cio_timings()
1779 ths_prepare, ddr2ns(dsi, ths_prepare), in dsi_cio_timings()
1780 ths_prepare_ths_zero, ddr2ns(dsi, ths_prepare_ths_zero)); in dsi_cio_timings()
1782 ths_trail, ddr2ns(dsi, ths_trail), in dsi_cio_timings()
1783 ths_exit, ddr2ns(dsi, ths_exit)); in dsi_cio_timings()
1787 tlpx_half, ddr2ns(dsi, tlpx_half), in dsi_cio_timings()
1788 tclk_trail, ddr2ns(dsi, tclk_trail), in dsi_cio_timings()
1789 tclk_zero, ddr2ns(dsi, tclk_zero)); in dsi_cio_timings()
1791 tclk_prepare, ddr2ns(dsi, tclk_prepare)); in dsi_cio_timings()
1795 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0); in dsi_cio_timings()
1800 dsi_write_reg(dsi, DSI_DSIPHY_CFG0, r); in dsi_cio_timings()
1802 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1); in dsi_cio_timings()
1807 if (dsi->data->quirks & DSI_QUIRK_PHY_DCC) { in dsi_cio_timings()
1813 dsi_write_reg(dsi, DSI_DSIPHY_CFG1, r); in dsi_cio_timings()
1815 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG2); in dsi_cio_timings()
1817 dsi_write_reg(dsi, DSI_DSIPHY_CFG2, r); in dsi_cio_timings()
1821 static void dsi_cio_enable_lane_override(struct dsi_data *dsi, in dsi_cio_enable_lane_override() argument
1827 u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26; in dsi_cio_enable_lane_override()
1831 for (i = 0; i < dsi->num_lanes_supported; ++i) { in dsi_cio_enable_lane_override()
1832 unsigned int p = dsi->lanes[i].polarity; in dsi_cio_enable_lane_override()
1853 REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, l, lptxscp_start, 17); in dsi_cio_enable_lane_override()
1858 REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 1, 27, 27); in dsi_cio_enable_lane_override()
1861 static void dsi_cio_disable_lane_override(struct dsi_data *dsi) in dsi_cio_disable_lane_override() argument
1864 REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */ in dsi_cio_disable_lane_override()
1867 REG_FLD_MOD(dsi, DSI_DSIPHY_CFG10, 0, 22, 17); in dsi_cio_disable_lane_override()
1870 static int dsi_cio_wait_tx_clk_esc_reset(struct dsi_data *dsi) in dsi_cio_wait_tx_clk_esc_reset() argument
1878 if (dsi->data->quirks & DSI_QUIRK_REVERSE_TXCLKESC) in dsi_cio_wait_tx_clk_esc_reset()
1883 for (i = 0; i < dsi->num_lanes_supported; ++i) in dsi_cio_wait_tx_clk_esc_reset()
1884 in_use[i] = dsi->lanes[i].function != DSI_LANE_UNUSED; in dsi_cio_wait_tx_clk_esc_reset()
1891 l = dsi_read_reg(dsi, DSI_DSIPHY_CFG5); in dsi_cio_wait_tx_clk_esc_reset()
1894 for (i = 0; i < dsi->num_lanes_supported; ++i) { in dsi_cio_wait_tx_clk_esc_reset()
1899 if (ok == dsi->num_lanes_supported) in dsi_cio_wait_tx_clk_esc_reset()
1903 for (i = 0; i < dsi->num_lanes_supported; ++i) { in dsi_cio_wait_tx_clk_esc_reset()
1918 static unsigned int dsi_get_lane_mask(struct dsi_data *dsi) in dsi_get_lane_mask() argument
1923 for (i = 0; i < dsi->num_lanes_supported; ++i) { in dsi_get_lane_mask()
1924 if (dsi->lanes[i].function != DSI_LANE_UNUSED) in dsi_get_lane_mask()
1943 static int dsi_omap4_mux_pads(struct dsi_data *dsi, unsigned int lanes) in dsi_omap4_mux_pads() argument
1948 if (dsi->module_id == 0) { in dsi_omap4_mux_pads()
1953 } else if (dsi->module_id == 1) { in dsi_omap4_mux_pads()
1962 return regmap_update_bits(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, in dsi_omap4_mux_pads()
1975 static int dsi_omap5_mux_pads(struct dsi_data *dsi, unsigned int lanes) in dsi_omap5_mux_pads() argument
1979 if (dsi->module_id == 0) in dsi_omap5_mux_pads()
1981 else if (dsi->module_id == 1) in dsi_omap5_mux_pads()
1986 return regmap_update_bits(dsi->syscon, OMAP5_DSIPHY_SYSCON_OFFSET, in dsi_omap5_mux_pads()
1991 static int dsi_enable_pads(struct dsi_data *dsi, unsigned int lane_mask) in dsi_enable_pads() argument
1993 if (dsi->data->model == DSI_MODEL_OMAP4) in dsi_enable_pads()
1994 return dsi_omap4_mux_pads(dsi, lane_mask); in dsi_enable_pads()
1995 if (dsi->data->model == DSI_MODEL_OMAP5) in dsi_enable_pads()
1996 return dsi_omap5_mux_pads(dsi, lane_mask); in dsi_enable_pads()
2000 static void dsi_disable_pads(struct dsi_data *dsi) in dsi_disable_pads() argument
2002 if (dsi->data->model == DSI_MODEL_OMAP4) in dsi_disable_pads()
2003 dsi_omap4_mux_pads(dsi, 0); in dsi_disable_pads()
2004 else if (dsi->data->model == DSI_MODEL_OMAP5) in dsi_disable_pads()
2005 dsi_omap5_mux_pads(dsi, 0); in dsi_disable_pads()
2008 static int dsi_cio_init(struct dsi_data *dsi) in dsi_cio_init() argument
2013 DSSDBG("DSI CIO init starts"); in dsi_cio_init()
2015 r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsi)); in dsi_cio_init()
2019 dsi_enable_scp_clk(dsi); in dsi_cio_init()
2022 * required after DSIPHY reset to complete the reset of the DSI complex in dsi_cio_init()
2024 dsi_read_reg(dsi, DSI_DSIPHY_CFG5); in dsi_cio_init()
2026 if (!wait_for_bit_change(dsi, DSI_DSIPHY_CFG5, 30, 1)) { in dsi_cio_init()
2032 r = dsi_set_lane_config(dsi); in dsi_cio_init()
2037 l = dsi_read_reg(dsi, DSI_TIMING1); in dsi_cio_init()
2042 dsi_write_reg(dsi, DSI_TIMING1, l); in dsi_cio_init()
2044 if (dsi->ulps_enabled) { in dsi_cio_init()
2061 for (i = 0; i < dsi->num_lanes_supported; ++i) { in dsi_cio_init()
2062 if (dsi->lanes[i].function == DSI_LANE_UNUSED) in dsi_cio_init()
2067 dsi_cio_enable_lane_override(dsi, mask_p, 0); in dsi_cio_init()
2070 r = dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ON); in dsi_cio_init()
2074 if (!wait_for_bit_change(dsi, DSI_COMPLEXIO_CFG1, 29, 1)) { in dsi_cio_init()
2080 dsi_if_enable(dsi, true); in dsi_cio_init()
2081 dsi_if_enable(dsi, false); in dsi_cio_init()
2082 REG_FLD_MOD(dsi, DSI_CLK_CTRL, 1, 20, 20); /* LP_CLK_ENABLE */ in dsi_cio_init()
2084 r = dsi_cio_wait_tx_clk_esc_reset(dsi); in dsi_cio_init()
2088 if (dsi->ulps_enabled) { in dsi_cio_init()
2089 /* Keep Mark-1 state for 1ms (as per DSI spec) */ in dsi_cio_init()
2096 dsi_cio_disable_lane_override(dsi); in dsi_cio_init()
2100 REG_FLD_MOD(dsi, DSI_TIMING1, 0, 15, 15); in dsi_cio_init()
2102 dsi_cio_timings(dsi); in dsi_cio_init()
2104 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_cio_init()
2106 REG_FLD_MOD(dsi, DSI_CLK_CTRL, in dsi_cio_init()
2107 dsi->vm_timings.ddr_clk_always_on, 13, 13); in dsi_cio_init()
2110 dsi->ulps_enabled = false; in dsi_cio_init()
2117 REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 20, 20); /* LP_CLK_ENABLE */ in dsi_cio_init()
2119 dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF); in dsi_cio_init()
2121 if (dsi->ulps_enabled) in dsi_cio_init()
2122 dsi_cio_disable_lane_override(dsi); in dsi_cio_init()
2124 dsi_disable_scp_clk(dsi); in dsi_cio_init()
2125 dsi_disable_pads(dsi); in dsi_cio_init()
2129 static void dsi_cio_uninit(struct dsi_data *dsi) in dsi_cio_uninit() argument
2132 REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13); in dsi_cio_uninit()
2134 dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_OFF); in dsi_cio_uninit()
2135 dsi_disable_scp_clk(dsi); in dsi_cio_uninit()
2136 dsi_disable_pads(dsi); in dsi_cio_uninit()
2139 static void dsi_config_tx_fifo(struct dsi_data *dsi, in dsi_config_tx_fifo() argument
2147 dsi->vc[0].tx_fifo_size = size1; in dsi_config_tx_fifo()
2148 dsi->vc[1].tx_fifo_size = size2; in dsi_config_tx_fifo()
2149 dsi->vc[2].tx_fifo_size = size3; in dsi_config_tx_fifo()
2150 dsi->vc[3].tx_fifo_size = size4; in dsi_config_tx_fifo()
2154 int size = dsi->vc[i].tx_fifo_size; in dsi_config_tx_fifo()
2168 dsi_write_reg(dsi, DSI_TX_FIFO_VC_SIZE, r); in dsi_config_tx_fifo()
2171 static void dsi_config_rx_fifo(struct dsi_data *dsi, in dsi_config_rx_fifo() argument
2179 dsi->vc[0].rx_fifo_size = size1; in dsi_config_rx_fifo()
2180 dsi->vc[1].rx_fifo_size = size2; in dsi_config_rx_fifo()
2181 dsi->vc[2].rx_fifo_size = size3; in dsi_config_rx_fifo()
2182 dsi->vc[3].rx_fifo_size = size4; in dsi_config_rx_fifo()
2186 int size = dsi->vc[i].rx_fifo_size; in dsi_config_rx_fifo()
2200 dsi_write_reg(dsi, DSI_RX_FIFO_VC_SIZE, r); in dsi_config_rx_fifo()
2203 static int dsi_force_tx_stop_mode_io(struct dsi_data *dsi) in dsi_force_tx_stop_mode_io() argument
2207 r = dsi_read_reg(dsi, DSI_TIMING1); in dsi_force_tx_stop_mode_io()
2209 dsi_write_reg(dsi, DSI_TIMING1, r); in dsi_force_tx_stop_mode_io()
2211 if (!wait_for_bit_change(dsi, DSI_TIMING1, 15, 0)) { in dsi_force_tx_stop_mode_io()
2219 static bool dsi_vc_is_enabled(struct dsi_data *dsi, int channel) in dsi_vc_is_enabled() argument
2221 return REG_GET(dsi, DSI_VC_CTRL(channel), 0, 0); in dsi_vc_is_enabled()
2228 struct dsi_data *dsi = vp_data->dsi; in dsi_packet_sent_handler_vp() local
2229 const int channel = dsi->update_channel; in dsi_packet_sent_handler_vp()
2230 u8 bit = dsi->te_enabled ? 30 : 31; in dsi_packet_sent_handler_vp()
2232 if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit) == 0) in dsi_packet_sent_handler_vp()
2236 static int dsi_sync_vc_vp(struct dsi_data *dsi, int channel) in dsi_sync_vc_vp() argument
2240 .dsi = dsi, in dsi_sync_vc_vp()
2246 bit = dsi->te_enabled ? 30 : 31; in dsi_sync_vc_vp()
2248 r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_vp, in dsi_sync_vc_vp()
2254 if (REG_GET(dsi, DSI_VC_TE(channel), bit, bit)) { in dsi_sync_vc_vp()
2263 dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp, in dsi_sync_vc_vp()
2268 dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_vp, in dsi_sync_vc_vp()
2278 struct dsi_data *dsi = l4_data->dsi; in dsi_packet_sent_handler_l4() local
2279 const int channel = dsi->update_channel; in dsi_packet_sent_handler_l4()
2281 if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5) == 0) in dsi_packet_sent_handler_l4()
2285 static int dsi_sync_vc_l4(struct dsi_data *dsi, int channel) in dsi_sync_vc_l4() argument
2289 .dsi = dsi, in dsi_sync_vc_l4()
2294 r = dsi_register_isr_vc(dsi, channel, dsi_packet_sent_handler_l4, in dsi_sync_vc_l4()
2300 if (REG_GET(dsi, DSI_VC_CTRL(channel), 5, 5)) { in dsi_sync_vc_l4()
2309 dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4, in dsi_sync_vc_l4()
2314 dsi_unregister_isr_vc(dsi, channel, dsi_packet_sent_handler_l4, in dsi_sync_vc_l4()
2320 static int dsi_sync_vc(struct dsi_data *dsi, int channel) in dsi_sync_vc() argument
2322 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_sync_vc()
2326 if (!dsi_vc_is_enabled(dsi, channel)) in dsi_sync_vc()
2329 switch (dsi->vc[channel].source) { in dsi_sync_vc()
2331 return dsi_sync_vc_vp(dsi, channel); in dsi_sync_vc()
2333 return dsi_sync_vc_l4(dsi, channel); in dsi_sync_vc()
2340 static int dsi_vc_enable(struct dsi_data *dsi, int channel, bool enable) in dsi_vc_enable() argument
2347 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 0, 0); in dsi_vc_enable()
2349 if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 0, enable)) { in dsi_vc_enable()
2357 static void dsi_vc_initial_config(struct dsi_data *dsi, int channel) in dsi_vc_initial_config() argument
2363 r = dsi_read_reg(dsi, DSI_VC_CTRL(channel)); in dsi_vc_initial_config()
2376 if (dsi->data->quirks & DSI_QUIRK_VC_OCP_WIDTH) in dsi_vc_initial_config()
2382 dsi_write_reg(dsi, DSI_VC_CTRL(channel), r); in dsi_vc_initial_config()
2384 dsi->vc[channel].source = DSI_VC_SOURCE_L4; in dsi_vc_initial_config()
2387 static int dsi_vc_config_source(struct dsi_data *dsi, int channel, in dsi_vc_config_source() argument
2390 if (dsi->vc[channel].source == source) in dsi_vc_config_source()
2395 dsi_sync_vc(dsi, channel); in dsi_vc_config_source()
2397 dsi_vc_enable(dsi, channel, 0); in dsi_vc_config_source()
2400 if (!wait_for_bit_change(dsi, DSI_VC_CTRL(channel), 15, 0)) { in dsi_vc_config_source()
2406 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), source, 1, 1); in dsi_vc_config_source()
2409 if (dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC) { in dsi_vc_config_source()
2411 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 30, 30); in dsi_vc_config_source()
2414 dsi_vc_enable(dsi, channel, 1); in dsi_vc_config_source()
2416 dsi->vc[channel].source = source; in dsi_vc_config_source()
2424 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_enable_hs() local
2428 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_vc_enable_hs()
2430 dsi_vc_enable(dsi, channel, 0); in dsi_vc_enable_hs()
2431 dsi_if_enable(dsi, 0); in dsi_vc_enable_hs()
2433 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), enable, 9, 9); in dsi_vc_enable_hs()
2435 dsi_vc_enable(dsi, channel, 1); in dsi_vc_enable_hs()
2436 dsi_if_enable(dsi, 1); in dsi_vc_enable_hs()
2438 dsi_force_tx_stop_mode_io(dsi); in dsi_vc_enable_hs()
2441 if (dsi->vm_timings.ddr_clk_always_on && enable) in dsi_vc_enable_hs()
2442 dsi_vc_send_null(dsi, channel); in dsi_vc_enable_hs()
2445 static void dsi_vc_flush_long_data(struct dsi_data *dsi, int channel) in dsi_vc_flush_long_data() argument
2447 while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) { in dsi_vc_flush_long_data()
2449 val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel)); in dsi_vc_flush_long_data()
2495 static u16 dsi_vc_flush_receive_data(struct dsi_data *dsi, int channel) in dsi_vc_flush_receive_data() argument
2498 while (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) { in dsi_vc_flush_receive_data()
2501 val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel)); in dsi_vc_flush_receive_data()
2516 dsi_vc_flush_long_data(dsi, channel); in dsi_vc_flush_receive_data()
2524 static int dsi_vc_send_bta(struct dsi_data *dsi, int channel) in dsi_vc_send_bta() argument
2526 if (dsi->debug_write || dsi->debug_read) in dsi_vc_send_bta()
2529 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_vc_send_bta()
2532 if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) { in dsi_vc_send_bta()
2534 dsi_vc_flush_receive_data(dsi, channel); in dsi_vc_send_bta()
2537 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */ in dsi_vc_send_bta()
2540 dsi_read_reg(dsi, DSI_VC_CTRL(channel)); in dsi_vc_send_bta()
2547 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_send_bta_sync() local
2552 r = dsi_register_isr_vc(dsi, channel, dsi_completion_handler, in dsi_vc_send_bta_sync()
2557 r = dsi_register_isr(dsi, dsi_completion_handler, &completion, in dsi_vc_send_bta_sync()
2562 r = dsi_vc_send_bta(dsi, channel); in dsi_vc_send_bta_sync()
2573 err = dsi_get_errors(dsi); in dsi_vc_send_bta_sync()
2580 dsi_unregister_isr(dsi, dsi_completion_handler, &completion, in dsi_vc_send_bta_sync()
2583 dsi_unregister_isr_vc(dsi, channel, dsi_completion_handler, in dsi_vc_send_bta_sync()
2589 static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel, in dsi_vc_write_long_header() argument
2595 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_vc_write_long_header()
2597 data_id = data_type | dsi->vc[channel].vc_id << 6; in dsi_vc_write_long_header()
2602 dsi_write_reg(dsi, DSI_VC_LONG_PACKET_HEADER(channel), val); in dsi_vc_write_long_header()
2605 static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel, in dsi_vc_write_long_payload() argument
2615 dsi_write_reg(dsi, DSI_VC_LONG_PACKET_PAYLOAD(channel), val); in dsi_vc_write_long_payload()
2618 static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type, in dsi_vc_send_long() argument
2627 if (dsi->debug_write) in dsi_vc_send_long()
2631 if (dsi->vc[channel].tx_fifo_size * 32 * 4 < len + 4) { in dsi_vc_send_long()
2636 dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4); in dsi_vc_send_long()
2638 dsi_vc_write_long_header(dsi, channel, data_type, len, ecc); in dsi_vc_send_long()
2642 if (dsi->debug_write) in dsi_vc_send_long()
2650 dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, b4); in dsi_vc_send_long()
2657 if (dsi->debug_write) in dsi_vc_send_long()
2675 dsi_vc_write_long_payload(dsi, channel, b1, b2, b3, 0); in dsi_vc_send_long()
2681 static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type, in dsi_vc_send_short() argument
2687 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_vc_send_short()
2689 if (dsi->debug_write) in dsi_vc_send_short()
2694 dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_L4); in dsi_vc_send_short()
2696 if (FLD_GET(dsi_read_reg(dsi, DSI_VC_CTRL(channel)), 16, 16)) { in dsi_vc_send_short()
2701 data_id = data_type | dsi->vc[channel].vc_id << 6; in dsi_vc_send_short()
2705 dsi_write_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel), r); in dsi_vc_send_short()
2710 static int dsi_vc_send_null(struct dsi_data *dsi, int channel) in dsi_vc_send_null() argument
2712 return dsi_vc_send_long(dsi, channel, MIPI_DSI_NULL_PACKET, NULL, 0, 0); in dsi_vc_send_null()
2715 static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel, in dsi_vc_write_nosync_common() argument
2723 r = dsi_vc_send_short(dsi, channel, in dsi_vc_write_nosync_common()
2726 r = dsi_vc_send_short(dsi, channel, in dsi_vc_write_nosync_common()
2731 r = dsi_vc_send_short(dsi, channel, in dsi_vc_write_nosync_common()
2737 r = dsi_vc_send_long(dsi, channel, in dsi_vc_write_nosync_common()
2749 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_dcs_write_nosync() local
2751 return dsi_vc_write_nosync_common(dsi, channel, data, len, in dsi_vc_dcs_write_nosync()
2758 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_generic_write_nosync() local
2760 return dsi_vc_write_nosync_common(dsi, channel, data, len, in dsi_vc_generic_write_nosync()
2768 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_write_common() local
2771 r = dsi_vc_write_nosync_common(dsi, channel, data, len, type); in dsi_vc_write_common()
2780 if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20)) { in dsi_vc_write_common()
2782 dsi_vc_flush_receive_data(dsi, channel); in dsi_vc_write_common()
2808 static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel, in dsi_vc_dcs_send_read_request() argument
2813 if (dsi->debug_read) in dsi_vc_dcs_send_read_request()
2817 r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0); in dsi_vc_dcs_send_read_request()
2827 static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel, in dsi_vc_generic_send_read_request() argument
2834 if (dsi->debug_read) in dsi_vc_generic_send_read_request()
2852 r = dsi_vc_send_short(dsi, channel, data_type, data, 0); in dsi_vc_generic_send_read_request()
2862 static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf, in dsi_vc_read_rx_fifo() argument
2870 if (REG_GET(dsi, DSI_VC_CTRL(channel), 20, 20) == 0) { in dsi_vc_read_rx_fifo()
2876 val = dsi_read_reg(dsi, DSI_VC_SHORT_PACKET_HEADER(channel)); in dsi_vc_read_rx_fifo()
2877 if (dsi->debug_read) in dsi_vc_read_rx_fifo()
2890 if (dsi->debug_read) in dsi_vc_read_rx_fifo()
2907 if (dsi->debug_read) in dsi_vc_read_rx_fifo()
2926 if (dsi->debug_read) in dsi_vc_read_rx_fifo()
2939 val = dsi_read_reg(dsi, in dsi_vc_read_rx_fifo()
2941 if (dsi->debug_read) in dsi_vc_read_rx_fifo()
2973 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_dcs_read() local
2976 r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd); in dsi_vc_dcs_read()
2984 r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen, in dsi_vc_dcs_read()
3003 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_generic_read() local
3006 r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen); in dsi_vc_generic_read()
3014 r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen, in dsi_vc_generic_read()
3030 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_vc_set_max_rx_packet_size() local
3032 return dsi_vc_send_short(dsi, channel, in dsi_vc_set_max_rx_packet_size()
3036 static int dsi_enter_ulps(struct dsi_data *dsi) in dsi_enter_ulps() argument
3044 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_enter_ulps()
3046 WARN_ON(dsi->ulps_enabled); in dsi_enter_ulps()
3048 if (dsi->ulps_enabled) in dsi_enter_ulps()
3052 if (REG_GET(dsi, DSI_CLK_CTRL, 13, 13)) { in dsi_enter_ulps()
3053 dsi_if_enable(dsi, 0); in dsi_enter_ulps()
3054 REG_FLD_MOD(dsi, DSI_CLK_CTRL, 0, 13, 13); in dsi_enter_ulps()
3055 dsi_if_enable(dsi, 1); in dsi_enter_ulps()
3058 dsi_sync_vc(dsi, 0); in dsi_enter_ulps()
3059 dsi_sync_vc(dsi, 1); in dsi_enter_ulps()
3060 dsi_sync_vc(dsi, 2); in dsi_enter_ulps()
3061 dsi_sync_vc(dsi, 3); in dsi_enter_ulps()
3063 dsi_force_tx_stop_mode_io(dsi); in dsi_enter_ulps()
3065 dsi_vc_enable(dsi, 0, false); in dsi_enter_ulps()
3066 dsi_vc_enable(dsi, 1, false); in dsi_enter_ulps()
3067 dsi_vc_enable(dsi, 2, false); in dsi_enter_ulps()
3068 dsi_vc_enable(dsi, 3, false); in dsi_enter_ulps()
3070 if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 16, 16)) { /* HS_BUSY */ in dsi_enter_ulps()
3075 if (REG_GET(dsi, DSI_COMPLEXIO_CFG2, 17, 17)) { /* LP_BUSY */ in dsi_enter_ulps()
3080 r = dsi_register_isr_cio(dsi, dsi_completion_handler, &completion, in dsi_enter_ulps()
3087 for (i = 0; i < dsi->num_lanes_supported; ++i) { in dsi_enter_ulps()
3088 if (dsi->lanes[i].function == DSI_LANE_UNUSED) in dsi_enter_ulps()
3094 REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, mask, 9, 5); in dsi_enter_ulps()
3097 dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2); in dsi_enter_ulps()
3106 dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion, in dsi_enter_ulps()
3110 REG_FLD_MOD(dsi, DSI_COMPLEXIO_CFG2, 0, 9, 5); in dsi_enter_ulps()
3113 dsi_read_reg(dsi, DSI_COMPLEXIO_CFG2); in dsi_enter_ulps()
3115 dsi_cio_power(dsi, DSI_COMPLEXIO_POWER_ULPS); in dsi_enter_ulps()
3117 dsi_if_enable(dsi, false); in dsi_enter_ulps()
3119 dsi->ulps_enabled = true; in dsi_enter_ulps()
3124 dsi_unregister_isr_cio(dsi, dsi_completion_handler, &completion, in dsi_enter_ulps()
3129 static void dsi_set_lp_rx_timeout(struct dsi_data *dsi, unsigned int ticks, in dsi_set_lp_rx_timeout() argument
3139 fck = dsi_fclk_rate(dsi); in dsi_set_lp_rx_timeout()
3141 r = dsi_read_reg(dsi, DSI_TIMING2); in dsi_set_lp_rx_timeout()
3146 dsi_write_reg(dsi, DSI_TIMING2, r); in dsi_set_lp_rx_timeout()
3156 static void dsi_set_ta_timeout(struct dsi_data *dsi, unsigned int ticks, in dsi_set_ta_timeout() argument
3166 fck = dsi_fclk_rate(dsi); in dsi_set_ta_timeout()
3168 r = dsi_read_reg(dsi, DSI_TIMING1); in dsi_set_ta_timeout()
3173 dsi_write_reg(dsi, DSI_TIMING1, r); in dsi_set_ta_timeout()
3183 static void dsi_set_stop_state_counter(struct dsi_data *dsi, unsigned int ticks, in dsi_set_stop_state_counter() argument
3193 fck = dsi_fclk_rate(dsi); in dsi_set_stop_state_counter()
3195 r = dsi_read_reg(dsi, DSI_TIMING1); in dsi_set_stop_state_counter()
3200 dsi_write_reg(dsi, DSI_TIMING1, r); in dsi_set_stop_state_counter()
3210 static void dsi_set_hs_tx_timeout(struct dsi_data *dsi, unsigned int ticks, in dsi_set_hs_tx_timeout() argument
3220 fck = dsi_get_txbyteclkhs(dsi); in dsi_set_hs_tx_timeout()
3222 r = dsi_read_reg(dsi, DSI_TIMING2); in dsi_set_hs_tx_timeout()
3227 dsi_write_reg(dsi, DSI_TIMING2, r); in dsi_set_hs_tx_timeout()
3237 static void dsi_config_vp_num_line_buffers(struct dsi_data *dsi) in dsi_config_vp_num_line_buffers() argument
3241 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_config_vp_num_line_buffers()
3242 int bpp = dsi_get_pixel_size(dsi->pix_fmt); in dsi_config_vp_num_line_buffers()
3243 const struct videomode *vm = &dsi->vm; in dsi_config_vp_num_line_buffers()
3248 if (dsi->line_buffer_size <= vm->hactive * bpp / 8) in dsi_config_vp_num_line_buffers()
3258 REG_FLD_MOD(dsi, DSI_CTRL, num_line_buffers, 13, 12); in dsi_config_vp_num_line_buffers()
3261 static void dsi_config_vp_sync_events(struct dsi_data *dsi) in dsi_config_vp_sync_events() argument
3266 if (dsi->vm_timings.trans_mode == OMAP_DSS_DSI_PULSE_MODE) in dsi_config_vp_sync_events()
3271 r = dsi_read_reg(dsi, DSI_CTRL); in dsi_config_vp_sync_events()
3279 dsi_write_reg(dsi, DSI_CTRL, r); in dsi_config_vp_sync_events()
3282 static void dsi_config_blanking_modes(struct dsi_data *dsi) in dsi_config_blanking_modes() argument
3284 int blanking_mode = dsi->vm_timings.blanking_mode; in dsi_config_blanking_modes()
3285 int hfp_blanking_mode = dsi->vm_timings.hfp_blanking_mode; in dsi_config_blanking_modes()
3286 int hbp_blanking_mode = dsi->vm_timings.hbp_blanking_mode; in dsi_config_blanking_modes()
3287 int hsa_blanking_mode = dsi->vm_timings.hsa_blanking_mode; in dsi_config_blanking_modes()
3294 r = dsi_read_reg(dsi, DSI_CTRL); in dsi_config_blanking_modes()
3299 dsi_write_reg(dsi, DSI_CTRL, r); in dsi_config_blanking_modes()
3364 static void dsi_config_cmd_mode_interleaving(struct dsi_data *dsi) in dsi_config_cmd_mode_interleaving() argument
3372 const struct videomode *vm = &dsi->vm; in dsi_config_cmd_mode_interleaving()
3373 int bpp = dsi_get_pixel_size(dsi->pix_fmt); in dsi_config_cmd_mode_interleaving()
3374 int ndl = dsi->num_lanes_used - 1; in dsi_config_cmd_mode_interleaving()
3375 int dsi_fclk_hsdiv = dsi->user_dsi_cinfo.mX[HSDIV_DSI] + 1; in dsi_config_cmd_mode_interleaving()
3382 r = dsi_read_reg(dsi, DSI_CTRL); in dsi_config_cmd_mode_interleaving()
3388 r = dsi_read_reg(dsi, DSI_VM_TIMING1); in dsi_config_cmd_mode_interleaving()
3393 r = dsi_read_reg(dsi, DSI_CLK_TIMING); in dsi_config_cmd_mode_interleaving()
3397 r = dsi_read_reg(dsi, DSI_VM_TIMING7); in dsi_config_cmd_mode_interleaving()
3401 r = dsi_read_reg(dsi, DSI_CLK_CTRL); in dsi_config_cmd_mode_interleaving()
3405 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0); in dsi_config_cmd_mode_interleaving()
3408 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1); in dsi_config_cmd_mode_interleaving()
3454 DSSDBG("DSI HS interleaving(TXBYTECLKHS) HSA %d, HFP %d, HBP %d, BLLP %d\n", in dsi_config_cmd_mode_interleaving()
3458 DSSDBG("DSI LP interleaving(bytes) HSA %d, HFP %d, HBP %d, BLLP %d\n", in dsi_config_cmd_mode_interleaving()
3462 r = dsi_read_reg(dsi, DSI_VM_TIMING4); in dsi_config_cmd_mode_interleaving()
3466 dsi_write_reg(dsi, DSI_VM_TIMING4, r); in dsi_config_cmd_mode_interleaving()
3468 r = dsi_read_reg(dsi, DSI_VM_TIMING5); in dsi_config_cmd_mode_interleaving()
3472 dsi_write_reg(dsi, DSI_VM_TIMING5, r); in dsi_config_cmd_mode_interleaving()
3474 r = dsi_read_reg(dsi, DSI_VM_TIMING6); in dsi_config_cmd_mode_interleaving()
3477 dsi_write_reg(dsi, DSI_VM_TIMING6, r); in dsi_config_cmd_mode_interleaving()
3480 static int dsi_proto_config(struct dsi_data *dsi) in dsi_proto_config() argument
3485 dsi_config_tx_fifo(dsi, DSI_FIFO_SIZE_32, in dsi_proto_config()
3490 dsi_config_rx_fifo(dsi, DSI_FIFO_SIZE_32, in dsi_proto_config()
3496 dsi_set_stop_state_counter(dsi, 0x1000, false, false); in dsi_proto_config()
3497 dsi_set_ta_timeout(dsi, 0x1fff, true, true); in dsi_proto_config()
3498 dsi_set_lp_rx_timeout(dsi, 0x1fff, true, true); in dsi_proto_config()
3499 dsi_set_hs_tx_timeout(dsi, 0x1fff, true, true); in dsi_proto_config()
3501 switch (dsi_get_pixel_size(dsi->pix_fmt)) { in dsi_proto_config()
3516 r = dsi_read_reg(dsi, DSI_CTRL); in dsi_proto_config()
3525 if (!(dsi->data->quirks & DSI_QUIRK_DCS_CMD_CONFIG_VC)) { in dsi_proto_config()
3531 dsi_write_reg(dsi, DSI_CTRL, r); in dsi_proto_config()
3533 dsi_config_vp_num_line_buffers(dsi); in dsi_proto_config()
3535 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_proto_config()
3536 dsi_config_vp_sync_events(dsi); in dsi_proto_config()
3537 dsi_config_blanking_modes(dsi); in dsi_proto_config()
3538 dsi_config_cmd_mode_interleaving(dsi); in dsi_proto_config()
3541 dsi_vc_initial_config(dsi, 0); in dsi_proto_config()
3542 dsi_vc_initial_config(dsi, 1); in dsi_proto_config()
3543 dsi_vc_initial_config(dsi, 2); in dsi_proto_config()
3544 dsi_vc_initial_config(dsi, 3); in dsi_proto_config()
3549 static void dsi_proto_timings(struct dsi_data *dsi) in dsi_proto_timings() argument
3558 int ndl = dsi->num_lanes_used - 1; in dsi_proto_timings()
3561 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG0); in dsi_proto_timings()
3568 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG1); in dsi_proto_timings()
3572 r = dsi_read_reg(dsi, DSI_DSIPHY_CFG2); in dsi_proto_timings()
3578 tclk_post = ns2ddr(dsi, 60) + 26; in dsi_proto_timings()
3589 r = dsi_read_reg(dsi, DSI_CLK_TIMING); in dsi_proto_timings()
3592 dsi_write_reg(dsi, DSI_CLK_TIMING, r); in dsi_proto_timings()
3606 dsi_write_reg(dsi, DSI_VM_TIMING7, r); in dsi_proto_timings()
3611 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_proto_timings()
3613 int hsa = dsi->vm_timings.hsa; in dsi_proto_timings()
3614 int hfp = dsi->vm_timings.hfp; in dsi_proto_timings()
3615 int hbp = dsi->vm_timings.hbp; in dsi_proto_timings()
3616 int vsa = dsi->vm_timings.vsa; in dsi_proto_timings()
3617 int vfp = dsi->vm_timings.vfp; in dsi_proto_timings()
3618 int vbp = dsi->vm_timings.vbp; in dsi_proto_timings()
3619 int window_sync = dsi->vm_timings.window_sync; in dsi_proto_timings()
3621 const struct videomode *vm = &dsi->vm; in dsi_proto_timings()
3622 int bpp = dsi_get_pixel_size(dsi->pix_fmt); in dsi_proto_timings()
3625 hsync_end = dsi->vm_timings.trans_mode == OMAP_DSS_DSI_PULSE_MODE; in dsi_proto_timings()
3640 r = dsi_read_reg(dsi, DSI_VM_TIMING1); in dsi_proto_timings()
3644 dsi_write_reg(dsi, DSI_VM_TIMING1, r); in dsi_proto_timings()
3646 r = dsi_read_reg(dsi, DSI_VM_TIMING2); in dsi_proto_timings()
3651 dsi_write_reg(dsi, DSI_VM_TIMING2, r); in dsi_proto_timings()
3653 r = dsi_read_reg(dsi, DSI_VM_TIMING3); in dsi_proto_timings()
3656 dsi_write_reg(dsi, DSI_VM_TIMING3, r); in dsi_proto_timings()
3663 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_configure_pins() local
3681 if (num_pins < 4 || num_pins > dsi->num_lanes_supported * 2 in dsi_configure_pins()
3697 if (dx < 0 || dx >= dsi->num_lanes_supported * 2) in dsi_configure_pins()
3700 if (dy < 0 || dy >= dsi->num_lanes_supported * 2) in dsi_configure_pins()
3720 memcpy(dsi->lanes, lanes, sizeof(dsi->lanes)); in dsi_configure_pins()
3721 dsi->num_lanes_used = num_lanes; in dsi_configure_pins()
3728 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_enable_video_output() local
3729 int bpp = dsi_get_pixel_size(dsi->pix_fmt); in dsi_enable_video_output()
3734 r = dsi_display_init_dispc(dsi); in dsi_enable_video_output()
3738 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_enable_video_output()
3739 switch (dsi->pix_fmt) { in dsi_enable_video_output()
3757 dsi_if_enable(dsi, false); in dsi_enable_video_output()
3758 dsi_vc_enable(dsi, channel, false); in dsi_enable_video_output()
3761 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 1, 4, 4); in dsi_enable_video_output()
3763 word_count = DIV_ROUND_UP(dsi->vm.hactive * bpp, 8); in dsi_enable_video_output()
3765 dsi_vc_write_long_header(dsi, channel, data_type, in dsi_enable_video_output()
3768 dsi_vc_enable(dsi, channel, true); in dsi_enable_video_output()
3769 dsi_if_enable(dsi, true); in dsi_enable_video_output()
3772 r = dss_mgr_enable(&dsi->output); in dsi_enable_video_output()
3779 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_enable_video_output()
3780 dsi_if_enable(dsi, false); in dsi_enable_video_output()
3781 dsi_vc_enable(dsi, channel, false); in dsi_enable_video_output()
3784 dsi_display_uninit_dispc(dsi); in dsi_enable_video_output()
3790 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_disable_video_output() local
3792 if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { in dsi_disable_video_output()
3793 dsi_if_enable(dsi, false); in dsi_disable_video_output()
3794 dsi_vc_enable(dsi, channel, false); in dsi_disable_video_output()
3797 REG_FLD_MOD(dsi, DSI_VC_CTRL(channel), 0, 4, 4); in dsi_disable_video_output()
3799 dsi_vc_enable(dsi, channel, true); in dsi_disable_video_output()
3800 dsi_if_enable(dsi, true); in dsi_disable_video_output()
3803 dss_mgr_disable(&dsi->output); in dsi_disable_video_output()
3805 dsi_display_uninit_dispc(dsi); in dsi_disable_video_output()
3808 static void dsi_update_screen_dispc(struct dsi_data *dsi) in dsi_update_screen_dispc() argument
3818 const unsigned channel = dsi->update_channel; in dsi_update_screen_dispc()
3819 const unsigned int line_buf_size = dsi->line_buffer_size; in dsi_update_screen_dispc()
3820 u16 w = dsi->vm.hactive; in dsi_update_screen_dispc()
3821 u16 h = dsi->vm.vactive; in dsi_update_screen_dispc()
3825 dsi_vc_config_source(dsi, channel, DSI_VC_SOURCE_VP); in dsi_update_screen_dispc()
3827 bytespp = dsi_get_pixel_size(dsi->pix_fmt) / 8; in dsi_update_screen_dispc()
3846 dsi_write_reg(dsi, DSI_VC_TE(channel), l); in dsi_update_screen_dispc()
3848 dsi_vc_write_long_header(dsi, channel, MIPI_DSI_DCS_LONG_WRITE, in dsi_update_screen_dispc()
3851 if (dsi->te_enabled) in dsi_update_screen_dispc()
3855 dsi_write_reg(dsi, DSI_VC_TE(channel), l); in dsi_update_screen_dispc()
3863 dispc_disable_sidle(dsi->dss->dispc); in dsi_update_screen_dispc()
3865 dsi_perf_mark_start(dsi); in dsi_update_screen_dispc()
3867 r = schedule_delayed_work(&dsi->framedone_timeout_work, in dsi_update_screen_dispc()
3871 dss_mgr_start_update(&dsi->output); in dsi_update_screen_dispc()
3873 if (dsi->te_enabled) { in dsi_update_screen_dispc()
3876 REG_FLD_MOD(dsi, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */ in dsi_update_screen_dispc()
3878 dsi_vc_send_bta(dsi, channel); in dsi_update_screen_dispc()
3881 mod_timer(&dsi->te_timer, jiffies + msecs_to_jiffies(250)); in dsi_update_screen_dispc()
3893 static void dsi_handle_framedone(struct dsi_data *dsi, int error) in dsi_handle_framedone() argument
3896 dispc_enable_sidle(dsi->dss->dispc); in dsi_handle_framedone()
3898 if (dsi->te_enabled) { in dsi_handle_framedone()
3900 REG_FLD_MOD(dsi, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */ in dsi_handle_framedone()
3903 dsi->framedone_callback(error, dsi->framedone_data); in dsi_handle_framedone()
3906 dsi_perf_show(dsi, "DISPC"); in dsi_handle_framedone()
3911 struct dsi_data *dsi = container_of(work, struct dsi_data, in dsi_framedone_timeout_work_callback() local
3918 * DSI */ in dsi_framedone_timeout_work_callback()
3922 dsi_handle_framedone(dsi, -ETIMEDOUT); in dsi_framedone_timeout_work_callback()
3927 struct dsi_data *dsi = data; in dsi_framedone_irq_callback() local
3930 * turns itself off. However, DSI still has the pixels in its buffers, in dsi_framedone_irq_callback()
3934 cancel_delayed_work(&dsi->framedone_timeout_work); in dsi_framedone_irq_callback()
3936 dsi_handle_framedone(dsi, 0); in dsi_framedone_irq_callback()
3942 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_update() local
3945 dsi_perf_mark_setup(dsi); in dsi_update()
3947 dsi->update_channel = channel; in dsi_update()
3949 dsi->framedone_callback = callback; in dsi_update()
3950 dsi->framedone_data = data; in dsi_update()
3952 dw = dsi->vm.hactive; in dsi_update()
3953 dh = dsi->vm.vactive; in dsi_update()
3956 dsi->update_bytes = dw * dh * in dsi_update()
3957 dsi_get_pixel_size(dsi->pix_fmt) / 8; in dsi_update()
3959 dsi_update_screen_dispc(dsi); in dsi_update()
3966 static int dsi_configure_dispc_clocks(struct dsi_data *dsi) in dsi_configure_dispc_clocks() argument
3972 fck = dsi_get_pll_hsdiv_dispc_rate(dsi); in dsi_configure_dispc_clocks()
3974 dispc_cinfo.lck_div = dsi->user_dispc_cinfo.lck_div; in dsi_configure_dispc_clocks()
3975 dispc_cinfo.pck_div = dsi->user_dispc_cinfo.pck_div; in dsi_configure_dispc_clocks()
3977 r = dispc_calc_clock_rates(dsi->dss->dispc, fck, &dispc_cinfo); in dsi_configure_dispc_clocks()
3983 dsi->mgr_config.clock_info = dispc_cinfo; in dsi_configure_dispc_clocks()
3988 static int dsi_display_init_dispc(struct dsi_data *dsi) in dsi_display_init_dispc() argument
3990 enum omap_channel channel = dsi->output.dispc_channel; in dsi_display_init_dispc()
3993 dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ? in dsi_display_init_dispc()
3997 if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) { in dsi_display_init_dispc()
3998 r = dss_mgr_register_framedone_handler(&dsi->output, in dsi_display_init_dispc()
3999 dsi_framedone_irq_callback, dsi); in dsi_display_init_dispc()
4005 dsi->mgr_config.stallmode = true; in dsi_display_init_dispc()
4006 dsi->mgr_config.fifohandcheck = true; in dsi_display_init_dispc()
4008 dsi->mgr_config.stallmode = false; in dsi_display_init_dispc()
4009 dsi->mgr_config.fifohandcheck = false; in dsi_display_init_dispc()
4012 r = dsi_configure_dispc_clocks(dsi); in dsi_display_init_dispc()
4016 dsi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS; in dsi_display_init_dispc()
4017 dsi->mgr_config.video_port_width = in dsi_display_init_dispc()
4018 dsi_get_pixel_size(dsi->pix_fmt); in dsi_display_init_dispc()
4019 dsi->mgr_config.lcden_sig_polarity = 0; in dsi_display_init_dispc()
4021 dss_mgr_set_lcd_config(&dsi->output, &dsi->mgr_config); in dsi_display_init_dispc()
4025 if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) in dsi_display_init_dispc()
4026 dss_mgr_unregister_framedone_handler(&dsi->output, in dsi_display_init_dispc()
4027 dsi_framedone_irq_callback, dsi); in dsi_display_init_dispc()
4029 dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK); in dsi_display_init_dispc()
4033 static void dsi_display_uninit_dispc(struct dsi_data *dsi) in dsi_display_uninit_dispc() argument
4035 enum omap_channel channel = dsi->output.dispc_channel; in dsi_display_uninit_dispc()
4037 if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) in dsi_display_uninit_dispc()
4038 dss_mgr_unregister_framedone_handler(&dsi->output, in dsi_display_uninit_dispc()
4039 dsi_framedone_irq_callback, dsi); in dsi_display_uninit_dispc()
4041 dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK); in dsi_display_uninit_dispc()
4044 static int dsi_configure_dsi_clocks(struct dsi_data *dsi) in dsi_configure_dsi_clocks() argument
4049 cinfo = dsi->user_dsi_cinfo; in dsi_configure_dsi_clocks()
4051 r = dss_pll_set_config(&dsi->pll, &cinfo); in dsi_configure_dsi_clocks()
4053 DSSERR("Failed to set dsi clocks\n"); in dsi_configure_dsi_clocks()
4060 static int dsi_display_init_dsi(struct dsi_data *dsi) in dsi_display_init_dsi() argument
4064 r = dss_pll_enable(&dsi->pll); in dsi_display_init_dsi()
4068 r = dsi_configure_dsi_clocks(dsi); in dsi_display_init_dsi()
4072 dss_select_dsi_clk_source(dsi->dss, dsi->module_id, in dsi_display_init_dsi()
4073 dsi->module_id == 0 ? in dsi_display_init_dsi()
4078 if (!dsi->vdds_dsi_enabled) { in dsi_display_init_dsi()
4079 r = regulator_enable(dsi->vdds_dsi_reg); in dsi_display_init_dsi()
4083 dsi->vdds_dsi_enabled = true; in dsi_display_init_dsi()
4086 r = dsi_cio_init(dsi); in dsi_display_init_dsi()
4090 _dsi_print_reset_status(dsi); in dsi_display_init_dsi()
4092 dsi_proto_timings(dsi); in dsi_display_init_dsi()
4093 dsi_set_lp_clk_divisor(dsi); in dsi_display_init_dsi()
4096 _dsi_print_reset_status(dsi); in dsi_display_init_dsi()
4098 r = dsi_proto_config(dsi); in dsi_display_init_dsi()
4103 dsi_vc_enable(dsi, 0, 1); in dsi_display_init_dsi()
4104 dsi_vc_enable(dsi, 1, 1); in dsi_display_init_dsi()
4105 dsi_vc_enable(dsi, 2, 1); in dsi_display_init_dsi()
4106 dsi_vc_enable(dsi, 3, 1); in dsi_display_init_dsi()
4107 dsi_if_enable(dsi, 1); in dsi_display_init_dsi()
4108 dsi_force_tx_stop_mode_io(dsi); in dsi_display_init_dsi()
4112 dsi_cio_uninit(dsi); in dsi_display_init_dsi()
4114 regulator_disable(dsi->vdds_dsi_reg); in dsi_display_init_dsi()
4115 dsi->vdds_dsi_enabled = false; in dsi_display_init_dsi()
4117 dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK); in dsi_display_init_dsi()
4119 dss_pll_disable(&dsi->pll); in dsi_display_init_dsi()
4124 static void dsi_display_uninit_dsi(struct dsi_data *dsi, bool disconnect_lanes, in dsi_display_uninit_dsi() argument
4127 if (enter_ulps && !dsi->ulps_enabled) in dsi_display_uninit_dsi()
4128 dsi_enter_ulps(dsi); in dsi_display_uninit_dsi()
4131 dsi_if_enable(dsi, 0); in dsi_display_uninit_dsi()
4132 dsi_vc_enable(dsi, 0, 0); in dsi_display_uninit_dsi()
4133 dsi_vc_enable(dsi, 1, 0); in dsi_display_uninit_dsi()
4134 dsi_vc_enable(dsi, 2, 0); in dsi_display_uninit_dsi()
4135 dsi_vc_enable(dsi, 3, 0); in dsi_display_uninit_dsi()
4137 dss_select_dsi_clk_source(dsi->dss, dsi->module_id, DSS_CLK_SRC_FCK); in dsi_display_uninit_dsi()
4138 dsi_cio_uninit(dsi); in dsi_display_uninit_dsi()
4139 dss_pll_disable(&dsi->pll); in dsi_display_uninit_dsi()
4142 regulator_disable(dsi->vdds_dsi_reg); in dsi_display_uninit_dsi()
4143 dsi->vdds_dsi_enabled = false; in dsi_display_uninit_dsi()
4149 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_display_enable() local
4154 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_display_enable()
4156 mutex_lock(&dsi->lock); in dsi_display_enable()
4158 r = dsi_runtime_get(dsi); in dsi_display_enable()
4162 _dsi_initialize_irq(dsi); in dsi_display_enable()
4164 r = dsi_display_init_dsi(dsi); in dsi_display_enable()
4168 mutex_unlock(&dsi->lock); in dsi_display_enable()
4173 dsi_runtime_put(dsi); in dsi_display_enable()
4175 mutex_unlock(&dsi->lock); in dsi_display_enable()
4182 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_display_disable() local
4186 WARN_ON(!dsi_bus_is_locked(dsi)); in dsi_display_disable()
4188 mutex_lock(&dsi->lock); in dsi_display_disable()
4190 dsi_sync_vc(dsi, 0); in dsi_display_disable()
4191 dsi_sync_vc(dsi, 1); in dsi_display_disable()
4192 dsi_sync_vc(dsi, 2); in dsi_display_disable()
4193 dsi_sync_vc(dsi, 3); in dsi_display_disable()
4195 dsi_display_uninit_dsi(dsi, disconnect_lanes, enter_ulps); in dsi_display_disable()
4197 dsi_runtime_put(dsi); in dsi_display_disable()
4199 mutex_unlock(&dsi->lock); in dsi_display_disable()
4204 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_enable_te() local
4206 dsi->te_enabled = enable; in dsi_enable_te()
4325 return dispc_div_calc(ctx->dsi->dss->dispc, dispc, in dsi_cm_calc_hsdiv_cb()
4334 struct dsi_data *dsi = ctx->dsi; in dsi_cm_calc_pll_cb() local
4342 dsi->data->max_fck_freq, in dsi_cm_calc_pll_cb()
4346 static bool dsi_cm_calc(struct dsi_data *dsi, in dsi_cm_calc() argument
4355 clkin = clk_get_rate(dsi->pll.clkin); in dsi_cm_calc()
4357 ndl = dsi->num_lanes_used - 1; in dsi_cm_calc()
4370 ctx->dsi = dsi; in dsi_cm_calc()
4371 ctx->pll = &dsi->pll; in dsi_cm_calc()
4387 struct dsi_data *dsi = ctx->dsi; in dsi_vm_calc_blanking() local
4390 int ndl = dsi->num_lanes_used - 1; in dsi_vm_calc_blanking()
4424 * When there are no line buffers, DISPC and DSI must have the in dsi_vm_calc_blanking()
4425 * same tput. Otherwise DISPC tput needs to be higher than DSI's. in dsi_vm_calc_blanking()
4427 if (dsi->line_buffer_size < xres * bitspp / 8) { in dsi_vm_calc_blanking()
4435 /* DSI tput must be over the min requirement */ in dsi_vm_calc_blanking()
4439 /* When non-burst mode, DSI tput must be below max requirement. */ in dsi_vm_calc_blanking()
4456 /* DSI htot to match the panel's nominal pck */ in dsi_vm_calc_blanking()
4463 /* total DSI blanking needed to achieve panel's TL */ in dsi_vm_calc_blanking()
4466 /* DISPC htot to match the DSI TL */ in dsi_vm_calc_blanking()
4469 /* verify that the DSI and DISPC TLs are the same */ in dsi_vm_calc_blanking()
4475 /* setup DSI videomode */ in dsi_vm_calc_blanking()
4599 print_dsi_vm("dsi ", &ctx->dsi_vm); in dsi_vm_calc_dispc_cb()
4626 return dispc_div_calc(ctx->dsi->dss->dispc, dispc, in dsi_vm_calc_hsdiv_cb()
4635 struct dsi_data *dsi = ctx->dsi; in dsi_vm_calc_pll_cb() local
4643 dsi->data->max_fck_freq, in dsi_vm_calc_pll_cb()
4647 static bool dsi_vm_calc(struct dsi_data *dsi, in dsi_vm_calc() argument
4655 int ndl = dsi->num_lanes_used - 1; in dsi_vm_calc()
4659 clkin = clk_get_rate(dsi->pll.clkin); in dsi_vm_calc()
4662 ctx->dsi = dsi; in dsi_vm_calc()
4663 ctx->pll = &dsi->pll; in dsi_vm_calc()
4692 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_set_config() local
4697 mutex_lock(&dsi->lock); in dsi_set_config()
4699 dsi->pix_fmt = config->pixel_format; in dsi_set_config()
4700 dsi->mode = config->mode; in dsi_set_config()
4703 ok = dsi_vm_calc(dsi, config, &ctx); in dsi_set_config()
4705 ok = dsi_cm_calc(dsi, config, &ctx); in dsi_set_config()
4708 DSSERR("failed to find suitable DSI clock settings\n"); in dsi_set_config()
4713 dsi_pll_calc_dsi_fck(dsi, &ctx.dsi_cinfo); in dsi_set_config()
4716 config->lp_clk_min, config->lp_clk_max, &dsi->user_lp_cinfo); in dsi_set_config()
4718 DSSERR("failed to find suitable DSI LP clock settings\n"); in dsi_set_config()
4722 dsi->user_dsi_cinfo = ctx.dsi_cinfo; in dsi_set_config()
4723 dsi->user_dispc_cinfo = ctx.dispc_cinfo; in dsi_set_config()
4725 dsi->vm = ctx.vm; in dsi_set_config()
4731 dsi->vm.flags &= ~DISPLAY_FLAGS_INTERLACED; in dsi_set_config()
4732 dsi->vm.flags &= ~DISPLAY_FLAGS_HSYNC_LOW; in dsi_set_config()
4733 dsi->vm.flags |= DISPLAY_FLAGS_HSYNC_HIGH; in dsi_set_config()
4734 dsi->vm.flags &= ~DISPLAY_FLAGS_VSYNC_LOW; in dsi_set_config()
4735 dsi->vm.flags |= DISPLAY_FLAGS_VSYNC_HIGH; in dsi_set_config()
4738 * flags, but this will only be possible when the DSI encoder will be in dsi_set_config()
4741 dsi->vm.flags &= ~DISPLAY_FLAGS_PIXDATA_NEGEDGE; in dsi_set_config()
4742 dsi->vm.flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE; in dsi_set_config()
4743 dsi->vm.flags &= ~DISPLAY_FLAGS_DE_LOW; in dsi_set_config()
4744 dsi->vm.flags |= DISPLAY_FLAGS_DE_HIGH; in dsi_set_config()
4745 dsi->vm.flags &= ~DISPLAY_FLAGS_SYNC_POSEDGE; in dsi_set_config()
4746 dsi->vm.flags |= DISPLAY_FLAGS_SYNC_NEGEDGE; in dsi_set_config()
4748 dss_mgr_set_timings(&dsi->output, &dsi->vm); in dsi_set_config()
4750 dsi->vm_timings = ctx.dsi_vm; in dsi_set_config()
4752 mutex_unlock(&dsi->lock); in dsi_set_config()
4756 mutex_unlock(&dsi->lock); in dsi_set_config()
4762 * Return a hardcoded channel for the DSI output. This should work for
4767 static enum omap_channel dsi_get_channel(struct dsi_data *dsi) in dsi_get_channel() argument
4769 switch (dsi->data->model) { in dsi_get_channel()
4774 switch (dsi->module_id) { in dsi_get_channel()
4785 switch (dsi->module_id) { in dsi_get_channel()
4803 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_request_vc() local
4806 for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { in dsi_request_vc()
4807 if (!dsi->vc[i].dssdev) { in dsi_request_vc()
4808 dsi->vc[i].dssdev = dssdev; in dsi_request_vc()
4820 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_set_vc_id() local
4832 if (dsi->vc[channel].dssdev != dssdev) { in dsi_set_vc_id()
4838 dsi->vc[channel].vc_id = vc_id; in dsi_set_vc_id()
4845 struct dsi_data *dsi = to_dsi_data(dssdev); in dsi_release_vc() local
4848 dsi->vc[channel].dssdev == dssdev) { in dsi_release_vc()
4849 dsi->vc[channel].dssdev = NULL; in dsi_release_vc()
4850 dsi->vc[channel].vc_id = 0; in dsi_release_vc()
4855 static int dsi_get_clocks(struct dsi_data *dsi) in dsi_get_clocks() argument
4859 clk = devm_clk_get(dsi->dev, "fck"); in dsi_get_clocks()
4865 dsi->dss_clk = clk; in dsi_get_clocks()
4887 .dsi = {
5014 static int dsi_init_pll_data(struct dss_device *dss, struct dsi_data *dsi) in dsi_init_pll_data() argument
5016 struct dss_pll *pll = &dsi->pll; in dsi_init_pll_data()
5020 clk = devm_clk_get(dsi->dev, "sys_clk"); in dsi_init_pll_data()
5026 pll->name = dsi->module_id == 0 ? "dsi0" : "dsi1"; in dsi_init_pll_data()
5027 pll->id = dsi->module_id == 0 ? DSS_PLL_DSI1 : DSS_PLL_DSI2; in dsi_init_pll_data()
5029 pll->base = dsi->pll_base; in dsi_init_pll_data()
5030 pll->hw = dsi->data->pll_hw; in dsi_init_pll_data()
5047 struct dsi_data *dsi = dev_get_drvdata(dev); in dsi_bind() local
5052 dsi->dss = dss; in dsi_bind()
5054 dsi_init_pll_data(dss, dsi); in dsi_bind()
5056 r = dsi_runtime_get(dsi); in dsi_bind()
5060 rev = dsi_read_reg(dsi, DSI_REVISION); in dsi_bind()
5061 dev_dbg(dev, "OMAP DSI rev %d.%d\n", in dsi_bind()
5064 dsi->line_buffer_size = dsi_get_line_buf_size(dsi); in dsi_bind()
5066 dsi_runtime_put(dsi); in dsi_bind()
5068 snprintf(name, sizeof(name), "dsi%u_regs", dsi->module_id + 1); in dsi_bind()
5069 dsi->debugfs.regs = dss_debugfs_create_file(dss, name, in dsi_bind()
5070 dsi_dump_dsi_regs, dsi); in dsi_bind()
5072 snprintf(name, sizeof(name), "dsi%u_irqs", dsi->module_id + 1); in dsi_bind()
5073 dsi->debugfs.irqs = dss_debugfs_create_file(dss, name, in dsi_bind()
5074 dsi_dump_dsi_irqs, dsi); in dsi_bind()
5076 snprintf(name, sizeof(name), "dsi%u_clks", dsi->module_id + 1); in dsi_bind()
5077 dsi->debugfs.clks = dss_debugfs_create_file(dss, name, in dsi_bind()
5078 dsi_dump_dsi_clocks, dsi); in dsi_bind()
5085 struct dsi_data *dsi = dev_get_drvdata(dev); in dsi_unbind() local
5087 dss_debugfs_remove_file(dsi->debugfs.clks); in dsi_unbind()
5088 dss_debugfs_remove_file(dsi->debugfs.irqs); in dsi_unbind()
5089 dss_debugfs_remove_file(dsi->debugfs.regs); in dsi_unbind()
5091 WARN_ON(dsi->scp_clk_refcount > 0); in dsi_unbind()
5093 dss_pll_unregister(&dsi->pll); in dsi_unbind()
5105 static int dsi_init_output(struct dsi_data *dsi) in dsi_init_output() argument
5107 struct omap_dss_device *out = &dsi->output; in dsi_init_output()
5110 out->dev = dsi->dev; in dsi_init_output()
5111 out->id = dsi->module_id == 0 ? in dsi_init_output()
5115 out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1"; in dsi_init_output()
5116 out->dispc_channel = dsi_get_channel(dsi); in dsi_init_output()
5133 static void dsi_uninit_output(struct dsi_data *dsi) in dsi_uninit_output() argument
5135 struct omap_dss_device *out = &dsi->output; in dsi_uninit_output()
5141 static int dsi_probe_of(struct dsi_data *dsi) in dsi_probe_of() argument
5143 struct device_node *node = dsi->dev->of_node; in dsi_probe_of()
5157 dev_err(dsi->dev, "failed to find lane data\n"); in dsi_probe_of()
5165 num_pins > dsi->num_lanes_supported * 2) { in dsi_probe_of()
5166 dev_err(dsi->dev, "bad number of lanes\n"); in dsi_probe_of()
5173 dev_err(dsi->dev, "failed to read lane data\n"); in dsi_probe_of()
5181 r = dsi_configure_pins(&dsi->output, &pin_cfg); in dsi_probe_of()
5183 dev_err(dsi->dev, "failed to configure pins"); in dsi_probe_of()
5249 { .compatible = "ti,omap3-dsi", .data = &dsi_of_data_omap36xx, },
5250 { .compatible = "ti,omap4-dsi", .data = &dsi_of_data_omap4, },
5251 { .compatible = "ti,omap5-dsi", .data = &dsi_of_data_omap5, },
5266 struct dsi_data *dsi; in dsi_probe() local
5272 dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); in dsi_probe()
5273 if (!dsi) in dsi_probe()
5276 dsi->dev = dev; in dsi_probe()
5277 dev_set_drvdata(dev, dsi); in dsi_probe()
5279 spin_lock_init(&dsi->irq_lock); in dsi_probe()
5280 spin_lock_init(&dsi->errors_lock); in dsi_probe()
5281 dsi->errors = 0; in dsi_probe()
5284 spin_lock_init(&dsi->irq_stats_lock); in dsi_probe()
5285 dsi->irq_stats.last_reset = jiffies; in dsi_probe()
5288 mutex_init(&dsi->lock); in dsi_probe()
5289 sema_init(&dsi->bus_lock, 1); in dsi_probe()
5291 INIT_DEFERRABLE_WORK(&dsi->framedone_timeout_work, in dsi_probe()
5295 timer_setup(&dsi->te_timer, dsi_te_timeout, 0); in dsi_probe()
5299 dsi->proto_base = devm_ioremap_resource(dev, dsi_mem); in dsi_probe()
5300 if (IS_ERR(dsi->proto_base)) in dsi_probe()
5301 return PTR_ERR(dsi->proto_base); in dsi_probe()
5304 dsi->phy_base = devm_ioremap_resource(dev, res); in dsi_probe()
5305 if (IS_ERR(dsi->phy_base)) in dsi_probe()
5306 return PTR_ERR(dsi->phy_base); in dsi_probe()
5309 dsi->pll_base = devm_ioremap_resource(dev, res); in dsi_probe()
5310 if (IS_ERR(dsi->pll_base)) in dsi_probe()
5311 return PTR_ERR(dsi->pll_base); in dsi_probe()
5313 dsi->irq = platform_get_irq(pdev, 0); in dsi_probe()
5314 if (dsi->irq < 0) { in dsi_probe()
5319 r = devm_request_irq(dev, dsi->irq, omap_dsi_irq_handler, in dsi_probe()
5320 IRQF_SHARED, dev_name(dev), dsi); in dsi_probe()
5326 dsi->vdds_dsi_reg = devm_regulator_get(dev, "vdd"); in dsi_probe()
5327 if (IS_ERR(dsi->vdds_dsi_reg)) { in dsi_probe()
5328 if (PTR_ERR(dsi->vdds_dsi_reg) != -EPROBE_DEFER) in dsi_probe()
5329 DSSERR("can't get DSI VDD regulator\n"); in dsi_probe()
5330 return PTR_ERR(dsi->vdds_dsi_reg); in dsi_probe()
5335 dsi->data = soc->data; in dsi_probe()
5337 dsi->data = of_match_node(dsi_of_match, dev->of_node)->data; in dsi_probe()
5339 d = dsi->data->modules; in dsi_probe()
5344 DSSERR("unsupported DSI module\n"); in dsi_probe()
5348 dsi->module_id = d->id; in dsi_probe()
5350 if (dsi->data->model == DSI_MODEL_OMAP4 || in dsi_probe()
5351 dsi->data->model == DSI_MODEL_OMAP5) { in dsi_probe()
5359 dsi->data->model == DSI_MODEL_OMAP4 ? in dsi_probe()
5364 dsi->syscon = syscon_node_to_regmap(np); in dsi_probe()
5368 /* DSI VCs initialization */ in dsi_probe()
5369 for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { in dsi_probe()
5370 dsi->vc[i].source = DSI_VC_SOURCE_L4; in dsi_probe()
5371 dsi->vc[i].dssdev = NULL; in dsi_probe()
5372 dsi->vc[i].vc_id = 0; in dsi_probe()
5375 r = dsi_get_clocks(dsi); in dsi_probe()
5381 /* DSI on OMAP3 doesn't have register DSI_GNQ, set number in dsi_probe()
5383 if (dsi->data->quirks & DSI_QUIRK_GNQ) { in dsi_probe()
5384 dsi_runtime_get(dsi); in dsi_probe()
5386 dsi->num_lanes_supported = 1 + REG_GET(dsi, DSI_GNQ, 11, 9); in dsi_probe()
5387 dsi_runtime_put(dsi); in dsi_probe()
5389 dsi->num_lanes_supported = 3; in dsi_probe()
5394 DSSERR("Failed to populate DSI child devices: %d\n", r); in dsi_probe()
5398 r = dsi_init_output(dsi); in dsi_probe()
5402 r = dsi_probe_of(dsi); in dsi_probe()
5404 DSSERR("Invalid DSI DT data\n"); in dsi_probe()
5415 dsi_uninit_output(dsi); in dsi_probe()
5425 struct dsi_data *dsi = platform_get_drvdata(pdev); in dsi_remove() local
5429 dsi_uninit_output(dsi); in dsi_remove()
5435 if (dsi->vdds_dsi_reg != NULL && dsi->vdds_dsi_enabled) { in dsi_remove()
5436 regulator_disable(dsi->vdds_dsi_reg); in dsi_remove()
5437 dsi->vdds_dsi_enabled = false; in dsi_remove()
5445 struct dsi_data *dsi = dev_get_drvdata(dev); in dsi_runtime_suspend() local
5447 dsi->is_enabled = false; in dsi_runtime_suspend()
5450 /* wait for current handler to finish before turning the DSI off */ in dsi_runtime_suspend()
5451 synchronize_irq(dsi->irq); in dsi_runtime_suspend()
5458 struct dsi_data *dsi = dev_get_drvdata(dev); in dsi_runtime_resume() local
5460 dsi->is_enabled = true; in dsi_runtime_resume()