20 #define DSS_SUBSYS_NAME "DSI"
22 #include <linux/kernel.h>
25 #include <linux/device.h>
30 #include <linux/module.h>
35 #include <linux/wait.h>
37 #include <linux/sched.h>
38 #include <linux/slab.h>
49 #define DSI_CATCH_MISSING_TE
53 #define DSI_REG(idx) ((const struct dsi_reg) { idx })
55 #define DSI_SZ_REGS SZ_1K
58 #define DSI_REVISION DSI_REG(0x0000)
59 #define DSI_SYSCONFIG DSI_REG(0x0010)
60 #define DSI_SYSSTATUS DSI_REG(0x0014)
61 #define DSI_IRQSTATUS DSI_REG(0x0018)
62 #define DSI_IRQENABLE DSI_REG(0x001C)
63 #define DSI_CTRL DSI_REG(0x0040)
64 #define DSI_GNQ DSI_REG(0x0044)
65 #define DSI_COMPLEXIO_CFG1 DSI_REG(0x0048)
66 #define DSI_COMPLEXIO_IRQ_STATUS DSI_REG(0x004C)
67 #define DSI_COMPLEXIO_IRQ_ENABLE DSI_REG(0x0050)
68 #define DSI_CLK_CTRL DSI_REG(0x0054)
69 #define DSI_TIMING1 DSI_REG(0x0058)
70 #define DSI_TIMING2 DSI_REG(0x005C)
71 #define DSI_VM_TIMING1 DSI_REG(0x0060)
72 #define DSI_VM_TIMING2 DSI_REG(0x0064)
73 #define DSI_VM_TIMING3 DSI_REG(0x0068)
74 #define DSI_CLK_TIMING DSI_REG(0x006C)
75 #define DSI_TX_FIFO_VC_SIZE DSI_REG(0x0070)
76 #define DSI_RX_FIFO_VC_SIZE DSI_REG(0x0074)
77 #define DSI_COMPLEXIO_CFG2 DSI_REG(0x0078)
78 #define DSI_RX_FIFO_VC_FULLNESS DSI_REG(0x007C)
79 #define DSI_VM_TIMING4 DSI_REG(0x0080)
80 #define DSI_TX_FIFO_VC_EMPTINESS DSI_REG(0x0084)
81 #define DSI_VM_TIMING5 DSI_REG(0x0088)
82 #define DSI_VM_TIMING6 DSI_REG(0x008C)
83 #define DSI_VM_TIMING7 DSI_REG(0x0090)
84 #define DSI_STOPCLK_TIMING DSI_REG(0x0094)
85 #define DSI_VC_CTRL(n) DSI_REG(0x0100 + (n * 0x20))
86 #define DSI_VC_TE(n) DSI_REG(0x0104 + (n * 0x20))
87 #define DSI_VC_LONG_PACKET_HEADER(n) DSI_REG(0x0108 + (n * 0x20))
88 #define DSI_VC_LONG_PACKET_PAYLOAD(n) DSI_REG(0x010C + (n * 0x20))
89 #define DSI_VC_SHORT_PACKET_HEADER(n) DSI_REG(0x0110 + (n * 0x20))
90 #define DSI_VC_IRQSTATUS(n) DSI_REG(0x0118 + (n * 0x20))
91 #define DSI_VC_IRQENABLE(n) DSI_REG(0x011C + (n * 0x20))
95 #define DSI_DSIPHY_CFG0 DSI_REG(0x200 + 0x0000)
96 #define DSI_DSIPHY_CFG1 DSI_REG(0x200 + 0x0004)
97 #define DSI_DSIPHY_CFG2 DSI_REG(0x200 + 0x0008)
98 #define DSI_DSIPHY_CFG5 DSI_REG(0x200 + 0x0014)
99 #define DSI_DSIPHY_CFG10 DSI_REG(0x200 + 0x0028)
103 #define DSI_PLL_CONTROL DSI_REG(0x300 + 0x0000)
104 #define DSI_PLL_STATUS DSI_REG(0x300 + 0x0004)
105 #define DSI_PLL_GO DSI_REG(0x300 + 0x0008)
106 #define DSI_PLL_CONFIGURATION1 DSI_REG(0x300 + 0x000C)
107 #define DSI_PLL_CONFIGURATION2 DSI_REG(0x300 + 0x0010)
109 #define REG_GET(dsidev, idx, start, end) \
110 FLD_GET(dsi_read_reg(dsidev, idx), start, end)
112 #define REG_FLD_MOD(dsidev, idx, val, start, end) \
113 dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, start, end))
116 #define DSI_IRQ_VC0 (1 << 0)
117 #define DSI_IRQ_VC1 (1 << 1)
118 #define DSI_IRQ_VC2 (1 << 2)
119 #define DSI_IRQ_VC3 (1 << 3)
120 #define DSI_IRQ_WAKEUP (1 << 4)
121 #define DSI_IRQ_RESYNC (1 << 5)
122 #define DSI_IRQ_PLL_LOCK (1 << 7)
123 #define DSI_IRQ_PLL_UNLOCK (1 << 8)
124 #define DSI_IRQ_PLL_RECALL (1 << 9)
125 #define DSI_IRQ_COMPLEXIO_ERR (1 << 10)
126 #define DSI_IRQ_HS_TX_TIMEOUT (1 << 14)
127 #define DSI_IRQ_LP_RX_TIMEOUT (1 << 15)
128 #define DSI_IRQ_TE_TRIGGER (1 << 16)
129 #define DSI_IRQ_ACK_TRIGGER (1 << 17)
130 #define DSI_IRQ_SYNC_LOST (1 << 18)
131 #define DSI_IRQ_LDO_POWER_GOOD (1 << 19)
132 #define DSI_IRQ_TA_TIMEOUT (1 << 20)
133 #define DSI_IRQ_ERROR_MASK \
134 (DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
135 DSI_IRQ_TA_TIMEOUT | DSI_IRQ_SYNC_LOST)
136 #define DSI_IRQ_CHANNEL_MASK 0xf
139 #define DSI_VC_IRQ_CS (1 << 0)
140 #define DSI_VC_IRQ_ECC_CORR (1 << 1)
141 #define DSI_VC_IRQ_PACKET_SENT (1 << 2)
142 #define DSI_VC_IRQ_FIFO_TX_OVF (1 << 3)
143 #define DSI_VC_IRQ_FIFO_RX_OVF (1 << 4)
144 #define DSI_VC_IRQ_BTA (1 << 5)
145 #define DSI_VC_IRQ_ECC_NO_CORR (1 << 6)
146 #define DSI_VC_IRQ_FIFO_TX_UDF (1 << 7)
147 #define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
148 #define DSI_VC_IRQ_ERROR_MASK \
149 (DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
150 DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
151 DSI_VC_IRQ_FIFO_TX_UDF)
154 #define DSI_CIO_IRQ_ERRSYNCESC1 (1 << 0)
155 #define DSI_CIO_IRQ_ERRSYNCESC2 (1 << 1)
156 #define DSI_CIO_IRQ_ERRSYNCESC3 (1 << 2)
157 #define DSI_CIO_IRQ_ERRSYNCESC4 (1 << 3)
158 #define DSI_CIO_IRQ_ERRSYNCESC5 (1 << 4)
159 #define DSI_CIO_IRQ_ERRESC1 (1 << 5)
160 #define DSI_CIO_IRQ_ERRESC2 (1 << 6)
161 #define DSI_CIO_IRQ_ERRESC3 (1 << 7)
162 #define DSI_CIO_IRQ_ERRESC4 (1 << 8)
163 #define DSI_CIO_IRQ_ERRESC5 (1 << 9)
164 #define DSI_CIO_IRQ_ERRCONTROL1 (1 << 10)
165 #define DSI_CIO_IRQ_ERRCONTROL2 (1 << 11)
166 #define DSI_CIO_IRQ_ERRCONTROL3 (1 << 12)
167 #define DSI_CIO_IRQ_ERRCONTROL4 (1 << 13)
168 #define DSI_CIO_IRQ_ERRCONTROL5 (1 << 14)
169 #define DSI_CIO_IRQ_STATEULPS1 (1 << 15)
170 #define DSI_CIO_IRQ_STATEULPS2 (1 << 16)
171 #define DSI_CIO_IRQ_STATEULPS3 (1 << 17)
172 #define DSI_CIO_IRQ_STATEULPS4 (1 << 18)
173 #define DSI_CIO_IRQ_STATEULPS5 (1 << 19)
174 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_1 (1 << 20)
175 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_1 (1 << 21)
176 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_2 (1 << 22)
177 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_2 (1 << 23)
178 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_3 (1 << 24)
179 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_3 (1 << 25)
180 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_4 (1 << 26)
181 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_4 (1 << 27)
182 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_5 (1 << 28)
183 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_5 (1 << 29)
184 #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0 (1 << 30)
185 #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1 (1 << 31)
186 #define DSI_CIO_IRQ_ERROR_MASK \
187 (DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
188 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
189 DSI_CIO_IRQ_ERRSYNCESC5 | \
190 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
191 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
192 DSI_CIO_IRQ_ERRESC5 | \
193 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
194 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
195 DSI_CIO_IRQ_ERRCONTROL5 | \
196 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
197 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
198 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
199 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
200 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
204 #define DSI_MAX_NR_ISRS 2
205 #define DSI_MAX_NR_LANES 5
289 unsigned update_bytes;
300 #ifdef DSI_CATCH_MISSING_TE
317 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
349 static bool dsi_perf;
360 return dssdev->
output->pdev;
387 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
395 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
403 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
412 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
420 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
425 static void dsi_completion_handler(
void *
data,
u32 mask)
440 if (
REG_GET(dsidev, idx, bitnum, bitnum) == value)
447 if (
REG_GET(dsidev, idx, bitnum, bitnum) == value)
450 wait = ns_to_ktime(1000 * 1000);
477 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
483 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
489 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
492 u32 setup_us, trans_us, total_us;
499 setup_time = ktime_sub(dsi->perf_start_time, dsi->perf_setup_time);
500 setup_us = (
u32)ktime_to_us(setup_time);
504 trans_time = ktime_sub(t, dsi->perf_start_time);
505 trans_us = (
u32)ktime_to_us(trans_time);
509 total_us = setup_us + trans_us;
511 total_bytes = dsi->update_bytes;
514 "%u bytes, %u kbytes/sec\n",
519 1000*1000 / total_us,
521 total_bytes * 1000 / total_us);
550 if (status & DSI_IRQ_##x) \
576 static void print_irq_status_vc(
int channel,
u32 status)
588 if (status & DSI_VC_IRQ_##x) \
605 static void print_irq_status_cio(
u32 status)
613 if (status & DSI_CIO_IRQ_##x) \
627 PIS(ERRCONTENTIONLP0_1);
628 PIS(ERRCONTENTIONLP1_1);
629 PIS(ERRCONTENTIONLP0_2);
630 PIS(ERRCONTENTIONLP1_2);
631 PIS(ERRCONTENTIONLP0_3);
632 PIS(ERRCONTENTIONLP1_3);
633 PIS(ULPSACTIVENOT_ALL0);
634 PIS(ULPSACTIVENOT_ALL1);
640 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
642 u32 *vcstatus,
u32 ciostatus)
644 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
647 spin_lock(&dsi->irq_stats_lock);
649 dsi->irq_stats.irq_count++;
650 dss_collect_irq_stats(irqstatus, dsi->irq_stats.dsi_irqs);
652 for (i = 0; i < 4; ++
i)
653 dss_collect_irq_stats(vcstatus[i], dsi->irq_stats.vc_irqs[i]);
655 dss_collect_irq_stats(ciostatus, dsi->irq_stats.cio_irqs);
657 spin_unlock(&dsi->irq_stats_lock);
660 #define dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus)
663 static int debug_irq;
666 u32 *vcstatus,
u32 ciostatus)
668 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
672 DSSERR(
"DSI error, irqstatus %x\n", irqstatus);
673 print_irq_status(irqstatus);
677 }
else if (debug_irq) {
678 print_irq_status(irqstatus);
681 for (i = 0; i < 4; ++
i) {
683 DSSERR(
"DSI VC(%d) error, vc irqstatus %x\n",
685 print_irq_status_vc(i, vcstatus[i]);
686 }
else if (debug_irq) {
687 print_irq_status_vc(i, vcstatus[i]);
692 DSSERR(
"DSI CIO error, cio irqstatus %x\n", ciostatus);
693 print_irq_status_cio(ciostatus);
694 }
else if (debug_irq) {
695 print_irq_status_cio(ciostatus);
699 static void dsi_call_isrs(
struct dsi_isr_data *isr_array,
700 unsigned isr_array_size,
u32 irqstatus)
705 for (i = 0; i < isr_array_size; i++) {
706 isr_data = &isr_array[
i];
707 if (isr_data->
isr && isr_data->
mask & irqstatus)
708 isr_data->
isr(isr_data->
arg, irqstatus);
713 u32 irqstatus,
u32 *vcstatus,
u32 ciostatus)
721 for (i = 0; i < 4; ++
i) {
722 if (vcstatus[i] == 0)
739 u32 irqstatus, vcstatus[4], ciostatus;
743 dsi = dsi_get_dsidrv_data(dsidev);
759 for (i = 0; i < 4; ++
i) {
760 if ((irqstatus & (1 << i)) == 0) {
782 #ifdef DSI_CATCH_MISSING_TE
794 dsi_handle_isrs(&dsi->
isr_tables_copy, irqstatus, vcstatus, ciostatus);
796 dsi_handle_irq_errors(dsidev, irqstatus, vcstatus, ciostatus);
806 unsigned isr_array_size,
u32 default_mask,
807 const struct dsi_reg enable_reg,
808 const struct dsi_reg status_reg)
817 for (i = 0; i < isr_array_size; i++) {
818 isr_data = &isr_array[
i];
823 mask |= isr_data->
mask;
826 old_mask = dsi_read_reg(dsidev, enable_reg);
828 dsi_write_reg(dsidev, status_reg, (mask ^ old_mask) & mask);
829 dsi_write_reg(dsidev, enable_reg, mask);
832 dsi_read_reg(dsidev, enable_reg);
833 dsi_read_reg(dsidev, status_reg);
839 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
841 #ifdef DSI_CATCH_MISSING_TE
844 _omap_dsi_configure_irqs(dsidev, dsi->
isr_tables.isr_table,
852 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
854 _omap_dsi_configure_irqs(dsidev, dsi->
isr_tables.isr_table_vc[vc],
863 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
865 _omap_dsi_configure_irqs(dsidev, dsi->
isr_tables.isr_table_cio,
873 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
881 _omap_dsi_set_irqs(dsidev);
882 for (vc = 0; vc < 4; ++
vc)
883 _omap_dsi_set_irqs_vc(dsidev, vc);
884 _omap_dsi_set_irqs_cio(dsidev);
886 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
890 struct dsi_isr_data *isr_array,
unsigned isr_array_size)
900 for (i = 0; i < isr_array_size; i++) {
901 isr_data = &isr_array[
i];
903 if (isr_data->
isr == isr && isr_data->
arg == arg &&
904 isr_data->
mask == mask) {
908 if (isr_data->
isr ==
NULL && free_idx == -1)
915 isr_data = &isr_array[free_idx];
924 struct dsi_isr_data *isr_array,
unsigned isr_array_size)
929 for (i = 0; i < isr_array_size; i++) {
930 isr_data = &isr_array[
i];
931 if (isr_data->
isr != isr || isr_data->
arg != arg ||
932 isr_data->
mask != mask)
948 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
954 r = _dsi_register_isr(isr, arg, mask, dsi->
isr_tables.isr_table,
958 _omap_dsi_set_irqs(dsidev);
960 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
968 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
974 r = _dsi_unregister_isr(isr, arg, mask, dsi->
isr_tables.isr_table,
978 _omap_dsi_set_irqs(dsidev);
980 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
985 static int dsi_register_isr_vc(
struct platform_device *dsidev,
int channel,
988 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
994 r = _dsi_register_isr(isr, arg, mask,
999 _omap_dsi_set_irqs_vc(dsidev, channel);
1001 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
1006 static int dsi_unregister_isr_vc(
struct platform_device *dsidev,
int channel,
1009 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1010 unsigned long flags;
1015 r = _dsi_unregister_isr(isr, arg, mask,
1020 _omap_dsi_set_irqs_vc(dsidev, channel);
1022 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
1030 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1031 unsigned long flags;
1036 r = _dsi_register_isr(isr, arg, mask, dsi->
isr_tables.isr_table_cio,
1040 _omap_dsi_set_irqs_cio(dsidev);
1042 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
1050 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1051 unsigned long flags;
1056 r = _dsi_unregister_isr(isr, arg, mask, dsi->
isr_tables.isr_table_cio,
1060 _omap_dsi_set_irqs_cio(dsidev);
1062 spin_unlock_irqrestore(&dsi->
irq_lock, flags);
1069 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1070 unsigned long flags;
1082 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1084 DSSDBG(
"dsi_runtime_get\n");
1086 r = pm_runtime_get_sync(&dsi->
pdev->dev);
1088 return r < 0 ? r : 0;
1093 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1096 DSSDBG(
"dsi_runtime_put\n");
1098 r = pm_runtime_put_sync(&dsi->
pdev->dev);
1103 static inline void dsi_enable_pll_clock(
struct platform_device *dsidev,
1106 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1109 clk_prepare_enable(dsi->
sys_clk);
1111 clk_disable_unprepare(dsi->
sys_clk);
1115 DSSERR(
"cannot lock PLL when enabling clocks\n");
1152 printk(
"PHY (%x%x%x, %d, %d, %d)\n",
1161 #define _dsi_print_reset_status(x)
1164 static inline int dsi_if_enable(
struct platform_device *dsidev,
bool enable)
1166 DSSDBG(
"dsi_if_enable(%d)\n", enable);
1168 enable = enable ? 1 : 0;
1171 if (wait_for_bit_change(dsidev,
DSI_CTRL, 0, enable) != enable) {
1172 DSSERR(
"Failed to set dsi_if_enable to %d\n", enable);
1181 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1186 static unsigned long dsi_get_pll_hsdiv_dsi_rate(
struct platform_device *dsidev)
1188 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1193 static unsigned long dsi_get_txbyteclkhs(
struct platform_device *dsidev)
1195 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1203 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1210 r = dsi_get_pll_hsdiv_dsi_rate(dsidev);
1219 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1220 unsigned long dsi_fclk;
1221 unsigned lp_clk_div;
1222 unsigned long lp_clk;
1224 lp_clk_div = dssdev->
clocks.dsi.lp_clk_div;
1226 if (lp_clk_div == 0 || lp_clk_div > dsi->
lpdiv_max)
1229 dsi_fclk = dsi_fclk_rate(dsidev);
1231 lp_clk = dsi_fclk / 2 / lp_clk_div;
1233 DSSDBG(
"LP_CLK_DIV %u, LP_CLK %lu\n", lp_clk_div, lp_clk);
1248 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1256 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1286 DSSERR(
"Failed to set DSI PLL power mode to %d\n",
1300 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1322 if (cinfo->
clkin4ddr > 1800 * 1000 * 1000)
1344 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1347 int min_fck_per_pck;
1349 unsigned long dss_sys_clk, max_dss_fck;
1357 DSSDBG(
"DSI clock info found from cache\n");
1364 min_fck_per_pck = CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK;
1366 if (min_fck_per_pck &&
1367 req_pck * min_fck_per_pck > max_dss_fck) {
1368 DSSERR(
"Requested pixel clock not possible with the current "
1369 "OMAP2_DSS_MIN_FCK_PER_PCK setting. Turning "
1370 "the constraint off.\n");
1371 min_fck_per_pck = 0;
1374 DSSDBG(
"dsi_pll_calc\n");
1377 memset(&best, 0,
sizeof(best));
1378 memset(&best_dispc, 0,
sizeof(best_dispc));
1380 memset(&cur, 0,
sizeof(cur));
1381 cur.
clkin = dss_sys_clk;
1419 if (min_fck_per_pck &&
1421 req_pck * min_fck_per_pck)
1430 if (
abs(cur_dispc.
pck - req_pck) <
1431 abs(best_dispc.
pck - req_pck)) {
1433 best_dispc = cur_dispc;
1435 if (cur_dispc.
pck == req_pck)
1443 if (min_fck_per_pck) {
1444 DSSERR(
"Could not find suitable clock settings.\n"
1445 "Turning FCK/PCK constraint off and"
1447 min_fck_per_pck = 0;
1451 DSSERR(
"Could not find suitable clock settings.\n");
1463 *dispc_cinfo = best_dispc;
1475 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1478 DSSDBG(
"dsi_pll_calc_ddrfreq\n");
1480 memset(&best, 0,
sizeof(best));
1495 a = 2 *
cur.regm * (
cur.clkin/1000);
1497 cur.clkin4ddr = a / b * 1000;
1499 if (
cur.clkin4ddr > 1800 * 1000 * 1000)
1502 if (
abs(
cur.clkin4ddr - req_clkin4ddr) <
1503 abs(best.clkin4ddr - req_clkin4ddr)) {
1505 DSSDBG(
"best %ld\n", best.clkin4ddr);
1508 if (
cur.clkin4ddr == req_clkin4ddr)
1522 unsigned long max_dsi_fck;
1534 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1535 unsigned regm_dispc, best_regm_dispc;
1536 unsigned long dispc_clk, best_dispc_clk;
1537 int min_fck_per_pck;
1538 unsigned long max_dss_fck;
1544 min_fck_per_pck = CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK;
1546 if (min_fck_per_pck &&
1547 req_pck * min_fck_per_pck > max_dss_fck) {
1548 DSSERR(
"Requested pixel clock not possible with the current "
1549 "OMAP2_DSS_MIN_FCK_PER_PCK setting. Turning "
1550 "the constraint off.\n");
1551 min_fck_per_pck = 0;
1555 best_regm_dispc = 0;
1557 memset(&best_dispc, 0,
sizeof(best_dispc));
1560 for (regm_dispc = 1; regm_dispc < dsi->
regm_dispc_max; ++regm_dispc) {
1563 dispc_clk = cinfo->
clkin4ddr / regm_dispc;
1568 if (dispc_clk < req_pck)
1571 if (dispc_clk > max_dss_fck)
1574 if (min_fck_per_pck && dispc_clk < req_pck * min_fck_per_pck)
1581 if (
abs(cur_dispc.pck - req_pck) <
1582 abs(best_dispc.pck - req_pck)) {
1583 best_regm_dispc = regm_dispc;
1584 best_dispc_clk = dispc_clk;
1585 best_dispc = cur_dispc;
1587 if (cur_dispc.pck == req_pck)
1593 if (min_fck_per_pck) {
1594 DSSERR(
"Could not find suitable clock settings.\n"
1595 "Turning FCK/PCK constraint off and"
1597 min_fck_per_pck = 0;
1601 DSSERR(
"Could not find suitable clock settings.\n");
1609 *dispc_cinfo = best_dispc;
1617 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1621 u8 regn_start, regn_end, regm_start, regm_end;
1622 u8 regm_dispc_start, regm_dispc_end, regm_dsi_start, regm_dsi_end;
1644 DSSDBG(
"CLKIN4DDR = 2 * %d / %d * %lu = %lu\n",
1650 DSSDBG(
"Data rate on 1 DSI lane %ld Mbps\n",
1677 l =
FLD_MOD(l, cinfo->
regn - 1, regn_start, regn_end);
1679 l =
FLD_MOD(l, cinfo->
regm, regm_start, regm_end);
1682 regm_dispc_start, regm_dispc_end);
1685 regm_dsi_start, regm_dsi_end);
1693 f = cinfo->
fint < 1000000 ? 0x3 :
1694 cinfo->
fint < 1250000 ? 0x4 :
1695 cinfo->
fint < 1500000 ? 0x5 :
1696 cinfo->
fint < 1750000 ? 0x6 :
1701 f = cinfo->
clkin4ddr < 1000000000 ? 0x2 : 0x4;
1715 if (wait_for_bit_change(dsidev,
DSI_PLL_GO, 0, 0) != 0) {
1716 DSSERR(
"dsi pll go bit not going down.\n");
1722 DSSERR(
"cannot lock PLL\n");
1746 DSSDBG(
"PLL config done\n");
1754 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1765 if (IS_ERR(vdds_dsi)) {
1766 DSSERR(
"can't get VDDS_DSI regulator\n");
1767 return PTR_ERR(vdds_dsi);
1773 dsi_enable_pll_clock(dsidev, 1);
1777 dsi_enable_scp_clk(dsidev);
1790 DSSERR(
"PLL not coming out of reset.\n");
1800 if (enable_hsclk && enable_hsdiv)
1802 else if (enable_hsclk)
1804 else if (enable_hsdiv)
1809 r = dsi_pll_power(dsidev, pwstate);
1814 DSSDBG(
"PLL init done\n");
1823 dsi_disable_scp_clk(dsidev);
1824 dsi_enable_pll_clock(dsidev, 0);
1830 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1834 if (disconnect_lanes) {
1840 dsi_disable_scp_clk(dsidev);
1841 dsi_enable_pll_clock(dsidev, 0);
1843 DSSDBG(
"PLL uninit done\n");
1849 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1860 seq_printf(s,
"- DSI%d PLL -\n", dsi_module + 1);
1869 seq_printf(s,
"DSI_PLL_HSDIV_DISPC (%s)\t%-16luregm_dispc %u\t(%s)\n",
1878 seq_printf(s,
"DSI_PLL_HSDIV_DSI (%s)\t%-16luregm_dsi %u\t(%s)\n",
1887 seq_printf(s,
"- DSI%d -\n", dsi_module + 1);
1893 seq_printf(s,
"DSI_FCLK\t%lu\n", dsi_fclk_rate(dsidev));
1898 seq_printf(s,
"TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsidev));
1913 dsi_dump_dsidev_clocks(dsidev, s);
1917 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
1921 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
1922 unsigned long flags;
1927 stats = dsi->irq_stats;
1928 memset(&dsi->irq_stats, 0,
sizeof(dsi->irq_stats));
1929 dsi->irq_stats.last_reset =
jiffies;
1931 spin_unlock_irqrestore(&dsi->irq_stats_lock, flags);
1938 seq_printf(s, "%-20s %10d\n", #x, stats.dsi_irqs[ffs(DSI_IRQ_##x)-1]);
1956 PIS(LDO_POWER_GOOD);
1961 seq_printf(s, "%-20s %10d %10d %10d %10d\n", #x, \
1962 stats.vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \
1963 stats.vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \
1964 stats.vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \
1965 stats.vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]);
1976 PIS(PP_BUSY_CHANGE);
1980 seq_printf(s, "%-20s %10d\n", #x, \
1981 stats.cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]);
1996 PIS(ERRCONTENTIONLP0_1);
1997 PIS(ERRCONTENTIONLP1_1);
1998 PIS(ERRCONTENTIONLP0_2);
1999 PIS(ERRCONTENTIONLP1_2);
2000 PIS(ERRCONTENTIONLP0_3);
2001 PIS(ERRCONTENTIONLP1_3);
2002 PIS(ULPSACTIVENOT_ALL0);
2003 PIS(ULPSACTIVENOT_ALL1);
2007 static void dsi1_dump_irqs(
struct seq_file *s)
2011 dsi_dump_dsidev_irqs(dsidev, s);
2014 static void dsi2_dump_irqs(
struct seq_file *s)
2018 dsi_dump_dsidev_irqs(dsidev, s);
2025 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsidev, r))
2029 dsi_enable_scp_clk(dsidev);
2101 dsi_disable_scp_clk(dsidev);
2106 static void dsi1_dump_regs(
struct seq_file *s)
2110 dsi_dump_dsidev_regs(dsidev, s);
2113 static void dsi2_dump_regs(
struct seq_file *s)
2117 dsi_dump_dsidev_regs(dsidev, s);
2138 DSSERR(
"failed to set complexio power state to "
2184 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2185 static const u8 offsets[] = { 0, 4, 8, 12, 16 };
2204 if (dsi->
lanes[t].function == functions[i])
2211 polarity = dsi->
lanes[
t].polarity;
2213 r =
FLD_MOD(r, lane_number + 1, offset + 2, offset);
2214 r =
FLD_MOD(r, polarity, offset + 3, offset + 3);
2219 unsigned offset = offsets[
i];
2221 r =
FLD_MOD(r, 0, offset + 2, offset);
2222 r =
FLD_MOD(r, 0, offset + 3, offset + 3);
2232 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2236 return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000;
2241 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2244 return ddr * 1000 * 1000 / (ddr_clk / 1000);
2250 u32 ths_prepare, ths_prepare_ths_zero, ths_trail, ths_exit;
2251 u32 tlpx_half, tclk_trail, tclk_zero;
2259 ths_prepare = ns2ddr(dsidev, 70) + 2;
2262 ths_prepare_ths_zero = ns2ddr(dsidev, 175) + 2;
2265 ths_trail = ns2ddr(dsidev, 60) + 5;
2268 ths_exit = ns2ddr(dsidev, 145);
2271 tlpx_half = ns2ddr(dsidev, 25);
2274 tclk_trail = ns2ddr(dsidev, 60) + 2;
2277 tclk_prepare = ns2ddr(dsidev, 65);
2280 tclk_zero = ns2ddr(dsidev, 260);
2282 DSSDBG(
"ths_prepare %u (%uns), ths_prepare_ths_zero %u (%uns)\n",
2283 ths_prepare, ddr2ns(dsidev, ths_prepare),
2284 ths_prepare_ths_zero, ddr2ns(dsidev, ths_prepare_ths_zero));
2285 DSSDBG(
"ths_trail %u (%uns), ths_exit %u (%uns)\n",
2286 ths_trail, ddr2ns(dsidev, ths_trail),
2287 ths_exit, ddr2ns(dsidev, ths_exit));
2289 DSSDBG(
"tlpx_half %u (%uns), tclk_trail %u (%uns), "
2290 "tclk_zero %u (%uns)\n",
2291 tlpx_half, ddr2ns(dsidev, tlpx_half),
2292 tclk_trail, ddr2ns(dsidev, tclk_trail),
2293 tclk_zero, ddr2ns(dsidev, tclk_zero));
2294 DSSDBG(
"tclk_prepare %u (%uns)\n",
2295 tclk_prepare, ddr2ns(dsidev, tclk_prepare));
2300 r =
FLD_MOD(r, ths_prepare, 31, 24);
2301 r =
FLD_MOD(r, ths_prepare_ths_zero, 23, 16);
2302 r =
FLD_MOD(r, ths_trail, 15, 8);
2303 r =
FLD_MOD(r, ths_exit, 7, 0);
2307 r =
FLD_MOD(r, tlpx_half, 20, 16);
2308 r =
FLD_MOD(r, tclk_trail, 15, 8);
2309 r =
FLD_MOD(r, tclk_zero, 7, 0);
2320 r =
FLD_MOD(r, tclk_prepare, 7, 0);
2325 static void dsi_cio_enable_lane_override(
struct platform_device *dsidev,
2326 unsigned mask_p,
unsigned mask_n)
2328 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2336 unsigned p = dsi->
lanes[
i].polarity;
2338 if (mask_p & (1 << i))
2339 l |= 1 << (i * 2 + (p ? 0 : 1));
2341 if (mask_n & (1 << i))
2342 l |= 1 << (i * 2 + (p ? 1 : 0));
2365 static void dsi_cio_disable_lane_override(
struct platform_device *dsidev)
2374 static int dsi_cio_wait_tx_clk_esc_reset(
struct platform_device *dsidev)
2376 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2379 static const u8 offsets_old[] = { 28, 27, 26 };
2380 static const u8 offsets_new[] = { 24, 25, 26, 27, 28 };
2384 offsets = offsets_old;
2386 offsets = offsets_new;
2400 if (!in_use[i] || (l & (1 << offsets[i])))
2409 if (!in_use[i] || (l & (1 << offsets[i])))
2412 DSSERR(
"CIO TXCLKESC%d domain not coming " \
2413 "out of reset\n", i);
2425 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2439 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2449 dsi_enable_scp_clk(dsidev);
2457 DSSERR(
"CIO SCP Clock domain not coming out of reset.\n");
2459 goto err_scp_clk_dom;
2462 r = dsi_set_lane_config(dsidev);
2464 goto err_scp_clk_dom;
2471 l =
FLD_MOD(l, 0x1fff, 12, 0);
2478 DSSDBG(
"manual ulps exit\n");
2497 dsi_cio_enable_lane_override(dsidev, mask_p, 0);
2505 DSSERR(
"CIO PWR clock domain not coming out of reset.\n");
2507 goto err_cio_pwr_dom;
2510 dsi_if_enable(dsidev,
true);
2511 dsi_if_enable(dsidev,
false);
2514 r = dsi_cio_wait_tx_clk_esc_reset(dsidev);
2516 goto err_tx_clk_esc_rst;
2520 ktime_t wait = ns_to_ktime(1000 * 1000);
2526 dsi_cio_disable_lane_override(dsidev);
2532 dsi_cio_timings(dsidev);
2542 DSSDBG(
"CIO init done\n");
2552 dsi_cio_disable_lane_override(dsidev);
2554 dsi_disable_scp_clk(dsidev);
2561 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2567 dsi_disable_scp_clk(dsidev);
2575 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2580 dsi->
vc[0].fifo_size = size1;
2581 dsi->
vc[1].fifo_size = size2;
2582 dsi->
vc[2].fifo_size = size3;
2583 dsi->
vc[3].fifo_size = size4;
2585 for (i = 0; i < 4; i++) {
2587 int size = dsi->
vc[
i].fifo_size;
2589 if (add + size > 4) {
2590 DSSERR(
"Illegal FIFO configuration\n");
2608 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2613 dsi->
vc[0].fifo_size = size1;
2614 dsi->
vc[1].fifo_size = size2;
2615 dsi->
vc[2].fifo_size = size3;
2616 dsi->
vc[3].fifo_size = size4;
2618 for (i = 0; i < 4; i++) {
2620 int size = dsi->
vc[
i].fifo_size;
2622 if (add + size > 4) {
2623 DSSERR(
"Illegal FIFO configuration\n");
2645 if (wait_for_bit_change(dsidev,
DSI_TIMING1, 15, 0) != 0) {
2646 DSSERR(
"TX_STOP bit not going down\n");
2653 static bool dsi_vc_is_enabled(
struct platform_device *dsidev,
int channel)
2658 static void dsi_packet_sent_handler_vp(
void *data,
u32 mask)
2670 static int dsi_sync_vc_vp(
struct platform_device *dsidev,
int channel)
2672 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2680 r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
2689 DSSERR(
"Failed to complete previous frame transfer\n");
2695 dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
2700 dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp,
2706 static void dsi_packet_sent_handler_l4(
void *data,
u32 mask)
2717 static int dsi_sync_vc_l4(
struct platform_device *dsidev,
int channel)
2723 r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
2732 DSSERR(
"Failed to complete previous l4 transfer\n");
2738 dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
2743 dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4,
2751 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2753 WARN_ON(!dsi_bus_is_locked(dsidev));
2757 if (!dsi_vc_is_enabled(dsidev, channel))
2760 switch (dsi->
vc[channel].source) {
2762 return dsi_sync_vc_vp(dsidev, channel);
2764 return dsi_sync_vc_l4(dsidev, channel);
2774 DSSDBG(
"dsi_vc_enable channel %d, enable %d\n",
2777 enable = enable ? 1 : 0;
2781 if (wait_for_bit_change(dsidev,
DSI_VC_CTRL(channel),
2782 0, enable) != enable) {
2783 DSSERR(
"Failed to set dsi_vc_enable to %d\n", enable);
2790 static void dsi_vc_initial_config(
struct platform_device *dsidev,
int channel)
2799 DSSERR(
"VC(%d) busy when trying to configure it!\n",
2818 static int dsi_vc_config_source(
struct platform_device *dsidev,
int channel,
2821 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2823 if (dsi->
vc[channel].source == source)
2828 dsi_sync_vc(dsidev, channel);
2830 dsi_vc_enable(dsidev, channel, 0);
2833 if (wait_for_bit_change(dsidev,
DSI_VC_CTRL(channel), 15, 0) != 0) {
2834 DSSERR(
"vc(%d) busy when trying to config for VP\n", channel);
2847 dsi_vc_enable(dsidev, channel, 1);
2858 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2860 DSSDBG(
"dsi_vc_enable_hs(%d, %d)\n", channel, enable);
2862 WARN_ON(!dsi_bus_is_locked(dsidev));
2864 dsi_vc_enable(dsidev, channel, 0);
2865 dsi_if_enable(dsidev, 0);
2869 dsi_vc_enable(dsidev, channel, 1);
2870 dsi_if_enable(dsidev, 1);
2872 dsi_force_tx_stop_mode_io(dsidev);
2875 if (dsi->
vm_timings.ddr_clk_always_on && enable)
2880 static void dsi_vc_flush_long_data(
struct platform_device *dsidev,
int channel)
2885 DSSDBG(
"\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
2889 (val >> 24) & 0xff);
2893 static void dsi_show_rx_ack_with_err(
u16 err)
2895 DSSERR(
"\tACK with ERROR (%#x):\n", err);
2897 DSSERR(
"\t\tSoT Error\n");
2899 DSSERR(
"\t\tSoT Sync Error\n");
2901 DSSERR(
"\t\tEoT Sync Error\n");
2903 DSSERR(
"\t\tEscape Mode Entry Command Error\n");
2905 DSSERR(
"\t\tLP Transmit Sync Error\n");
2907 DSSERR(
"\t\tHS Receive Timeout Error\n");
2909 DSSERR(
"\t\tFalse Control Error\n");
2911 DSSERR(
"\t\t(reserved7)\n");
2913 DSSERR(
"\t\tECC Error, single-bit (corrected)\n");
2915 DSSERR(
"\t\tECC Error, multi-bit (not corrected)\n");
2916 if (err & (1 << 10))
2917 DSSERR(
"\t\tChecksum Error\n");
2918 if (err & (1 << 11))
2919 DSSERR(
"\t\tData type not recognized\n");
2920 if (err & (1 << 12))
2921 DSSERR(
"\t\tInvalid VC ID\n");
2922 if (err & (1 << 13))
2923 DSSERR(
"\t\tInvalid Transmission Length\n");
2924 if (err & (1 << 14))
2925 DSSERR(
"\t\t(reserved14)\n");
2926 if (err & (1 << 15))
2927 DSSERR(
"\t\tDSI Protocol Violation\n");
2938 DSSERR(
"\trawval %#08x\n", val);
2942 dsi_show_rx_ack_with_err(err);
2944 DSSERR(
"\tDCS short response, 1 byte: %#x\n",
2947 DSSERR(
"\tDCS short response, 2 byte: %#x\n",
2950 DSSERR(
"\tDCS long response, len %d\n",
2952 dsi_vc_flush_long_data(dsidev, channel);
2954 DSSERR(
"\tunknown datatype 0x%02x\n", dt);
2960 static int dsi_vc_send_bta(
struct platform_device *dsidev,
int channel)
2962 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2965 DSSDBG(
"dsi_vc_send_bta %d\n", channel);
2967 WARN_ON(!dsi_bus_is_locked(dsidev));
2971 DSSERR(
"rx fifo not empty when sending BTA, dumping data:\n");
2972 dsi_vc_flush_receive_data(dsidev, channel);
2990 r = dsi_register_isr_vc(dsidev, channel, dsi_completion_handler,
2995 r = dsi_register_isr(dsidev, dsi_completion_handler, &
completion,
3000 r = dsi_vc_send_bta(dsidev, channel);
3006 DSSERR(
"Failed to receive BTA\n");
3011 err = dsi_get_errors(dsidev);
3013 DSSERR(
"Error while sending BTA: %x\n", err);
3018 dsi_unregister_isr(dsidev, dsi_completion_handler, &
completion,
3021 dsi_unregister_isr_vc(dsidev, channel, dsi_completion_handler,
3028 static inline void dsi_vc_write_long_header(
struct platform_device *dsidev,
3031 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3035 WARN_ON(!dsi_bus_is_locked(dsidev));
3037 data_id = data_type | dsi->
vc[
channel].vc_id << 6;
3045 static inline void dsi_vc_write_long_payload(
struct platform_device *dsidev,
3046 int channel,
u8 b1,
u8 b2,
u8 b3,
u8 b4)
3050 val = b4 << 24 | b3 << 16 | b2 << 8 | b1 << 0;
3058 static int dsi_vc_send_long(
struct platform_device *dsidev,
int channel,
3059 u8 data_type,
u8 *data,
u16 len,
u8 ecc)
3062 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3069 DSSDBG(
"dsi_vc_send_long, %d bytes\n", len);
3072 if (dsi->
vc[channel].fifo_size * 32 * 4 < len + 4) {
3073 DSSERR(
"unable to send long packet: packet too long.\n");
3079 dsi_vc_write_long_header(dsidev, channel, data_type, len, ecc);
3082 for (i = 0; i < len >> 2; i++) {
3084 DSSDBG(
"\tsending full packet %d\n", i);
3091 dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, b4);
3096 b1 = 0; b2 = 0; b3 = 0;
3099 DSSDBG(
"\tsending remainder bytes %d\n", i);
3116 dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, 0);
3122 static int dsi_vc_send_short(
struct platform_device *dsidev,
int channel,
3123 u8 data_type,
u16 data,
u8 ecc)
3125 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3129 WARN_ON(!dsi_bus_is_locked(dsidev));
3132 DSSDBG(
"dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
3134 data_type, data & 0xff, (data >> 8) & 0xff);
3139 DSSERR(
"ERROR FIFO FULL, aborting transfer\n");
3143 data_id = data_type | dsi->
vc[
channel].vc_id << 6;
3145 r = (data_id << 0) | (data << 8) | (ecc << 24);
3168 r = dsi_vc_send_short(dsidev, channel,
3170 }
else if (len == 1) {
3171 r = dsi_vc_send_short(dsidev, channel,
3175 }
else if (len == 2) {
3176 r = dsi_vc_send_short(dsidev, channel,
3180 data[0] | (data[1] << 8), 0);
3182 r = dsi_vc_send_long(dsidev, channel,
3196 return dsi_vc_write_nosync_common(dsidev, channel, data, len,
3206 return dsi_vc_write_nosync_common(dsidev, channel, data, len,
3211 static int dsi_vc_write_common(
struct omap_dss_device *dssdev,
int channel,
3217 r = dsi_vc_write_nosync_common(dsidev, channel, data, len, type);
3227 DSSERR(
"rx fifo not empty after write, dumping data:\n");
3228 dsi_vc_flush_receive_data(dsidev, channel);
3235 DSSERR(
"dsi_vc_write_common(ch %d, cmd 0x%02x, len %d) failed\n",
3236 channel, data[0], len);
3243 return dsi_vc_write_common(dssdev, channel, data, len,
3251 return dsi_vc_write_common(dssdev, channel, data, len,
3295 static int dsi_vc_dcs_send_read_request(
struct platform_device *dsidev,
3296 int channel,
u8 dcs_cmd)
3298 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3302 DSSDBG(
"dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n",
3307 DSSERR(
"dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)"
3308 " failed\n", channel, dcs_cmd);
3315 static int dsi_vc_generic_send_read_request(
struct platform_device *dsidev,
3316 int channel,
u8 *reqdata,
int reqlen)
3318 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3324 DSSDBG(
"dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n",
3330 }
else if (reqlen == 1) {
3333 }
else if (reqlen == 2) {
3335 data = reqdata[0] | (reqdata[1] << 8);
3341 r = dsi_vc_send_short(dsidev, channel, data_type, data, 0);
3343 DSSERR(
"dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
3344 " failed\n", channel, reqlen);
3351 static int dsi_vc_read_rx_fifo(
struct platform_device *dsidev,
int channel,
3354 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3361 DSSERR(
"RX fifo empty when trying to read.\n");
3368 DSSDBG(
"\theader: %08x\n", val);
3372 dsi_show_rx_ack_with_err(err);
3381 DSSDBG(
"\t%s short response, 1 byte: %02x\n",
3398 DSSDBG(
"\t%s short response, 2 byte: %04x\n",
3407 buf[0] = data & 0xff;
3408 buf[1] = (data >> 8) & 0xff;
3415 int len =
FLD_GET(val, 23, 8);
3417 DSSDBG(
"\t%s long response, len %d\n",
3427 for (w = 0; w < len + 2;) {
3429 val = dsi_read_reg(dsidev,
3432 DSSDBG(
"\t\t%02x %02x %02x %02x\n",
3436 (val >> 24) & 0xff);
3438 for (b = 0; b < 4; ++
b) {
3440 buf[
w] = (val >> (b * 8)) & 0xff;
3448 DSSERR(
"\tunknown datatype 0x%02x\n", dt);
3454 DSSERR(
"dsi_vc_read_rx_fifo(ch %d type %s) failed\n", channel,
3461 u8 *buf,
int buflen)
3466 r = dsi_vc_dcs_send_read_request(dsidev, channel, dcs_cmd);
3474 r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
3486 DSSERR(
"dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", channel, dcs_cmd);
3491 static int dsi_vc_generic_read(
struct omap_dss_device *dssdev,
int channel,
3492 u8 *reqdata,
int reqlen,
u8 *buf,
int buflen)
3497 r = dsi_vc_generic_send_read_request(dsidev, channel, reqdata, reqlen);
3505 r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
3523 r = dsi_vc_generic_read(dssdev, channel,
NULL, 0, buf, buflen);
3525 DSSERR(
"dsi_vc_generic_read_0(ch %d) failed\n", channel);
3534 u8 *buf,
int buflen)
3538 r = dsi_vc_generic_read(dssdev, channel, ¶m, 1, buf, buflen);
3540 DSSERR(
"dsi_vc_generic_read_1(ch %d) failed\n", channel);
3555 reqdata[1] = param2;
3557 r = dsi_vc_generic_read(dssdev, channel, reqdata, 2, buf, buflen);
3559 DSSERR(
"dsi_vc_generic_read_2(ch %d) failed\n", channel);
3572 return dsi_vc_send_short(dsidev, channel,
3579 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3586 WARN_ON(!dsi_bus_is_locked(dsidev));
3595 dsi_if_enable(dsidev, 0);
3597 dsi_if_enable(dsidev, 1);
3600 dsi_sync_vc(dsidev, 0);
3601 dsi_sync_vc(dsidev, 1);
3602 dsi_sync_vc(dsidev, 2);
3603 dsi_sync_vc(dsidev, 3);
3605 dsi_force_tx_stop_mode_io(dsidev);
3607 dsi_vc_enable(dsidev, 0,
false);
3608 dsi_vc_enable(dsidev, 1,
false);
3609 dsi_vc_enable(dsidev, 2,
false);
3610 dsi_vc_enable(dsidev, 3,
false);
3613 DSSERR(
"HS busy when enabling ULPS\n");
3618 DSSERR(
"LP busy when enabling ULPS\n");
3622 r = dsi_register_isr_cio(dsidev, dsi_completion_handler, &
completion,
3643 DSSERR(
"ULPS enable timeout\n");
3648 dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &
completion,
3659 dsi_if_enable(dsidev,
false);
3666 dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &
completion,
3672 unsigned ticks,
bool x4,
bool x16)
3675 unsigned long total_ticks;
3681 fck = dsi_fclk_rate(dsidev);
3685 r =
FLD_MOD(r, x16 ? 1 : 0, 14, 14);
3686 r =
FLD_MOD(r, x4 ? 1 : 0, 13, 13);
3690 total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
3692 DSSDBG(
"LP_RX_TO %lu ticks (%#x%s%s) = %lu ns\n",
3694 ticks, x4 ?
" x4" :
"", x16 ?
" x16" :
"",
3695 (total_ticks * 1000) / (fck / 1000 / 1000));
3698 static void dsi_set_ta_timeout(
struct platform_device *dsidev,
unsigned ticks,
3702 unsigned long total_ticks;
3708 fck = dsi_fclk_rate(dsidev);
3712 r =
FLD_MOD(r, x16 ? 1 : 0, 30, 30);
3713 r =
FLD_MOD(r, x8 ? 1 : 0, 29, 29);
3714 r =
FLD_MOD(r, ticks, 28, 16);
3717 total_ticks = ticks * (x16 ? 16 : 1) * (x8 ? 8 : 1);
3719 DSSDBG(
"TA_TO %lu ticks (%#x%s%s) = %lu ns\n",
3721 ticks, x8 ?
" x8" :
"", x16 ?
" x16" :
"",
3722 (total_ticks * 1000) / (fck / 1000 / 1000));
3725 static void dsi_set_stop_state_counter(
struct platform_device *dsidev,
3726 unsigned ticks,
bool x4,
bool x16)
3729 unsigned long total_ticks;
3735 fck = dsi_fclk_rate(dsidev);
3739 r =
FLD_MOD(r, x16 ? 1 : 0, 14, 14);
3740 r =
FLD_MOD(r, x4 ? 1 : 0, 13, 13);
3744 total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
3746 DSSDBG(
"STOP_STATE_COUNTER %lu ticks (%#x%s%s) = %lu ns\n",
3748 ticks, x4 ?
" x4" :
"", x16 ?
" x16" :
"",
3749 (total_ticks * 1000) / (fck / 1000 / 1000));
3753 unsigned ticks,
bool x4,
bool x16)
3756 unsigned long total_ticks;
3762 fck = dsi_get_txbyteclkhs(dsidev);
3766 r =
FLD_MOD(r, x16 ? 1 : 0, 30, 30);
3767 r =
FLD_MOD(r, x4 ? 1 : 0, 29, 29);
3768 r =
FLD_MOD(r, ticks, 28, 16);
3771 total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
3773 DSSDBG(
"HS_TX_TO %lu ticks (%#x%s%s) = %lu ns\n",
3775 ticks, x4 ?
" x4" :
"", x16 ?
" x16" :
"",
3776 (total_ticks * 1000) / (fck / 1000 / 1000));
3779 static void dsi_config_vp_num_line_buffers(
struct platform_device *dsidev)
3781 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3782 int num_line_buffers;
3786 unsigned line_buf_size = dsi_get_line_buf_size(dsidev);
3792 if (line_buf_size <= timings->
x_res * bpp / 8)
3793 num_line_buffers = 0;
3795 num_line_buffers = 2;
3798 num_line_buffers = 2;
3807 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3808 bool vsync_end = dsi->
vm_timings.vp_vsync_end;
3809 bool hsync_end = dsi->
vm_timings.vp_hsync_end;
3812 r = dsi_read_reg(dsidev,
DSI_CTRL);
3817 r =
FLD_MOD(r, vsync_end, 16, 16);
3819 r =
FLD_MOD(r, hsync_end, 18, 18);
3820 dsi_write_reg(dsidev,
DSI_CTRL, r);
3825 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3826 int blanking_mode = dsi->
vm_timings.blanking_mode;
3827 int hfp_blanking_mode = dsi->
vm_timings.hfp_blanking_mode;
3828 int hbp_blanking_mode = dsi->
vm_timings.hbp_blanking_mode;
3829 int hsa_blanking_mode = dsi->
vm_timings.hsa_blanking_mode;
3836 r = dsi_read_reg(dsidev,
DSI_CTRL);
3837 r =
FLD_MOD(r, blanking_mode, 20, 20);
3838 r =
FLD_MOD(r, hfp_blanking_mode, 21, 21);
3839 r =
FLD_MOD(r, hbp_blanking_mode, 22, 22);
3840 r =
FLD_MOD(r, hsa_blanking_mode, 23, 23);
3841 dsi_write_reg(dsidev,
DSI_CTRL, r);
3852 static int dsi_compute_interleave_hs(
int blank,
bool ddr_alwon,
int enter_hs,
3853 int exit_hs,
int exiths_clk,
int ddr_pre,
int ddr_post)
3864 transition = enter_hs + exit_hs +
max(enter_hs, 2) + 1;
3867 trans1 = ddr_pre + enter_hs + exit_hs +
max(enter_hs, 2) + 1;
3868 trans2 = ddr_pre + enter_hs + exiths_clk + ddr_post + ddr_pre +
3870 transition =
max(trans1, trans2);
3873 return blank > transition ? blank - transition : 0;
3883 static int dsi_compute_interleave_lp(
int blank,
int enter_hs,
int exit_hs,
3884 int lp_clk_div,
int tdsi_fclk)
3889 int thsbyte_clk = 16;
3893 trans_lp = exit_hs +
max(enter_hs, 2) + 1;
3896 tlp_avail = thsbyte_clk * (blank - trans_lp);
3898 ttxclkesc = tdsi_fclk * lp_clk_div;
3900 lp_inter = ((tlp_avail - 8 * thsbyte_clk - 5 * tdsi_fclk) / ttxclkesc -
3903 return max(lp_inter, 0);
3906 static void dsi_config_cmd_mode_interleaving(
struct omap_dss_device *dssdev)
3909 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3911 int hfp_blanking_mode, hbp_blanking_mode, hsa_blanking_mode;
3912 int hsa, hfp, hbp, width_bytes, bllp, lp_clk_div;
3913 int ddr_clk_pre, ddr_clk_post, enter_hs_mode_lat, exit_hs_mode_lat;
3914 int tclk_trail, ths_exit, exiths_clk;
3919 int dsi_fclk_hsdiv = dssdev->
clocks.dsi.regm_dsi + 1;
3920 int hsa_interleave_hs = 0, hsa_interleave_lp = 0;
3921 int hfp_interleave_hs = 0, hfp_interleave_lp = 0;
3922 int hbp_interleave_hs = 0, hbp_interleave_lp = 0;
3923 int bl_interleave_hs = 0, bl_interleave_lp = 0;
3926 r = dsi_read_reg(dsidev,
DSI_CTRL);
3927 blanking_mode =
FLD_GET(r, 20, 20);
3928 hfp_blanking_mode =
FLD_GET(r, 21, 21);
3929 hbp_blanking_mode =
FLD_GET(r, 22, 22);
3930 hsa_blanking_mode =
FLD_GET(r, 23, 23);
3938 ddr_clk_post =
FLD_GET(r, 7, 0);
3939 ddr_clk_pre =
FLD_GET(r, 15, 8);
3942 exit_hs_mode_lat =
FLD_GET(r, 15, 0);
3943 enter_hs_mode_lat =
FLD_GET(r, 31, 16);
3946 lp_clk_div =
FLD_GET(r, 12, 0);
3947 ddr_alwon =
FLD_GET(r, 13, 13);
3953 tclk_trail =
FLD_GET(r, 15, 8);
3955 exiths_clk = ths_exit + tclk_trail;
3958 bllp = hbp + hfp + hsa +
DIV_ROUND_UP(width_bytes + 6, ndl);
3960 if (!hsa_blanking_mode) {
3961 hsa_interleave_hs = dsi_compute_interleave_hs(hsa, ddr_alwon,
3962 enter_hs_mode_lat, exit_hs_mode_lat,
3963 exiths_clk, ddr_clk_pre, ddr_clk_post);
3964 hsa_interleave_lp = dsi_compute_interleave_lp(hsa,
3965 enter_hs_mode_lat, exit_hs_mode_lat,
3966 lp_clk_div, dsi_fclk_hsdiv);
3969 if (!hfp_blanking_mode) {
3970 hfp_interleave_hs = dsi_compute_interleave_hs(hfp, ddr_alwon,
3971 enter_hs_mode_lat, exit_hs_mode_lat,
3972 exiths_clk, ddr_clk_pre, ddr_clk_post);
3973 hfp_interleave_lp = dsi_compute_interleave_lp(hfp,
3974 enter_hs_mode_lat, exit_hs_mode_lat,
3975 lp_clk_div, dsi_fclk_hsdiv);
3978 if (!hbp_blanking_mode) {
3979 hbp_interleave_hs = dsi_compute_interleave_hs(hbp, ddr_alwon,
3980 enter_hs_mode_lat, exit_hs_mode_lat,
3981 exiths_clk, ddr_clk_pre, ddr_clk_post);
3983 hbp_interleave_lp = dsi_compute_interleave_lp(hbp,
3984 enter_hs_mode_lat, exit_hs_mode_lat,
3985 lp_clk_div, dsi_fclk_hsdiv);
3988 if (!blanking_mode) {
3989 bl_interleave_hs = dsi_compute_interleave_hs(bllp, ddr_alwon,
3990 enter_hs_mode_lat, exit_hs_mode_lat,
3991 exiths_clk, ddr_clk_pre, ddr_clk_post);
3993 bl_interleave_lp = dsi_compute_interleave_lp(bllp,
3994 enter_hs_mode_lat, exit_hs_mode_lat,
3995 lp_clk_div, dsi_fclk_hsdiv);
3998 DSSDBG(
"DSI HS interleaving(TXBYTECLKHS) HSA %d, HFP %d, HBP %d, BLLP %d\n",
3999 hsa_interleave_hs, hfp_interleave_hs, hbp_interleave_hs,
4002 DSSDBG(
"DSI LP interleaving(bytes) HSA %d, HFP %d, HBP %d, BLLP %d\n",
4003 hsa_interleave_lp, hfp_interleave_lp, hbp_interleave_lp,
4007 r =
FLD_MOD(r, hsa_interleave_hs, 23, 16);
4008 r =
FLD_MOD(r, hfp_interleave_hs, 15, 8);
4009 r =
FLD_MOD(r, hbp_interleave_hs, 7, 0);
4013 r =
FLD_MOD(r, hsa_interleave_lp, 23, 16);
4014 r =
FLD_MOD(r, hfp_interleave_lp, 15, 8);
4015 r =
FLD_MOD(r, hbp_interleave_lp, 7, 0);
4019 r =
FLD_MOD(r, bl_interleave_hs, 31, 15);
4020 r =
FLD_MOD(r, bl_interleave_lp, 16, 0);
4027 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4042 dsi_set_stop_state_counter(dsidev, 0x1000,
false,
false);
4043 dsi_set_ta_timeout(dsidev, 0x1fff,
true,
true);
4044 dsi_set_lp_rx_timeout(dsidev, 0x1fff,
true,
true);
4045 dsi_set_hs_tx_timeout(dsidev, 0x1fff,
true,
true);
4062 r = dsi_read_reg(dsidev,
DSI_CTRL);
4067 r =
FLD_MOD(r, buswidth, 7, 6);
4077 dsi_write_reg(dsidev,
DSI_CTRL, r);
4079 dsi_config_vp_num_line_buffers(dsidev);
4082 dsi_config_vp_sync_events(dsidev);
4083 dsi_config_blanking_modes(dsidev);
4084 dsi_config_cmd_mode_interleaving(dssdev);
4087 dsi_vc_initial_config(dsidev, 0);
4088 dsi_vc_initial_config(dsidev, 1);
4089 dsi_vc_initial_config(dsidev, 2);
4090 dsi_vc_initial_config(dsidev, 3);
4097 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4098 unsigned tlpx, tclk_zero, tclk_prepare, tclk_trail;
4099 unsigned tclk_pre, tclk_post;
4100 unsigned ths_prepare, ths_prepare_ths_zero, ths_zero;
4101 unsigned ths_trail, ths_exit;
4102 unsigned ddr_clk_pre, ddr_clk_post;
4103 unsigned enter_hs_mode_lat, exit_hs_mode_lat;
4109 ths_prepare =
FLD_GET(r, 31, 24);
4110 ths_prepare_ths_zero =
FLD_GET(r, 23, 16);
4111 ths_zero = ths_prepare_ths_zero - ths_prepare;
4112 ths_trail =
FLD_GET(r, 15, 8);
4116 tlpx =
FLD_GET(r, 20, 16) * 2;
4117 tclk_trail =
FLD_GET(r, 15, 8);
4121 tclk_prepare =
FLD_GET(r, 7, 0);
4126 tclk_post = ns2ddr(dsidev, 60) + 26;
4130 ddr_clk_pre =
DIV_ROUND_UP(tclk_pre + tlpx + tclk_zero + tclk_prepare,
4132 ddr_clk_post =
DIV_ROUND_UP(tclk_post + ths_trail, 4) + ths_eot;
4134 BUG_ON(ddr_clk_pre == 0 || ddr_clk_pre > 255);
4135 BUG_ON(ddr_clk_post == 0 || ddr_clk_post > 255);
4138 r =
FLD_MOD(r, ddr_clk_pre, 15, 8);
4139 r =
FLD_MOD(r, ddr_clk_post, 7, 0);
4142 DSSDBG(
"ddr_clk_pre %u, ddr_clk_post %u\n",
4150 exit_hs_mode_lat =
DIV_ROUND_UP(ths_trail + ths_exit, 4) + 1 + ths_eot;
4152 r =
FLD_VAL(enter_hs_mode_lat, 31, 16) |
4153 FLD_VAL(exit_hs_mode_lat, 15, 0);
4156 DSSDBG(
"enter_hs_mode_lat %u, exit_hs_mode_lat %u\n",
4157 enter_hs_mode_lat, exit_hs_mode_lat);
4167 int window_sync = dsi->
vm_timings.window_sync;
4168 bool hsync_end = dsi->
vm_timings.vp_hsync_end;
4171 int tl, t_he, width_bytes;
4174 ((hsa == 0 && ndl == 3) ? 1 :
DIV_ROUND_UP(4, ndl)) : 0;
4179 tl =
DIV_ROUND_UP(4, ndl) + (hsync_end ? hsa : 0) + t_he + hfp +
4182 DSSDBG(
"HBP: %d, HFP: %d, HSA: %d, TL: %d TXBYTECLKHS\n", hbp,
4183 hfp, hsync_end ? hsa : 0, tl);
4184 DSSDBG(
"VBP: %d, VFP: %d, VSA: %d, VACT: %d lines\n", vbp, vfp,
4185 vsa, timings->
y_res);
4190 r =
FLD_MOD(r, hsync_end ? hsa : 0, 31, 24);
4197 r =
FLD_MOD(r, window_sync, 27, 24);
4211 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4227 pins = pin_cfg->
pins;
4230 || num_pins % 2 != 0)
4238 for (i = 0; i < num_pins; i += 2) {
4263 lanes[lane].
function = functions[i / 2];
4276 unsigned long ddr_clk,
unsigned long lp_clk)
4279 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4282 unsigned lp_clk_div;
4283 unsigned long dsi_fclk;
4288 DSSDBGF(
"ddr_clk %lu, lp_clk %lu", ddr_clk, lp_clk);
4293 r = dsi_pll_calc_ddrfreq(dsidev, ddr_clk * 4, &cinfo);
4298 dsi_pll_calc_dsi_fck(dsidev, &cinfo);
4302 DSSDBG(
"finding dispc dividers for pck %lu\n", pck);
4303 r = dsi_pll_calc_dispc_fck(dsidev, pck, &cinfo, &dispc_cinfo);
4316 dssdev->
clocks.dsi.lp_clk_div = lp_clk_div;
4323 dssdev->
clocks.dispc.channel.lcd_clk_src =
4328 dssdev->
clocks.dsi.dsi_fclk_src =
4344 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4370 dsi_if_enable(dsidev,
false);
4371 dsi_vc_enable(dsidev, channel,
false);
4378 dsi_vc_write_long_header(dsidev, channel, data_type,
4381 dsi_vc_enable(dsidev, channel,
true);
4382 dsi_if_enable(dsidev,
true);
4388 dsi_if_enable(dsidev,
false);
4389 dsi_vc_enable(dsidev, channel,
false);
4402 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4406 dsi_if_enable(dsidev,
false);
4407 dsi_vc_enable(dsidev, channel,
false);
4412 dsi_vc_enable(dsidev, channel,
true);
4413 dsi_if_enable(dsidev,
true);
4423 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4429 unsigned packet_payload;
4430 unsigned packet_len;
4434 const unsigned line_buf_size = dsi_get_line_buf_size(dsidev);
4438 DSSDBG(
"dsi_update_screen_dispc(%dx%d)\n", w, h);
4443 bytespl = w * bytespp;
4444 bytespf = bytespl *
h;
4449 if (bytespf < line_buf_size)
4450 packet_payload = bytespf;
4452 packet_payload = (line_buf_size) / bytespl * bytespl;
4454 packet_len = packet_payload + 1;
4455 total_len = (bytespf / packet_payload) * packet_len;
4457 if (bytespf % packet_payload)
4458 total_len += (bytespf % packet_payload) + 1;
4460 l =
FLD_VAL(total_len, 23, 0);
4461 dsi_write_reg(dsidev,
DSI_VC_TE(channel), l);
4470 dsi_write_reg(dsidev,
DSI_VC_TE(channel), l);
4480 dsi_perf_mark_start(dsidev);
4495 dsi_vc_send_bta(dsidev, channel);
4497 #ifdef DSI_CATCH_MISSING_TE
4503 #ifdef DSI_CATCH_MISSING_TE
4504 static void dsi_te_timeout(
unsigned long arg)
4506 DSSERR(
"TE not received for 250ms!\n");
4512 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4525 dsi_perf_show(dsidev,
"DISPC");
4528 static void dsi_framedone_timeout_work_callback(
struct work_struct *
work)
4539 DSSERR(
"Framedone not received for 250ms!\n");
4544 static void dsi_framedone_irq_callback(
void *data,
u32 mask)
4547 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4556 dsi_handle_framedone(dsidev, 0);
4560 void (*
callback)(
int,
void *),
void *data)
4563 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4566 dsi_perf_mark_setup(dsidev);
4577 dsi->update_bytes = dw * dh *
4580 dsi_update_screen_dispc(dssdev);
4591 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4594 unsigned long long fck;
4603 DSSERR(
"Failed to calc dispc clocks\n");
4615 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4631 (
void *) dsidev, irq);
4633 DSSERR(
"can't get FRAMEDONE irq\n");
4648 dsi->
timings.interlace =
false;
4657 r = dsi_configure_dispc_clocks(dssdev);
4672 (
void *) dsidev, irq);
4680 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4689 (
void *) dsidev, irq);
4703 r = dsi_calc_clock_rates(dsidev, &cinfo);
4705 DSSERR(
"Failed to calc dsi clocks\n");
4711 DSSERR(
"Failed to set dsi clocks\n");
4721 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4729 r = dsi_configure_dsi_clocks(dssdev);
4736 dssdev->
clocks.dispc.channel.lcd_clk_src);
4740 r = dsi_cio_init(dsidev);
4746 dsi_proto_timings(dsidev);
4747 dsi_set_lp_clk_divisor(dssdev);
4752 r = dsi_proto_config(dssdev);
4757 dsi_vc_enable(dsidev, 0, 1);
4758 dsi_vc_enable(dsidev, 1, 1);
4759 dsi_vc_enable(dsidev, 2, 1);
4760 dsi_vc_enable(dsidev, 3, 1);
4761 dsi_if_enable(dsidev, 1);
4762 dsi_force_tx_stop_mode_io(dsidev);
4766 dsi_cio_uninit(dsidev);
4779 bool disconnect_lanes,
bool enter_ulps)
4782 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4786 dsi_enter_ulps(dsidev);
4789 dsi_if_enable(dsidev, 0);
4790 dsi_vc_enable(dsidev, 0, 0);
4791 dsi_vc_enable(dsidev, 1, 0);
4792 dsi_vc_enable(dsidev, 2, 0);
4793 dsi_vc_enable(dsidev, 3, 0);
4798 dsi_cio_uninit(dsidev);
4805 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4809 DSSDBG(
"dsi_display_enable\n");
4811 WARN_ON(!dsi_bus_is_locked(dsidev));
4816 DSSERR(
"failed to enable display: no output/manager\n");
4823 DSSERR(
"failed to start device\n");
4831 dsi_enable_pll_clock(dsidev, 1);
4833 _dsi_initialize_irq(dsidev);
4835 r = dsi_display_init_dispc(dssdev);
4837 goto err_init_dispc;
4839 r = dsi_display_init_dsi(dssdev);
4848 dsi_display_uninit_dispc(dssdev);
4850 dsi_enable_pll_clock(dsidev, 0);
4856 DSSDBG(
"dsi_display_enable FAILED\n");
4862 bool disconnect_lanes,
bool enter_ulps)
4865 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4867 DSSDBG(
"dsi_display_disable\n");
4869 WARN_ON(!dsi_bus_is_locked(dsidev));
4873 dsi_sync_vc(dsidev, 0);
4874 dsi_sync_vc(dsidev, 1);
4875 dsi_sync_vc(dsidev, 2);
4876 dsi_sync_vc(dsidev, 3);
4878 dsi_display_uninit_dispc(dssdev);
4880 dsi_display_uninit_dsi(dssdev, disconnect_lanes, enter_ulps);
4883 dsi_enable_pll_clock(dsidev, 0);
4894 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4905 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4918 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4933 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4947 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4961 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4975 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
4984 if (IS_ERR(vdds_dsi)) {
4985 DSSERR(
"can't get VDDS_DSI regulator\n");
4986 return PTR_ERR(vdds_dsi);
4998 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5002 if (!dsi->
vc[i].dssdev) {
5009 DSSERR(
"cannot get VC for display %s", dssdev->
name);
5017 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5019 if (vc_id < 0 || vc_id > 3) {
5020 DSSERR(
"VC ID out of range\n");
5025 DSSERR(
"Virtual Channel out of range\n");
5029 if (dsi->
vc[channel].dssdev != dssdev) {
5030 DSSERR(
"Virtual Channel not allocated to display %s\n",
5044 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5046 if ((channel >= 0 && channel <= 3) &&
5047 dsi->
vc[channel].dssdev == dssdev) {
5057 DSSERR(
"%s (%s) not active\n",
5065 DSSERR(
"%s (%s) not active\n",
5070 static void dsi_calc_clock_param_ranges(
struct platform_device *dsidev)
5072 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5086 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5091 DSSERR(
"can't get fck\n");
5092 return PTR_ERR(clk);
5099 DSSERR(
"can't get sys_clk\n");
5102 return PTR_ERR(clk);
5112 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5123 struct dsi_data *dsi = dsi_get_dsidrv_data(pdev);
5139 if (def_dssdev ==
NULL)
5142 if (def_disp_name !=
NULL &&
5158 plat_dssdev = dsi_find_dssdev(dsidev);
5169 r = dsi_init_display(dssdev);
5171 DSSERR(
"device %s init failed: %d\n", dssdev->
name, r);
5178 DSSERR(
"device %s register failed: %d\n", dssdev->
name, r);
5186 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5200 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5226 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
5228 dsi->irq_stats.last_reset =
jiffies;
5235 dsi_framedone_timeout_work_callback);
5237 #ifdef DSI_CATCH_MISSING_TE
5239 dsi->
te_timer.function = dsi_te_timeout;
5244 DSSERR(
"can't get IORESOURCE_MEM DSI\n");
5249 resource_size(dsi_mem));
5251 DSSERR(
"can't ioremap DSI\n");
5257 DSSERR(
"platform_get_irq failed\n");
5261 r = devm_request_irq(&dsidev->
dev, dsi->
irq, omap_dsi_irq_handler,
5264 DSSERR(
"request_irq failed\n");
5272 dsi->
vc[
i].vc_id = 0;
5275 dsi_calc_clock_param_ranges(dsidev);
5277 r = dsi_get_clocks(dsidev);
5285 goto err_runtime_get;
5288 dev_dbg(&dsidev->
dev,
"OMAP DSI rev %d.%d\n",
5299 dsi_init_output(dsidev);
5301 dsi_probe_pdata(dsidev);
5310 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
5319 pm_runtime_disable(&dsidev->
dev);
5320 dsi_put_clocks(dsidev);
5326 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
5332 dsi_uninit_output(dsidev);
5334 pm_runtime_disable(&dsidev->
dev);
5336 dsi_put_clocks(dsidev);
5351 static int dsi_runtime_suspend(
struct device *
dev)
5358 static int dsi_runtime_resume(
struct device *
dev)
5369 static const struct dev_pm_ops dsi_pm_ops = {
5370 .runtime_suspend = dsi_runtime_suspend,
5371 .runtime_resume = dsi_runtime_resume,
5375 .remove =
__exit_p(omap_dsihw_remove),
5377 .name =
"omapdss_dsi",