2 * linux/drivers/video/omap2/dss/dsi.c
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
20 #define DSS_SUBSYS_NAME "DSI"
22 #include <linux/kernel.h>
24 #include <linux/clk.h>
25 #include <linux/device.h>
26 #include <linux/err.h>
27 #include <linux/interrupt.h>
28 #include <linux/delay.h>
29 #include <linux/mutex.h>
30 #include <linux/semaphore.h>
31 #include <linux/seq_file.h>
32 #include <linux/platform_device.h>
33 #include <linux/regulator/consumer.h>
34 #include <linux/wait.h>
35 #include <linux/workqueue.h>
36 #include <linux/sched.h>
37 #include <linux/slab.h>
38 #include <linux/debugfs.h>
39 #include <linux/pm_runtime.h>
41 #include <video/omapdss.h>
42 #include <plat/clock.h>
45 #include "dss_features.h"
47 /*#define VERBOSE_IRQ*/
48 #define DSI_CATCH_MISSING_TE
50 struct dsi_reg
{ u16 idx
; };
52 #define DSI_REG(idx) ((const struct dsi_reg) { idx })
54 #define DSI_SZ_REGS SZ_1K
55 /* DSI Protocol Engine */
57 #define DSI_REVISION DSI_REG(0x0000)
58 #define DSI_SYSCONFIG DSI_REG(0x0010)
59 #define DSI_SYSSTATUS DSI_REG(0x0014)
60 #define DSI_IRQSTATUS DSI_REG(0x0018)
61 #define DSI_IRQENABLE DSI_REG(0x001C)
62 #define DSI_CTRL DSI_REG(0x0040)
63 #define DSI_GNQ DSI_REG(0x0044)
64 #define DSI_COMPLEXIO_CFG1 DSI_REG(0x0048)
65 #define DSI_COMPLEXIO_IRQ_STATUS DSI_REG(0x004C)
66 #define DSI_COMPLEXIO_IRQ_ENABLE DSI_REG(0x0050)
67 #define DSI_CLK_CTRL DSI_REG(0x0054)
68 #define DSI_TIMING1 DSI_REG(0x0058)
69 #define DSI_TIMING2 DSI_REG(0x005C)
70 #define DSI_VM_TIMING1 DSI_REG(0x0060)
71 #define DSI_VM_TIMING2 DSI_REG(0x0064)
72 #define DSI_VM_TIMING3 DSI_REG(0x0068)
73 #define DSI_CLK_TIMING DSI_REG(0x006C)
74 #define DSI_TX_FIFO_VC_SIZE DSI_REG(0x0070)
75 #define DSI_RX_FIFO_VC_SIZE DSI_REG(0x0074)
76 #define DSI_COMPLEXIO_CFG2 DSI_REG(0x0078)
77 #define DSI_RX_FIFO_VC_FULLNESS DSI_REG(0x007C)
78 #define DSI_VM_TIMING4 DSI_REG(0x0080)
79 #define DSI_TX_FIFO_VC_EMPTINESS DSI_REG(0x0084)
80 #define DSI_VM_TIMING5 DSI_REG(0x0088)
81 #define DSI_VM_TIMING6 DSI_REG(0x008C)
82 #define DSI_VM_TIMING7 DSI_REG(0x0090)
83 #define DSI_STOPCLK_TIMING DSI_REG(0x0094)
84 #define DSI_VC_CTRL(n) DSI_REG(0x0100 + (n * 0x20))
85 #define DSI_VC_TE(n) DSI_REG(0x0104 + (n * 0x20))
86 #define DSI_VC_LONG_PACKET_HEADER(n) DSI_REG(0x0108 + (n * 0x20))
87 #define DSI_VC_LONG_PACKET_PAYLOAD(n) DSI_REG(0x010C + (n * 0x20))
88 #define DSI_VC_SHORT_PACKET_HEADER(n) DSI_REG(0x0110 + (n * 0x20))
89 #define DSI_VC_IRQSTATUS(n) DSI_REG(0x0118 + (n * 0x20))
90 #define DSI_VC_IRQENABLE(n) DSI_REG(0x011C + (n * 0x20))
94 #define DSI_DSIPHY_CFG0 DSI_REG(0x200 + 0x0000)
95 #define DSI_DSIPHY_CFG1 DSI_REG(0x200 + 0x0004)
96 #define DSI_DSIPHY_CFG2 DSI_REG(0x200 + 0x0008)
97 #define DSI_DSIPHY_CFG5 DSI_REG(0x200 + 0x0014)
98 #define DSI_DSIPHY_CFG10 DSI_REG(0x200 + 0x0028)
100 /* DSI_PLL_CTRL_SCP */
102 #define DSI_PLL_CONTROL DSI_REG(0x300 + 0x0000)
103 #define DSI_PLL_STATUS DSI_REG(0x300 + 0x0004)
104 #define DSI_PLL_GO DSI_REG(0x300 + 0x0008)
105 #define DSI_PLL_CONFIGURATION1 DSI_REG(0x300 + 0x000C)
106 #define DSI_PLL_CONFIGURATION2 DSI_REG(0x300 + 0x0010)
108 #define REG_GET(dsidev, idx, start, end) \
109 FLD_GET(dsi_read_reg(dsidev, idx), start, end)
111 #define REG_FLD_MOD(dsidev, idx, val, start, end) \
112 dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, start, end))
114 /* Global interrupts */
115 #define DSI_IRQ_VC0 (1 << 0)
116 #define DSI_IRQ_VC1 (1 << 1)
117 #define DSI_IRQ_VC2 (1 << 2)
118 #define DSI_IRQ_VC3 (1 << 3)
119 #define DSI_IRQ_WAKEUP (1 << 4)
120 #define DSI_IRQ_RESYNC (1 << 5)
121 #define DSI_IRQ_PLL_LOCK (1 << 7)
122 #define DSI_IRQ_PLL_UNLOCK (1 << 8)
123 #define DSI_IRQ_PLL_RECALL (1 << 9)
124 #define DSI_IRQ_COMPLEXIO_ERR (1 << 10)
125 #define DSI_IRQ_HS_TX_TIMEOUT (1 << 14)
126 #define DSI_IRQ_LP_RX_TIMEOUT (1 << 15)
127 #define DSI_IRQ_TE_TRIGGER (1 << 16)
128 #define DSI_IRQ_ACK_TRIGGER (1 << 17)
129 #define DSI_IRQ_SYNC_LOST (1 << 18)
130 #define DSI_IRQ_LDO_POWER_GOOD (1 << 19)
131 #define DSI_IRQ_TA_TIMEOUT (1 << 20)
132 #define DSI_IRQ_ERROR_MASK \
133 (DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
135 #define DSI_IRQ_CHANNEL_MASK 0xf
137 /* Virtual channel interrupts */
138 #define DSI_VC_IRQ_CS (1 << 0)
139 #define DSI_VC_IRQ_ECC_CORR (1 << 1)
140 #define DSI_VC_IRQ_PACKET_SENT (1 << 2)
141 #define DSI_VC_IRQ_FIFO_TX_OVF (1 << 3)
142 #define DSI_VC_IRQ_FIFO_RX_OVF (1 << 4)
143 #define DSI_VC_IRQ_BTA (1 << 5)
144 #define DSI_VC_IRQ_ECC_NO_CORR (1 << 6)
145 #define DSI_VC_IRQ_FIFO_TX_UDF (1 << 7)
146 #define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
147 #define DSI_VC_IRQ_ERROR_MASK \
148 (DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
149 DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
150 DSI_VC_IRQ_FIFO_TX_UDF)
152 /* ComplexIO interrupts */
153 #define DSI_CIO_IRQ_ERRSYNCESC1 (1 << 0)
154 #define DSI_CIO_IRQ_ERRSYNCESC2 (1 << 1)
155 #define DSI_CIO_IRQ_ERRSYNCESC3 (1 << 2)
156 #define DSI_CIO_IRQ_ERRSYNCESC4 (1 << 3)
157 #define DSI_CIO_IRQ_ERRSYNCESC5 (1 << 4)
158 #define DSI_CIO_IRQ_ERRESC1 (1 << 5)
159 #define DSI_CIO_IRQ_ERRESC2 (1 << 6)
160 #define DSI_CIO_IRQ_ERRESC3 (1 << 7)
161 #define DSI_CIO_IRQ_ERRESC4 (1 << 8)
162 #define DSI_CIO_IRQ_ERRESC5 (1 << 9)
163 #define DSI_CIO_IRQ_ERRCONTROL1 (1 << 10)
164 #define DSI_CIO_IRQ_ERRCONTROL2 (1 << 11)
165 #define DSI_CIO_IRQ_ERRCONTROL3 (1 << 12)
166 #define DSI_CIO_IRQ_ERRCONTROL4 (1 << 13)
167 #define DSI_CIO_IRQ_ERRCONTROL5 (1 << 14)
168 #define DSI_CIO_IRQ_STATEULPS1 (1 << 15)
169 #define DSI_CIO_IRQ_STATEULPS2 (1 << 16)
170 #define DSI_CIO_IRQ_STATEULPS3 (1 << 17)
171 #define DSI_CIO_IRQ_STATEULPS4 (1 << 18)
172 #define DSI_CIO_IRQ_STATEULPS5 (1 << 19)
173 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_1 (1 << 20)
174 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_1 (1 << 21)
175 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_2 (1 << 22)
176 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_2 (1 << 23)
177 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_3 (1 << 24)
178 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_3 (1 << 25)
179 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_4 (1 << 26)
180 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_4 (1 << 27)
181 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_5 (1 << 28)
182 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_5 (1 << 29)
183 #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0 (1 << 30)
184 #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1 (1 << 31)
185 #define DSI_CIO_IRQ_ERROR_MASK \
186 (DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
187 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
188 DSI_CIO_IRQ_ERRSYNCESC5 | \
189 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
190 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
191 DSI_CIO_IRQ_ERRESC5 | \
192 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
193 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
194 DSI_CIO_IRQ_ERRCONTROL5 | \
195 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
196 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
197 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
198 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
199 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
201 #define DSI_DT_DCS_SHORT_WRITE_0 0x05
202 #define DSI_DT_DCS_SHORT_WRITE_1 0x15
203 #define DSI_DT_DCS_READ 0x06
204 #define DSI_DT_SET_MAX_RET_PKG_SIZE 0x37
205 #define DSI_DT_NULL_PACKET 0x09
206 #define DSI_DT_DCS_LONG_WRITE 0x39
208 #define DSI_DT_RX_ACK_WITH_ERR 0x02
209 #define DSI_DT_RX_DCS_LONG_READ 0x1c
210 #define DSI_DT_RX_SHORT_READ_1 0x21
211 #define DSI_DT_RX_SHORT_READ_2 0x22
213 typedef void (*omap_dsi_isr_t
) (void *arg
, u32 mask
);
215 #define DSI_MAX_NR_ISRS 2
217 struct dsi_isr_data
{
225 DSI_FIFO_SIZE_32
= 1,
226 DSI_FIFO_SIZE_64
= 2,
227 DSI_FIFO_SIZE_96
= 3,
228 DSI_FIFO_SIZE_128
= 4,
239 DSI_DATA1_P
= 1 << 2,
240 DSI_DATA1_N
= 1 << 3,
241 DSI_DATA2_P
= 1 << 4,
242 DSI_DATA2_N
= 1 << 5,
243 DSI_DATA3_P
= 1 << 6,
244 DSI_DATA3_N
= 1 << 7,
245 DSI_DATA4_P
= 1 << 8,
246 DSI_DATA4_N
= 1 << 9,
249 struct dsi_update_region
{
251 struct omap_dss_device
*device
;
254 struct dsi_irq_stats
{
255 unsigned long last_reset
;
257 unsigned dsi_irqs
[32];
258 unsigned vc_irqs
[4][32];
259 unsigned cio_irqs
[32];
262 struct dsi_isr_tables
{
263 struct dsi_isr_data isr_table
[DSI_MAX_NR_ISRS
];
264 struct dsi_isr_data isr_table_vc
[4][DSI_MAX_NR_ISRS
];
265 struct dsi_isr_data isr_table_cio
[DSI_MAX_NR_ISRS
];
269 struct platform_device
*pdev
;
277 void (*dsi_mux_pads
)(bool enable
);
279 struct dsi_clock_info current_cinfo
;
281 bool vdds_dsi_enabled
;
282 struct regulator
*vdds_dsi_reg
;
285 enum dsi_vc_mode mode
;
286 struct omap_dss_device
*dssdev
;
287 enum fifo_size fifo_size
;
292 struct semaphore bus_lock
;
297 struct dsi_isr_tables isr_tables
;
298 /* space for a copy used by the interrupt handler */
299 struct dsi_isr_tables isr_tables_copy
;
302 struct dsi_update_region update_region
;
307 void (*framedone_callback
)(int, void *);
308 void *framedone_data
;
310 struct delayed_work framedone_timeout_work
;
312 #ifdef DSI_CATCH_MISSING_TE
313 struct timer_list te_timer
;
316 unsigned long cache_req_pck
;
317 unsigned long cache_clk_freq
;
318 struct dsi_clock_info cache_cinfo
;
321 spinlock_t errors_lock
;
323 ktime_t perf_setup_time
;
324 ktime_t perf_start_time
;
329 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
330 spinlock_t irq_stats_lock
;
331 struct dsi_irq_stats irq_stats
;
333 /* DSI PLL Parameter Ranges */
334 unsigned long regm_max
, regn_max
;
335 unsigned long regm_dispc_max
, regm_dsi_max
;
336 unsigned long fint_min
, fint_max
;
337 unsigned long lpdiv_max
;
341 unsigned scp_clk_refcount
;
344 struct dsi_packet_sent_handler_data
{
345 struct platform_device
*dsidev
;
346 struct completion
*completion
;
349 static struct platform_device
*dsi_pdev_map
[MAX_NUM_DSI
];
352 static unsigned int dsi_perf
;
353 module_param_named(dsi_perf
, dsi_perf
, bool, 0644);
356 static inline struct dsi_data
*dsi_get_dsidrv_data(struct platform_device
*dsidev
)
358 return dev_get_drvdata(&dsidev
->dev
);
361 static inline struct platform_device
*dsi_get_dsidev_from_dssdev(struct omap_dss_device
*dssdev
)
363 return dsi_pdev_map
[dssdev
->phy
.dsi
.module
];
366 struct platform_device
*dsi_get_dsidev_from_id(int module
)
368 return dsi_pdev_map
[module
];
371 static int dsi_get_dsidev_id(struct platform_device
*dsidev
)
373 /* TEMP: Pass 0 as the dsi module index till the time the dsi platform
374 * device names aren't changed to the form "omapdss_dsi.0",
375 * "omapdss_dsi.1" and so on */
376 BUG_ON(dsidev
->id
!= -1);
381 static inline void dsi_write_reg(struct platform_device
*dsidev
,
382 const struct dsi_reg idx
, u32 val
)
384 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
386 __raw_writel(val
, dsi
->base
+ idx
.idx
);
389 static inline u32
dsi_read_reg(struct platform_device
*dsidev
,
390 const struct dsi_reg idx
)
392 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
394 return __raw_readl(dsi
->base
+ idx
.idx
);
397 void dsi_bus_lock(struct omap_dss_device
*dssdev
)
399 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
400 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
402 down(&dsi
->bus_lock
);
404 EXPORT_SYMBOL(dsi_bus_lock
);
406 void dsi_bus_unlock(struct omap_dss_device
*dssdev
)
408 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
409 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
413 EXPORT_SYMBOL(dsi_bus_unlock
);
415 static bool dsi_bus_is_locked(struct platform_device
*dsidev
)
417 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
419 return dsi
->bus_lock
.count
== 0;
422 static void dsi_completion_handler(void *data
, u32 mask
)
424 complete((struct completion
*)data
);
427 static inline int wait_for_bit_change(struct platform_device
*dsidev
,
428 const struct dsi_reg idx
, int bitnum
, int value
)
432 while (REG_GET(dsidev
, idx
, bitnum
, bitnum
) != value
) {
441 static void dsi_perf_mark_setup(struct platform_device
*dsidev
)
443 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
444 dsi
->perf_setup_time
= ktime_get();
447 static void dsi_perf_mark_start(struct platform_device
*dsidev
)
449 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
450 dsi
->perf_start_time
= ktime_get();
453 static void dsi_perf_show(struct platform_device
*dsidev
, const char *name
)
455 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
456 ktime_t t
, setup_time
, trans_time
;
458 u32 setup_us
, trans_us
, total_us
;
465 setup_time
= ktime_sub(dsi
->perf_start_time
, dsi
->perf_setup_time
);
466 setup_us
= (u32
)ktime_to_us(setup_time
);
470 trans_time
= ktime_sub(t
, dsi
->perf_start_time
);
471 trans_us
= (u32
)ktime_to_us(trans_time
);
475 total_us
= setup_us
+ trans_us
;
477 total_bytes
= dsi
->update_region
.w
*
478 dsi
->update_region
.h
*
479 dsi
->update_region
.device
->ctrl
.pixel_size
/ 8;
481 printk(KERN_INFO
"DSI(%s): %u us + %u us = %u us (%uHz), "
482 "%u bytes, %u kbytes/sec\n",
487 1000*1000 / total_us
,
489 total_bytes
* 1000 / total_us
);
492 static inline void dsi_perf_mark_setup(struct platform_device
*dsidev
)
496 static inline void dsi_perf_mark_start(struct platform_device
*dsidev
)
500 static inline void dsi_perf_show(struct platform_device
*dsidev
,
506 static void print_irq_status(u32 status
)
512 if ((status
& ~DSI_IRQ_CHANNEL_MASK
) == 0)
515 printk(KERN_DEBUG
"DSI IRQ: 0x%x: ", status
);
518 if (status & DSI_IRQ_##x) \
544 static void print_irq_status_vc(int channel
, u32 status
)
550 if ((status
& ~DSI_VC_IRQ_PACKET_SENT
) == 0)
553 printk(KERN_DEBUG
"DSI VC(%d) IRQ 0x%x: ", channel
, status
);
556 if (status & DSI_VC_IRQ_##x) \
573 static void print_irq_status_cio(u32 status
)
578 printk(KERN_DEBUG
"DSI CIO IRQ 0x%x: ", status
);
581 if (status & DSI_CIO_IRQ_##x) \
595 PIS(ERRCONTENTIONLP0_1
);
596 PIS(ERRCONTENTIONLP1_1
);
597 PIS(ERRCONTENTIONLP0_2
);
598 PIS(ERRCONTENTIONLP1_2
);
599 PIS(ERRCONTENTIONLP0_3
);
600 PIS(ERRCONTENTIONLP1_3
);
601 PIS(ULPSACTIVENOT_ALL0
);
602 PIS(ULPSACTIVENOT_ALL1
);
608 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
609 static void dsi_collect_irq_stats(struct platform_device
*dsidev
, u32 irqstatus
,
610 u32
*vcstatus
, u32 ciostatus
)
612 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
615 spin_lock(&dsi
->irq_stats_lock
);
617 dsi
->irq_stats
.irq_count
++;
618 dss_collect_irq_stats(irqstatus
, dsi
->irq_stats
.dsi_irqs
);
620 for (i
= 0; i
< 4; ++i
)
621 dss_collect_irq_stats(vcstatus
[i
], dsi
->irq_stats
.vc_irqs
[i
]);
623 dss_collect_irq_stats(ciostatus
, dsi
->irq_stats
.cio_irqs
);
625 spin_unlock(&dsi
->irq_stats_lock
);
628 #define dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus)
631 static int debug_irq
;
633 static void dsi_handle_irq_errors(struct platform_device
*dsidev
, u32 irqstatus
,
634 u32
*vcstatus
, u32 ciostatus
)
636 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
639 if (irqstatus
& DSI_IRQ_ERROR_MASK
) {
640 DSSERR("DSI error, irqstatus %x\n", irqstatus
);
641 print_irq_status(irqstatus
);
642 spin_lock(&dsi
->errors_lock
);
643 dsi
->errors
|= irqstatus
& DSI_IRQ_ERROR_MASK
;
644 spin_unlock(&dsi
->errors_lock
);
645 } else if (debug_irq
) {
646 print_irq_status(irqstatus
);
649 for (i
= 0; i
< 4; ++i
) {
650 if (vcstatus
[i
] & DSI_VC_IRQ_ERROR_MASK
) {
651 DSSERR("DSI VC(%d) error, vc irqstatus %x\n",
653 print_irq_status_vc(i
, vcstatus
[i
]);
654 } else if (debug_irq
) {
655 print_irq_status_vc(i
, vcstatus
[i
]);
659 if (ciostatus
& DSI_CIO_IRQ_ERROR_MASK
) {
660 DSSERR("DSI CIO error, cio irqstatus %x\n", ciostatus
);
661 print_irq_status_cio(ciostatus
);
662 } else if (debug_irq
) {
663 print_irq_status_cio(ciostatus
);
667 static void dsi_call_isrs(struct dsi_isr_data
*isr_array
,
668 unsigned isr_array_size
, u32 irqstatus
)
670 struct dsi_isr_data
*isr_data
;
673 for (i
= 0; i
< isr_array_size
; i
++) {
674 isr_data
= &isr_array
[i
];
675 if (isr_data
->isr
&& isr_data
->mask
& irqstatus
)
676 isr_data
->isr(isr_data
->arg
, irqstatus
);
680 static void dsi_handle_isrs(struct dsi_isr_tables
*isr_tables
,
681 u32 irqstatus
, u32
*vcstatus
, u32 ciostatus
)
685 dsi_call_isrs(isr_tables
->isr_table
,
686 ARRAY_SIZE(isr_tables
->isr_table
),
689 for (i
= 0; i
< 4; ++i
) {
690 if (vcstatus
[i
] == 0)
692 dsi_call_isrs(isr_tables
->isr_table_vc
[i
],
693 ARRAY_SIZE(isr_tables
->isr_table_vc
[i
]),
698 dsi_call_isrs(isr_tables
->isr_table_cio
,
699 ARRAY_SIZE(isr_tables
->isr_table_cio
),
703 static irqreturn_t
omap_dsi_irq_handler(int irq
, void *arg
)
705 struct platform_device
*dsidev
;
706 struct dsi_data
*dsi
;
707 u32 irqstatus
, vcstatus
[4], ciostatus
;
710 dsidev
= (struct platform_device
*) arg
;
711 dsi
= dsi_get_dsidrv_data(dsidev
);
713 spin_lock(&dsi
->irq_lock
);
715 irqstatus
= dsi_read_reg(dsidev
, DSI_IRQSTATUS
);
717 /* IRQ is not for us */
719 spin_unlock(&dsi
->irq_lock
);
723 dsi_write_reg(dsidev
, DSI_IRQSTATUS
, irqstatus
& ~DSI_IRQ_CHANNEL_MASK
);
724 /* flush posted write */
725 dsi_read_reg(dsidev
, DSI_IRQSTATUS
);
727 for (i
= 0; i
< 4; ++i
) {
728 if ((irqstatus
& (1 << i
)) == 0) {
733 vcstatus
[i
] = dsi_read_reg(dsidev
, DSI_VC_IRQSTATUS(i
));
735 dsi_write_reg(dsidev
, DSI_VC_IRQSTATUS(i
), vcstatus
[i
]);
736 /* flush posted write */
737 dsi_read_reg(dsidev
, DSI_VC_IRQSTATUS(i
));
740 if (irqstatus
& DSI_IRQ_COMPLEXIO_ERR
) {
741 ciostatus
= dsi_read_reg(dsidev
, DSI_COMPLEXIO_IRQ_STATUS
);
743 dsi_write_reg(dsidev
, DSI_COMPLEXIO_IRQ_STATUS
, ciostatus
);
744 /* flush posted write */
745 dsi_read_reg(dsidev
, DSI_COMPLEXIO_IRQ_STATUS
);
750 #ifdef DSI_CATCH_MISSING_TE
751 if (irqstatus
& DSI_IRQ_TE_TRIGGER
)
752 del_timer(&dsi
->te_timer
);
755 /* make a copy and unlock, so that isrs can unregister
757 memcpy(&dsi
->isr_tables_copy
, &dsi
->isr_tables
,
758 sizeof(dsi
->isr_tables
));
760 spin_unlock(&dsi
->irq_lock
);
762 dsi_handle_isrs(&dsi
->isr_tables_copy
, irqstatus
, vcstatus
, ciostatus
);
764 dsi_handle_irq_errors(dsidev
, irqstatus
, vcstatus
, ciostatus
);
766 dsi_collect_irq_stats(dsidev
, irqstatus
, vcstatus
, ciostatus
);
771 /* dsi->irq_lock has to be locked by the caller */
772 static void _omap_dsi_configure_irqs(struct platform_device
*dsidev
,
773 struct dsi_isr_data
*isr_array
,
774 unsigned isr_array_size
, u32 default_mask
,
775 const struct dsi_reg enable_reg
,
776 const struct dsi_reg status_reg
)
778 struct dsi_isr_data
*isr_data
;
785 for (i
= 0; i
< isr_array_size
; i
++) {
786 isr_data
= &isr_array
[i
];
788 if (isr_data
->isr
== NULL
)
791 mask
|= isr_data
->mask
;
794 old_mask
= dsi_read_reg(dsidev
, enable_reg
);
795 /* clear the irqstatus for newly enabled irqs */
796 dsi_write_reg(dsidev
, status_reg
, (mask
^ old_mask
) & mask
);
797 dsi_write_reg(dsidev
, enable_reg
, mask
);
799 /* flush posted writes */
800 dsi_read_reg(dsidev
, enable_reg
);
801 dsi_read_reg(dsidev
, status_reg
);
804 /* dsi->irq_lock has to be locked by the caller */
805 static void _omap_dsi_set_irqs(struct platform_device
*dsidev
)
807 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
808 u32 mask
= DSI_IRQ_ERROR_MASK
;
809 #ifdef DSI_CATCH_MISSING_TE
810 mask
|= DSI_IRQ_TE_TRIGGER
;
812 _omap_dsi_configure_irqs(dsidev
, dsi
->isr_tables
.isr_table
,
813 ARRAY_SIZE(dsi
->isr_tables
.isr_table
), mask
,
814 DSI_IRQENABLE
, DSI_IRQSTATUS
);
817 /* dsi->irq_lock has to be locked by the caller */
818 static void _omap_dsi_set_irqs_vc(struct platform_device
*dsidev
, int vc
)
820 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
822 _omap_dsi_configure_irqs(dsidev
, dsi
->isr_tables
.isr_table_vc
[vc
],
823 ARRAY_SIZE(dsi
->isr_tables
.isr_table_vc
[vc
]),
824 DSI_VC_IRQ_ERROR_MASK
,
825 DSI_VC_IRQENABLE(vc
), DSI_VC_IRQSTATUS(vc
));
828 /* dsi->irq_lock has to be locked by the caller */
829 static void _omap_dsi_set_irqs_cio(struct platform_device
*dsidev
)
831 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
833 _omap_dsi_configure_irqs(dsidev
, dsi
->isr_tables
.isr_table_cio
,
834 ARRAY_SIZE(dsi
->isr_tables
.isr_table_cio
),
835 DSI_CIO_IRQ_ERROR_MASK
,
836 DSI_COMPLEXIO_IRQ_ENABLE
, DSI_COMPLEXIO_IRQ_STATUS
);
839 static void _dsi_initialize_irq(struct platform_device
*dsidev
)
841 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
845 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
847 memset(&dsi
->isr_tables
, 0, sizeof(dsi
->isr_tables
));
849 _omap_dsi_set_irqs(dsidev
);
850 for (vc
= 0; vc
< 4; ++vc
)
851 _omap_dsi_set_irqs_vc(dsidev
, vc
);
852 _omap_dsi_set_irqs_cio(dsidev
);
854 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
857 static int _dsi_register_isr(omap_dsi_isr_t isr
, void *arg
, u32 mask
,
858 struct dsi_isr_data
*isr_array
, unsigned isr_array_size
)
860 struct dsi_isr_data
*isr_data
;
866 /* check for duplicate entry and find a free slot */
868 for (i
= 0; i
< isr_array_size
; i
++) {
869 isr_data
= &isr_array
[i
];
871 if (isr_data
->isr
== isr
&& isr_data
->arg
== arg
&&
872 isr_data
->mask
== mask
) {
876 if (isr_data
->isr
== NULL
&& free_idx
== -1)
883 isr_data
= &isr_array
[free_idx
];
886 isr_data
->mask
= mask
;
891 static int _dsi_unregister_isr(omap_dsi_isr_t isr
, void *arg
, u32 mask
,
892 struct dsi_isr_data
*isr_array
, unsigned isr_array_size
)
894 struct dsi_isr_data
*isr_data
;
897 for (i
= 0; i
< isr_array_size
; i
++) {
898 isr_data
= &isr_array
[i
];
899 if (isr_data
->isr
!= isr
|| isr_data
->arg
!= arg
||
900 isr_data
->mask
!= mask
)
903 isr_data
->isr
= NULL
;
904 isr_data
->arg
= NULL
;
913 static int dsi_register_isr(struct platform_device
*dsidev
, omap_dsi_isr_t isr
,
916 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
920 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
922 r
= _dsi_register_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table
,
923 ARRAY_SIZE(dsi
->isr_tables
.isr_table
));
926 _omap_dsi_set_irqs(dsidev
);
928 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
933 static int dsi_unregister_isr(struct platform_device
*dsidev
,
934 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
936 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
940 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
942 r
= _dsi_unregister_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table
,
943 ARRAY_SIZE(dsi
->isr_tables
.isr_table
));
946 _omap_dsi_set_irqs(dsidev
);
948 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
953 static int dsi_register_isr_vc(struct platform_device
*dsidev
, int channel
,
954 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
956 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
960 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
962 r
= _dsi_register_isr(isr
, arg
, mask
,
963 dsi
->isr_tables
.isr_table_vc
[channel
],
964 ARRAY_SIZE(dsi
->isr_tables
.isr_table_vc
[channel
]));
967 _omap_dsi_set_irqs_vc(dsidev
, channel
);
969 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
974 static int dsi_unregister_isr_vc(struct platform_device
*dsidev
, int channel
,
975 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
977 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
981 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
983 r
= _dsi_unregister_isr(isr
, arg
, mask
,
984 dsi
->isr_tables
.isr_table_vc
[channel
],
985 ARRAY_SIZE(dsi
->isr_tables
.isr_table_vc
[channel
]));
988 _omap_dsi_set_irqs_vc(dsidev
, channel
);
990 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
995 static int dsi_register_isr_cio(struct platform_device
*dsidev
,
996 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
998 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1002 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
1004 r
= _dsi_register_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table_cio
,
1005 ARRAY_SIZE(dsi
->isr_tables
.isr_table_cio
));
1008 _omap_dsi_set_irqs_cio(dsidev
);
1010 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
1015 static int dsi_unregister_isr_cio(struct platform_device
*dsidev
,
1016 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
1018 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1019 unsigned long flags
;
1022 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
1024 r
= _dsi_unregister_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table_cio
,
1025 ARRAY_SIZE(dsi
->isr_tables
.isr_table_cio
));
1028 _omap_dsi_set_irqs_cio(dsidev
);
1030 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
1035 static u32
dsi_get_errors(struct platform_device
*dsidev
)
1037 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1038 unsigned long flags
;
1040 spin_lock_irqsave(&dsi
->errors_lock
, flags
);
1043 spin_unlock_irqrestore(&dsi
->errors_lock
, flags
);
1047 int dsi_runtime_get(struct platform_device
*dsidev
)
1050 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1052 DSSDBG("dsi_runtime_get\n");
1054 r
= pm_runtime_get_sync(&dsi
->pdev
->dev
);
1056 return r
< 0 ? r
: 0;
1059 void dsi_runtime_put(struct platform_device
*dsidev
)
1061 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1064 DSSDBG("dsi_runtime_put\n");
1066 r
= pm_runtime_put(&dsi
->pdev
->dev
);
1070 /* source clock for DSI PLL. this could also be PCLKFREE */
1071 static inline void dsi_enable_pll_clock(struct platform_device
*dsidev
,
1074 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1077 clk_enable(dsi
->sys_clk
);
1079 clk_disable(dsi
->sys_clk
);
1081 if (enable
&& dsi
->pll_locked
) {
1082 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 1, 1) != 1)
1083 DSSERR("cannot lock PLL when enabling clocks\n");
1088 static void _dsi_print_reset_status(struct platform_device
*dsidev
)
1096 /* A dummy read using the SCP interface to any DSIPHY register is
1097 * required after DSIPHY reset to complete the reset of the DSI complex
1099 l
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
1101 printk(KERN_DEBUG
"DSI resets: ");
1103 l
= dsi_read_reg(dsidev
, DSI_PLL_STATUS
);
1104 printk("PLL (%d) ", FLD_GET(l
, 0, 0));
1106 l
= dsi_read_reg(dsidev
, DSI_COMPLEXIO_CFG1
);
1107 printk("CIO (%d) ", FLD_GET(l
, 29, 29));
1109 if (dss_has_feature(FEAT_DSI_REVERSE_TXCLKESC
)) {
1119 l
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
1120 printk("PHY (%x%x%x, %d, %d, %d)\n",
1126 FLD_GET(l
, 31, 31));
1129 #define _dsi_print_reset_status(x)
1132 static inline int dsi_if_enable(struct platform_device
*dsidev
, bool enable
)
1134 DSSDBG("dsi_if_enable(%d)\n", enable
);
1136 enable
= enable
? 1 : 0;
1137 REG_FLD_MOD(dsidev
, DSI_CTRL
, enable
, 0, 0); /* IF_EN */
1139 if (wait_for_bit_change(dsidev
, DSI_CTRL
, 0, enable
) != enable
) {
1140 DSSERR("Failed to set dsi_if_enable to %d\n", enable
);
1147 unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device
*dsidev
)
1149 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1151 return dsi
->current_cinfo
.dsi_pll_hsdiv_dispc_clk
;
1154 static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device
*dsidev
)
1156 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1158 return dsi
->current_cinfo
.dsi_pll_hsdiv_dsi_clk
;
1161 static unsigned long dsi_get_txbyteclkhs(struct platform_device
*dsidev
)
1163 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1165 return dsi
->current_cinfo
.clkin4ddr
/ 16;
1168 static unsigned long dsi_fclk_rate(struct platform_device
*dsidev
)
1171 int dsi_module
= dsi_get_dsidev_id(dsidev
);
1172 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1174 if (dss_get_dsi_clk_source(dsi_module
) == OMAP_DSS_CLK_SRC_FCK
) {
1175 /* DSI FCLK source is DSS_CLK_FCK */
1176 r
= clk_get_rate(dsi
->dss_clk
);
1178 /* DSI FCLK source is dsi_pll_hsdiv_dsi_clk */
1179 r
= dsi_get_pll_hsdiv_dsi_rate(dsidev
);
1185 static int dsi_set_lp_clk_divisor(struct omap_dss_device
*dssdev
)
1187 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
1188 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1189 unsigned long dsi_fclk
;
1190 unsigned lp_clk_div
;
1191 unsigned long lp_clk
;
1193 lp_clk_div
= dssdev
->clocks
.dsi
.lp_clk_div
;
1195 if (lp_clk_div
== 0 || lp_clk_div
> dsi
->lpdiv_max
)
1198 dsi_fclk
= dsi_fclk_rate(dsidev
);
1200 lp_clk
= dsi_fclk
/ 2 / lp_clk_div
;
1202 DSSDBG("LP_CLK_DIV %u, LP_CLK %lu\n", lp_clk_div
, lp_clk
);
1203 dsi
->current_cinfo
.lp_clk
= lp_clk
;
1204 dsi
->current_cinfo
.lp_clk_div
= lp_clk_div
;
1206 /* LP_CLK_DIVISOR */
1207 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, lp_clk_div
, 12, 0);
1209 /* LP_RX_SYNCHRO_ENABLE */
1210 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, dsi_fclk
> 30000000 ? 1 : 0, 21, 21);
1215 static void dsi_enable_scp_clk(struct platform_device
*dsidev
)
1217 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1219 if (dsi
->scp_clk_refcount
++ == 0)
1220 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 1, 14, 14); /* CIO_CLK_ICG */
1223 static void dsi_disable_scp_clk(struct platform_device
*dsidev
)
1225 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1227 WARN_ON(dsi
->scp_clk_refcount
== 0);
1228 if (--dsi
->scp_clk_refcount
== 0)
1229 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 0, 14, 14); /* CIO_CLK_ICG */
1232 enum dsi_pll_power_state
{
1233 DSI_PLL_POWER_OFF
= 0x0,
1234 DSI_PLL_POWER_ON_HSCLK
= 0x1,
1235 DSI_PLL_POWER_ON_ALL
= 0x2,
1236 DSI_PLL_POWER_ON_DIV
= 0x3,
1239 static int dsi_pll_power(struct platform_device
*dsidev
,
1240 enum dsi_pll_power_state state
)
1244 /* DSI-PLL power command 0x3 is not working */
1245 if (dss_has_feature(FEAT_DSI_PLL_PWR_BUG
) &&
1246 state
== DSI_PLL_POWER_ON_DIV
)
1247 state
= DSI_PLL_POWER_ON_ALL
;
1250 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, state
, 31, 30);
1252 /* PLL_PWR_STATUS */
1253 while (FLD_GET(dsi_read_reg(dsidev
, DSI_CLK_CTRL
), 29, 28) != state
) {
1255 DSSERR("Failed to set DSI PLL power mode to %d\n",
1265 /* calculate clock rates using dividers in cinfo */
1266 static int dsi_calc_clock_rates(struct omap_dss_device
*dssdev
,
1267 struct dsi_clock_info
*cinfo
)
1269 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
1270 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1272 if (cinfo
->regn
== 0 || cinfo
->regn
> dsi
->regn_max
)
1275 if (cinfo
->regm
== 0 || cinfo
->regm
> dsi
->regm_max
)
1278 if (cinfo
->regm_dispc
> dsi
->regm_dispc_max
)
1281 if (cinfo
->regm_dsi
> dsi
->regm_dsi_max
)
1284 if (cinfo
->use_sys_clk
) {
1285 cinfo
->clkin
= clk_get_rate(dsi
->sys_clk
);
1286 /* XXX it is unclear if highfreq should be used
1287 * with DSS_SYS_CLK source also */
1288 cinfo
->highfreq
= 0;
1290 cinfo
->clkin
= dispc_pclk_rate(dssdev
->manager
->id
);
1292 if (cinfo
->clkin
< 32000000)
1293 cinfo
->highfreq
= 0;
1295 cinfo
->highfreq
= 1;
1298 cinfo
->fint
= cinfo
->clkin
/ (cinfo
->regn
* (cinfo
->highfreq
? 2 : 1));
1300 if (cinfo
->fint
> dsi
->fint_max
|| cinfo
->fint
< dsi
->fint_min
)
1303 cinfo
->clkin4ddr
= 2 * cinfo
->regm
* cinfo
->fint
;
1305 if (cinfo
->clkin4ddr
> 1800 * 1000 * 1000)
1308 if (cinfo
->regm_dispc
> 0)
1309 cinfo
->dsi_pll_hsdiv_dispc_clk
=
1310 cinfo
->clkin4ddr
/ cinfo
->regm_dispc
;
1312 cinfo
->dsi_pll_hsdiv_dispc_clk
= 0;
1314 if (cinfo
->regm_dsi
> 0)
1315 cinfo
->dsi_pll_hsdiv_dsi_clk
=
1316 cinfo
->clkin4ddr
/ cinfo
->regm_dsi
;
1318 cinfo
->dsi_pll_hsdiv_dsi_clk
= 0;
1323 int dsi_pll_calc_clock_div_pck(struct platform_device
*dsidev
, bool is_tft
,
1324 unsigned long req_pck
, struct dsi_clock_info
*dsi_cinfo
,
1325 struct dispc_clock_info
*dispc_cinfo
)
1327 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1328 struct dsi_clock_info cur
, best
;
1329 struct dispc_clock_info best_dispc
;
1330 int min_fck_per_pck
;
1332 unsigned long dss_sys_clk
, max_dss_fck
;
1334 dss_sys_clk
= clk_get_rate(dsi
->sys_clk
);
1336 max_dss_fck
= dss_feat_get_param_max(FEAT_PARAM_DSS_FCK
);
1338 if (req_pck
== dsi
->cache_req_pck
&&
1339 dsi
->cache_cinfo
.clkin
== dss_sys_clk
) {
1340 DSSDBG("DSI clock info found from cache\n");
1341 *dsi_cinfo
= dsi
->cache_cinfo
;
1342 dispc_find_clk_divs(is_tft
, req_pck
,
1343 dsi_cinfo
->dsi_pll_hsdiv_dispc_clk
, dispc_cinfo
);
1347 min_fck_per_pck
= CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK
;
1349 if (min_fck_per_pck
&&
1350 req_pck
* min_fck_per_pck
> max_dss_fck
) {
1351 DSSERR("Requested pixel clock not possible with the current "
1352 "OMAP2_DSS_MIN_FCK_PER_PCK setting. Turning "
1353 "the constraint off.\n");
1354 min_fck_per_pck
= 0;
1357 DSSDBG("dsi_pll_calc\n");
1360 memset(&best
, 0, sizeof(best
));
1361 memset(&best_dispc
, 0, sizeof(best_dispc
));
1363 memset(&cur
, 0, sizeof(cur
));
1364 cur
.clkin
= dss_sys_clk
;
1365 cur
.use_sys_clk
= 1;
1368 /* no highfreq: 0.75MHz < Fint = clkin / regn < 2.1MHz */
1369 /* highfreq: 0.75MHz < Fint = clkin / (2*regn) < 2.1MHz */
1370 /* To reduce PLL lock time, keep Fint high (around 2 MHz) */
1371 for (cur
.regn
= 1; cur
.regn
< dsi
->regn_max
; ++cur
.regn
) {
1372 if (cur
.highfreq
== 0)
1373 cur
.fint
= cur
.clkin
/ cur
.regn
;
1375 cur
.fint
= cur
.clkin
/ (2 * cur
.regn
);
1377 if (cur
.fint
> dsi
->fint_max
|| cur
.fint
< dsi
->fint_min
)
1380 /* DSIPHY(MHz) = (2 * regm / regn) * (clkin / (highfreq + 1)) */
1381 for (cur
.regm
= 1; cur
.regm
< dsi
->regm_max
; ++cur
.regm
) {
1384 a
= 2 * cur
.regm
* (cur
.clkin
/1000);
1385 b
= cur
.regn
* (cur
.highfreq
+ 1);
1386 cur
.clkin4ddr
= a
/ b
* 1000;
1388 if (cur
.clkin4ddr
> 1800 * 1000 * 1000)
1391 /* dsi_pll_hsdiv_dispc_clk(MHz) =
1392 * DSIPHY(MHz) / regm_dispc < 173MHz/186Mhz */
1393 for (cur
.regm_dispc
= 1; cur
.regm_dispc
<
1394 dsi
->regm_dispc_max
; ++cur
.regm_dispc
) {
1395 struct dispc_clock_info cur_dispc
;
1396 cur
.dsi_pll_hsdiv_dispc_clk
=
1397 cur
.clkin4ddr
/ cur
.regm_dispc
;
1399 /* this will narrow down the search a bit,
1400 * but still give pixclocks below what was
1402 if (cur
.dsi_pll_hsdiv_dispc_clk
< req_pck
)
1405 if (cur
.dsi_pll_hsdiv_dispc_clk
> max_dss_fck
)
1408 if (min_fck_per_pck
&&
1409 cur
.dsi_pll_hsdiv_dispc_clk
<
1410 req_pck
* min_fck_per_pck
)
1415 dispc_find_clk_divs(is_tft
, req_pck
,
1416 cur
.dsi_pll_hsdiv_dispc_clk
,
1419 if (abs(cur_dispc
.pck
- req_pck
) <
1420 abs(best_dispc
.pck
- req_pck
)) {
1422 best_dispc
= cur_dispc
;
1424 if (cur_dispc
.pck
== req_pck
)
1432 if (min_fck_per_pck
) {
1433 DSSERR("Could not find suitable clock settings.\n"
1434 "Turning FCK/PCK constraint off and"
1436 min_fck_per_pck
= 0;
1440 DSSERR("Could not find suitable clock settings.\n");
1445 /* dsi_pll_hsdiv_dsi_clk (regm_dsi) is not used */
1447 best
.dsi_pll_hsdiv_dsi_clk
= 0;
1452 *dispc_cinfo
= best_dispc
;
1454 dsi
->cache_req_pck
= req_pck
;
1455 dsi
->cache_clk_freq
= 0;
1456 dsi
->cache_cinfo
= best
;
1461 int dsi_pll_set_clock_div(struct platform_device
*dsidev
,
1462 struct dsi_clock_info
*cinfo
)
1464 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1468 u8 regn_start
, regn_end
, regm_start
, regm_end
;
1469 u8 regm_dispc_start
, regm_dispc_end
, regm_dsi_start
, regm_dsi_end
;
1473 dsi
->current_cinfo
.use_sys_clk
= cinfo
->use_sys_clk
;
1474 dsi
->current_cinfo
.highfreq
= cinfo
->highfreq
;
1476 dsi
->current_cinfo
.fint
= cinfo
->fint
;
1477 dsi
->current_cinfo
.clkin4ddr
= cinfo
->clkin4ddr
;
1478 dsi
->current_cinfo
.dsi_pll_hsdiv_dispc_clk
=
1479 cinfo
->dsi_pll_hsdiv_dispc_clk
;
1480 dsi
->current_cinfo
.dsi_pll_hsdiv_dsi_clk
=
1481 cinfo
->dsi_pll_hsdiv_dsi_clk
;
1483 dsi
->current_cinfo
.regn
= cinfo
->regn
;
1484 dsi
->current_cinfo
.regm
= cinfo
->regm
;
1485 dsi
->current_cinfo
.regm_dispc
= cinfo
->regm_dispc
;
1486 dsi
->current_cinfo
.regm_dsi
= cinfo
->regm_dsi
;
1488 DSSDBG("DSI Fint %ld\n", cinfo
->fint
);
1490 DSSDBG("clkin (%s) rate %ld, highfreq %d\n",
1491 cinfo
->use_sys_clk
? "dss_sys_clk" : "pclkfree",
1495 /* DSIPHY == CLKIN4DDR */
1496 DSSDBG("CLKIN4DDR = 2 * %d / %d * %lu / %d = %lu\n",
1500 cinfo
->highfreq
+ 1,
1503 DSSDBG("Data rate on 1 DSI lane %ld Mbps\n",
1504 cinfo
->clkin4ddr
/ 1000 / 1000 / 2);
1506 DSSDBG("Clock lane freq %ld Hz\n", cinfo
->clkin4ddr
/ 4);
1508 DSSDBG("regm_dispc = %d, %s (%s) = %lu\n", cinfo
->regm_dispc
,
1509 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
),
1510 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
),
1511 cinfo
->dsi_pll_hsdiv_dispc_clk
);
1512 DSSDBG("regm_dsi = %d, %s (%s) = %lu\n", cinfo
->regm_dsi
,
1513 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
),
1514 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
),
1515 cinfo
->dsi_pll_hsdiv_dsi_clk
);
1517 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGN
, ®n_start
, ®n_end
);
1518 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM
, ®m_start
, ®m_end
);
1519 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DISPC
, ®m_dispc_start
,
1521 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DSI
, ®m_dsi_start
,
1524 /* DSI_PLL_AUTOMODE = manual */
1525 REG_FLD_MOD(dsidev
, DSI_PLL_CONTROL
, 0, 0, 0);
1527 l
= dsi_read_reg(dsidev
, DSI_PLL_CONFIGURATION1
);
1528 l
= FLD_MOD(l
, 1, 0, 0); /* DSI_PLL_STOPMODE */
1530 l
= FLD_MOD(l
, cinfo
->regn
- 1, regn_start
, regn_end
);
1532 l
= FLD_MOD(l
, cinfo
->regm
, regm_start
, regm_end
);
1534 l
= FLD_MOD(l
, cinfo
->regm_dispc
> 0 ? cinfo
->regm_dispc
- 1 : 0,
1535 regm_dispc_start
, regm_dispc_end
);
1536 /* DSIPROTO_CLOCK_DIV */
1537 l
= FLD_MOD(l
, cinfo
->regm_dsi
> 0 ? cinfo
->regm_dsi
- 1 : 0,
1538 regm_dsi_start
, regm_dsi_end
);
1539 dsi_write_reg(dsidev
, DSI_PLL_CONFIGURATION1
, l
);
1541 BUG_ON(cinfo
->fint
< dsi
->fint_min
|| cinfo
->fint
> dsi
->fint_max
);
1543 if (dss_has_feature(FEAT_DSI_PLL_FREQSEL
)) {
1544 f
= cinfo
->fint
< 1000000 ? 0x3 :
1545 cinfo
->fint
< 1250000 ? 0x4 :
1546 cinfo
->fint
< 1500000 ? 0x5 :
1547 cinfo
->fint
< 1750000 ? 0x6 :
1551 l
= dsi_read_reg(dsidev
, DSI_PLL_CONFIGURATION2
);
1553 if (dss_has_feature(FEAT_DSI_PLL_FREQSEL
))
1554 l
= FLD_MOD(l
, f
, 4, 1); /* DSI_PLL_FREQSEL */
1555 l
= FLD_MOD(l
, cinfo
->use_sys_clk
? 0 : 1,
1556 11, 11); /* DSI_PLL_CLKSEL */
1557 l
= FLD_MOD(l
, cinfo
->highfreq
,
1558 12, 12); /* DSI_PLL_HIGHFREQ */
1559 l
= FLD_MOD(l
, 1, 13, 13); /* DSI_PLL_REFEN */
1560 l
= FLD_MOD(l
, 0, 14, 14); /* DSIPHY_CLKINEN */
1561 l
= FLD_MOD(l
, 1, 20, 20); /* DSI_HSDIVBYPASS */
1562 dsi_write_reg(dsidev
, DSI_PLL_CONFIGURATION2
, l
);
1564 REG_FLD_MOD(dsidev
, DSI_PLL_GO
, 1, 0, 0); /* DSI_PLL_GO */
1566 if (wait_for_bit_change(dsidev
, DSI_PLL_GO
, 0, 0) != 0) {
1567 DSSERR("dsi pll go bit not going down.\n");
1572 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 1, 1) != 1) {
1573 DSSERR("cannot lock PLL\n");
1578 dsi
->pll_locked
= 1;
1580 l
= dsi_read_reg(dsidev
, DSI_PLL_CONFIGURATION2
);
1581 l
= FLD_MOD(l
, 0, 0, 0); /* DSI_PLL_IDLE */
1582 l
= FLD_MOD(l
, 0, 5, 5); /* DSI_PLL_PLLLPMODE */
1583 l
= FLD_MOD(l
, 0, 6, 6); /* DSI_PLL_LOWCURRSTBY */
1584 l
= FLD_MOD(l
, 0, 7, 7); /* DSI_PLL_TIGHTPHASELOCK */
1585 l
= FLD_MOD(l
, 0, 8, 8); /* DSI_PLL_DRIFTGUARDEN */
1586 l
= FLD_MOD(l
, 0, 10, 9); /* DSI_PLL_LOCKSEL */
1587 l
= FLD_MOD(l
, 1, 13, 13); /* DSI_PLL_REFEN */
1588 l
= FLD_MOD(l
, 1, 14, 14); /* DSIPHY_CLKINEN */
1589 l
= FLD_MOD(l
, 0, 15, 15); /* DSI_BYPASSEN */
1590 l
= FLD_MOD(l
, 1, 16, 16); /* DSS_CLOCK_EN */
1591 l
= FLD_MOD(l
, 0, 17, 17); /* DSS_CLOCK_PWDN */
1592 l
= FLD_MOD(l
, 1, 18, 18); /* DSI_PROTO_CLOCK_EN */
1593 l
= FLD_MOD(l
, 0, 19, 19); /* DSI_PROTO_CLOCK_PWDN */
1594 l
= FLD_MOD(l
, 0, 20, 20); /* DSI_HSDIVBYPASS */
1595 dsi_write_reg(dsidev
, DSI_PLL_CONFIGURATION2
, l
);
1597 DSSDBG("PLL config done\n");
1602 int dsi_pll_init(struct platform_device
*dsidev
, bool enable_hsclk
,
1605 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1607 enum dsi_pll_power_state pwstate
;
1609 DSSDBG("PLL init\n");
1611 if (dsi
->vdds_dsi_reg
== NULL
) {
1612 struct regulator
*vdds_dsi
;
1614 vdds_dsi
= regulator_get(&dsi
->pdev
->dev
, "vdds_dsi");
1616 if (IS_ERR(vdds_dsi
)) {
1617 DSSERR("can't get VDDS_DSI regulator\n");
1618 return PTR_ERR(vdds_dsi
);
1621 dsi
->vdds_dsi_reg
= vdds_dsi
;
1624 dsi_enable_pll_clock(dsidev
, 1);
1626 * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4.
1628 dsi_enable_scp_clk(dsidev
);
1630 if (!dsi
->vdds_dsi_enabled
) {
1631 r
= regulator_enable(dsi
->vdds_dsi_reg
);
1634 dsi
->vdds_dsi_enabled
= true;
1637 /* XXX PLL does not come out of reset without this... */
1638 dispc_pck_free_enable(1);
1640 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 0, 1) != 1) {
1641 DSSERR("PLL not coming out of reset.\n");
1643 dispc_pck_free_enable(0);
1647 /* XXX ... but if left on, we get problems when planes do not
1648 * fill the whole display. No idea about this */
1649 dispc_pck_free_enable(0);
1651 if (enable_hsclk
&& enable_hsdiv
)
1652 pwstate
= DSI_PLL_POWER_ON_ALL
;
1653 else if (enable_hsclk
)
1654 pwstate
= DSI_PLL_POWER_ON_HSCLK
;
1655 else if (enable_hsdiv
)
1656 pwstate
= DSI_PLL_POWER_ON_DIV
;
1658 pwstate
= DSI_PLL_POWER_OFF
;
1660 r
= dsi_pll_power(dsidev
, pwstate
);
1665 DSSDBG("PLL init done\n");
1669 if (dsi
->vdds_dsi_enabled
) {
1670 regulator_disable(dsi
->vdds_dsi_reg
);
1671 dsi
->vdds_dsi_enabled
= false;
1674 dsi_disable_scp_clk(dsidev
);
1675 dsi_enable_pll_clock(dsidev
, 0);
1679 void dsi_pll_uninit(struct platform_device
*dsidev
, bool disconnect_lanes
)
1681 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1683 dsi
->pll_locked
= 0;
1684 dsi_pll_power(dsidev
, DSI_PLL_POWER_OFF
);
1685 if (disconnect_lanes
) {
1686 WARN_ON(!dsi
->vdds_dsi_enabled
);
1687 regulator_disable(dsi
->vdds_dsi_reg
);
1688 dsi
->vdds_dsi_enabled
= false;
1691 dsi_disable_scp_clk(dsidev
);
1692 dsi_enable_pll_clock(dsidev
, 0);
1694 DSSDBG("PLL uninit done\n");
1697 static void dsi_dump_dsidev_clocks(struct platform_device
*dsidev
,
1700 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1701 struct dsi_clock_info
*cinfo
= &dsi
->current_cinfo
;
1702 enum omap_dss_clk_source dispc_clk_src
, dsi_clk_src
;
1703 int dsi_module
= dsi_get_dsidev_id(dsidev
);
1705 dispc_clk_src
= dss_get_dispc_clk_source();
1706 dsi_clk_src
= dss_get_dsi_clk_source(dsi_module
);
1708 if (dsi_runtime_get(dsidev
))
1711 seq_printf(s
, "- DSI%d PLL -\n", dsi_module
+ 1);
1713 seq_printf(s
, "dsi pll source = %s\n",
1714 cinfo
->use_sys_clk
? "dss_sys_clk" : "pclkfree");
1716 seq_printf(s
, "Fint\t\t%-16luregn %u\n", cinfo
->fint
, cinfo
->regn
);
1718 seq_printf(s
, "CLKIN4DDR\t%-16luregm %u\n",
1719 cinfo
->clkin4ddr
, cinfo
->regm
);
1721 seq_printf(s
, "%s (%s)\t%-16luregm_dispc %u\t(%s)\n",
1722 dss_get_generic_clk_source_name(dispc_clk_src
),
1723 dss_feat_get_clk_source_name(dispc_clk_src
),
1724 cinfo
->dsi_pll_hsdiv_dispc_clk
,
1726 dispc_clk_src
== OMAP_DSS_CLK_SRC_FCK
?
1729 seq_printf(s
, "%s (%s)\t%-16luregm_dsi %u\t(%s)\n",
1730 dss_get_generic_clk_source_name(dsi_clk_src
),
1731 dss_feat_get_clk_source_name(dsi_clk_src
),
1732 cinfo
->dsi_pll_hsdiv_dsi_clk
,
1734 dsi_clk_src
== OMAP_DSS_CLK_SRC_FCK
?
1737 seq_printf(s
, "- DSI%d -\n", dsi_module
+ 1);
1739 seq_printf(s
, "dsi fclk source = %s (%s)\n",
1740 dss_get_generic_clk_source_name(dsi_clk_src
),
1741 dss_feat_get_clk_source_name(dsi_clk_src
));
1743 seq_printf(s
, "DSI_FCLK\t%lu\n", dsi_fclk_rate(dsidev
));
1745 seq_printf(s
, "DDR_CLK\t\t%lu\n",
1746 cinfo
->clkin4ddr
/ 4);
1748 seq_printf(s
, "TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsidev
));
1750 seq_printf(s
, "LP_CLK\t\t%lu\n", cinfo
->lp_clk
);
1752 dsi_runtime_put(dsidev
);
1755 void dsi_dump_clocks(struct seq_file
*s
)
1757 struct platform_device
*dsidev
;
1760 for (i
= 0; i
< MAX_NUM_DSI
; i
++) {
1761 dsidev
= dsi_get_dsidev_from_id(i
);
1763 dsi_dump_dsidev_clocks(dsidev
, s
);
1767 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
1768 static void dsi_dump_dsidev_irqs(struct platform_device
*dsidev
,
1771 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1772 unsigned long flags
;
1773 struct dsi_irq_stats stats
;
1774 int dsi_module
= dsi_get_dsidev_id(dsidev
);
1776 spin_lock_irqsave(&dsi
->irq_stats_lock
, flags
);
1778 stats
= dsi
->irq_stats
;
1779 memset(&dsi
->irq_stats
, 0, sizeof(dsi
->irq_stats
));
1780 dsi
->irq_stats
.last_reset
= jiffies
;
1782 spin_unlock_irqrestore(&dsi
->irq_stats_lock
, flags
);
1784 seq_printf(s
, "period %u ms\n",
1785 jiffies_to_msecs(jiffies
- stats
.last_reset
));
1787 seq_printf(s
, "irqs %d\n", stats
.irq_count
);
1789 seq_printf(s, "%-20s %10d\n", #x, stats.dsi_irqs[ffs(DSI_IRQ_##x)-1]);
1791 seq_printf(s
, "-- DSI%d interrupts --\n", dsi_module
+ 1);
1807 PIS(LDO_POWER_GOOD
);
1812 seq_printf(s, "%-20s %10d %10d %10d %10d\n", #x, \
1813 stats.vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \
1814 stats.vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \
1815 stats.vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \
1816 stats.vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]);
1818 seq_printf(s
, "-- VC interrupts --\n");
1827 PIS(PP_BUSY_CHANGE
);
1831 seq_printf(s, "%-20s %10d\n", #x, \
1832 stats.cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]);
1834 seq_printf(s
, "-- CIO interrupts --\n");
1847 PIS(ERRCONTENTIONLP0_1
);
1848 PIS(ERRCONTENTIONLP1_1
);
1849 PIS(ERRCONTENTIONLP0_2
);
1850 PIS(ERRCONTENTIONLP1_2
);
1851 PIS(ERRCONTENTIONLP0_3
);
1852 PIS(ERRCONTENTIONLP1_3
);
1853 PIS(ULPSACTIVENOT_ALL0
);
1854 PIS(ULPSACTIVENOT_ALL1
);
1858 static void dsi1_dump_irqs(struct seq_file
*s
)
1860 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(0);
1862 dsi_dump_dsidev_irqs(dsidev
, s
);
1865 static void dsi2_dump_irqs(struct seq_file
*s
)
1867 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(1);
1869 dsi_dump_dsidev_irqs(dsidev
, s
);
1872 void dsi_create_debugfs_files_irq(struct dentry
*debugfs_dir
,
1873 const struct file_operations
*debug_fops
)
1875 struct platform_device
*dsidev
;
1877 dsidev
= dsi_get_dsidev_from_id(0);
1879 debugfs_create_file("dsi1_irqs", S_IRUGO
, debugfs_dir
,
1880 &dsi1_dump_irqs
, debug_fops
);
1882 dsidev
= dsi_get_dsidev_from_id(1);
1884 debugfs_create_file("dsi2_irqs", S_IRUGO
, debugfs_dir
,
1885 &dsi2_dump_irqs
, debug_fops
);
1889 static void dsi_dump_dsidev_regs(struct platform_device
*dsidev
,
1892 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsidev, r))
1894 if (dsi_runtime_get(dsidev
))
1896 dsi_enable_scp_clk(dsidev
);
1898 DUMPREG(DSI_REVISION
);
1899 DUMPREG(DSI_SYSCONFIG
);
1900 DUMPREG(DSI_SYSSTATUS
);
1901 DUMPREG(DSI_IRQSTATUS
);
1902 DUMPREG(DSI_IRQENABLE
);
1904 DUMPREG(DSI_COMPLEXIO_CFG1
);
1905 DUMPREG(DSI_COMPLEXIO_IRQ_STATUS
);
1906 DUMPREG(DSI_COMPLEXIO_IRQ_ENABLE
);
1907 DUMPREG(DSI_CLK_CTRL
);
1908 DUMPREG(DSI_TIMING1
);
1909 DUMPREG(DSI_TIMING2
);
1910 DUMPREG(DSI_VM_TIMING1
);
1911 DUMPREG(DSI_VM_TIMING2
);
1912 DUMPREG(DSI_VM_TIMING3
);
1913 DUMPREG(DSI_CLK_TIMING
);
1914 DUMPREG(DSI_TX_FIFO_VC_SIZE
);
1915 DUMPREG(DSI_RX_FIFO_VC_SIZE
);
1916 DUMPREG(DSI_COMPLEXIO_CFG2
);
1917 DUMPREG(DSI_RX_FIFO_VC_FULLNESS
);
1918 DUMPREG(DSI_VM_TIMING4
);
1919 DUMPREG(DSI_TX_FIFO_VC_EMPTINESS
);
1920 DUMPREG(DSI_VM_TIMING5
);
1921 DUMPREG(DSI_VM_TIMING6
);
1922 DUMPREG(DSI_VM_TIMING7
);
1923 DUMPREG(DSI_STOPCLK_TIMING
);
1925 DUMPREG(DSI_VC_CTRL(0));
1926 DUMPREG(DSI_VC_TE(0));
1927 DUMPREG(DSI_VC_LONG_PACKET_HEADER(0));
1928 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(0));
1929 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(0));
1930 DUMPREG(DSI_VC_IRQSTATUS(0));
1931 DUMPREG(DSI_VC_IRQENABLE(0));
1933 DUMPREG(DSI_VC_CTRL(1));
1934 DUMPREG(DSI_VC_TE(1));
1935 DUMPREG(DSI_VC_LONG_PACKET_HEADER(1));
1936 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(1));
1937 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(1));
1938 DUMPREG(DSI_VC_IRQSTATUS(1));
1939 DUMPREG(DSI_VC_IRQENABLE(1));
1941 DUMPREG(DSI_VC_CTRL(2));
1942 DUMPREG(DSI_VC_TE(2));
1943 DUMPREG(DSI_VC_LONG_PACKET_HEADER(2));
1944 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(2));
1945 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(2));
1946 DUMPREG(DSI_VC_IRQSTATUS(2));
1947 DUMPREG(DSI_VC_IRQENABLE(2));
1949 DUMPREG(DSI_VC_CTRL(3));
1950 DUMPREG(DSI_VC_TE(3));
1951 DUMPREG(DSI_VC_LONG_PACKET_HEADER(3));
1952 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(3));
1953 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(3));
1954 DUMPREG(DSI_VC_IRQSTATUS(3));
1955 DUMPREG(DSI_VC_IRQENABLE(3));
1957 DUMPREG(DSI_DSIPHY_CFG0
);
1958 DUMPREG(DSI_DSIPHY_CFG1
);
1959 DUMPREG(DSI_DSIPHY_CFG2
);
1960 DUMPREG(DSI_DSIPHY_CFG5
);
1962 DUMPREG(DSI_PLL_CONTROL
);
1963 DUMPREG(DSI_PLL_STATUS
);
1964 DUMPREG(DSI_PLL_GO
);
1965 DUMPREG(DSI_PLL_CONFIGURATION1
);
1966 DUMPREG(DSI_PLL_CONFIGURATION2
);
1968 dsi_disable_scp_clk(dsidev
);
1969 dsi_runtime_put(dsidev
);
1973 static void dsi1_dump_regs(struct seq_file
*s
)
1975 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(0);
1977 dsi_dump_dsidev_regs(dsidev
, s
);
1980 static void dsi2_dump_regs(struct seq_file
*s
)
1982 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(1);
1984 dsi_dump_dsidev_regs(dsidev
, s
);
1987 void dsi_create_debugfs_files_reg(struct dentry
*debugfs_dir
,
1988 const struct file_operations
*debug_fops
)
1990 struct platform_device
*dsidev
;
1992 dsidev
= dsi_get_dsidev_from_id(0);
1994 debugfs_create_file("dsi1_regs", S_IRUGO
, debugfs_dir
,
1995 &dsi1_dump_regs
, debug_fops
);
1997 dsidev
= dsi_get_dsidev_from_id(1);
1999 debugfs_create_file("dsi2_regs", S_IRUGO
, debugfs_dir
,
2000 &dsi2_dump_regs
, debug_fops
);
2002 enum dsi_cio_power_state
{
2003 DSI_COMPLEXIO_POWER_OFF
= 0x0,
2004 DSI_COMPLEXIO_POWER_ON
= 0x1,
2005 DSI_COMPLEXIO_POWER_ULPS
= 0x2,
2008 static int dsi_cio_power(struct platform_device
*dsidev
,
2009 enum dsi_cio_power_state state
)
2014 REG_FLD_MOD(dsidev
, DSI_COMPLEXIO_CFG1
, state
, 28, 27);
2017 while (FLD_GET(dsi_read_reg(dsidev
, DSI_COMPLEXIO_CFG1
),
2020 DSSERR("failed to set complexio power state to "
2030 /* Number of data lanes present on DSI interface */
2031 static inline int dsi_get_num_data_lanes(struct platform_device
*dsidev
)
2033 /* DSI on OMAP3 doesn't have register DSI_GNQ, set number
2034 * of data lanes as 2 by default */
2035 if (dss_has_feature(FEAT_DSI_GNQ
))
2036 return REG_GET(dsidev
, DSI_GNQ
, 11, 9); /* NB_DATA_LANES */
2041 /* Number of data lanes used by the dss device */
2042 static inline int dsi_get_num_data_lanes_dssdev(struct omap_dss_device
*dssdev
)
2044 int num_data_lanes
= 0;
2046 if (dssdev
->phy
.dsi
.data1_lane
!= 0)
2048 if (dssdev
->phy
.dsi
.data2_lane
!= 0)
2050 if (dssdev
->phy
.dsi
.data3_lane
!= 0)
2052 if (dssdev
->phy
.dsi
.data4_lane
!= 0)
2055 return num_data_lanes
;
2058 static unsigned dsi_get_line_buf_size(struct platform_device
*dsidev
)
2062 /* line buffer on OMAP3 is 1024 x 24bits */
2063 /* XXX: for some reason using full buffer size causes
2064 * considerable TX slowdown with update sizes that fill the
2066 if (!dss_has_feature(FEAT_DSI_GNQ
))
2069 val
= REG_GET(dsidev
, DSI_GNQ
, 14, 12); /* VP1_LINE_BUFFER_SIZE */
2073 return 512 * 3; /* 512x24 bits */
2075 return 682 * 3; /* 682x24 bits */
2077 return 853 * 3; /* 853x24 bits */
2079 return 1024 * 3; /* 1024x24 bits */
2081 return 1194 * 3; /* 1194x24 bits */
2083 return 1365 * 3; /* 1365x24 bits */
2089 static void dsi_set_lane_config(struct omap_dss_device
*dssdev
)
2091 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2093 int num_data_lanes_dssdev
= dsi_get_num_data_lanes_dssdev(dssdev
);
2095 int clk_lane
= dssdev
->phy
.dsi
.clk_lane
;
2096 int data1_lane
= dssdev
->phy
.dsi
.data1_lane
;
2097 int data2_lane
= dssdev
->phy
.dsi
.data2_lane
;
2098 int clk_pol
= dssdev
->phy
.dsi
.clk_pol
;
2099 int data1_pol
= dssdev
->phy
.dsi
.data1_pol
;
2100 int data2_pol
= dssdev
->phy
.dsi
.data2_pol
;
2102 r
= dsi_read_reg(dsidev
, DSI_COMPLEXIO_CFG1
);
2103 r
= FLD_MOD(r
, clk_lane
, 2, 0);
2104 r
= FLD_MOD(r
, clk_pol
, 3, 3);
2105 r
= FLD_MOD(r
, data1_lane
, 6, 4);
2106 r
= FLD_MOD(r
, data1_pol
, 7, 7);
2107 r
= FLD_MOD(r
, data2_lane
, 10, 8);
2108 r
= FLD_MOD(r
, data2_pol
, 11, 11);
2109 if (num_data_lanes_dssdev
> 2) {
2110 int data3_lane
= dssdev
->phy
.dsi
.data3_lane
;
2111 int data3_pol
= dssdev
->phy
.dsi
.data3_pol
;
2113 r
= FLD_MOD(r
, data3_lane
, 14, 12);
2114 r
= FLD_MOD(r
, data3_pol
, 15, 15);
2116 if (num_data_lanes_dssdev
> 3) {
2117 int data4_lane
= dssdev
->phy
.dsi
.data4_lane
;
2118 int data4_pol
= dssdev
->phy
.dsi
.data4_pol
;
2120 r
= FLD_MOD(r
, data4_lane
, 18, 16);
2121 r
= FLD_MOD(r
, data4_pol
, 19, 19);
2123 dsi_write_reg(dsidev
, DSI_COMPLEXIO_CFG1
, r
);
2125 /* The configuration of the DSI complex I/O (number of data lanes,
2126 position, differential order) should not be changed while
2127 DSS.DSI_CLK_CRTRL[20] LP_CLK_ENABLE bit is set to 1. In order for
2128 the hardware to take into account a new configuration of the complex
2129 I/O (done in DSS.DSI_COMPLEXIO_CFG1 register), it is recommended to
2130 follow this sequence: First set the DSS.DSI_CTRL[0] IF_EN bit to 1,
2131 then reset the DSS.DSI_CTRL[0] IF_EN to 0, then set
2132 DSS.DSI_CLK_CTRL[20] LP_CLK_ENABLE to 1 and finally set again the
2133 DSS.DSI_CTRL[0] IF_EN bit to 1. If the sequence is not followed, the
2134 DSI complex I/O configuration is unknown. */
2137 REG_FLD_MOD(dsidev, DSI_CTRL, 1, 0, 0);
2138 REG_FLD_MOD(dsidev, DSI_CTRL, 0, 0, 0);
2139 REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 20, 20);
2140 REG_FLD_MOD(dsidev, DSI_CTRL, 1, 0, 0);
2144 static inline unsigned ns2ddr(struct platform_device
*dsidev
, unsigned ns
)
2146 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2148 /* convert time in ns to ddr ticks, rounding up */
2149 unsigned long ddr_clk
= dsi
->current_cinfo
.clkin4ddr
/ 4;
2150 return (ns
* (ddr_clk
/ 1000 / 1000) + 999) / 1000;
2153 static inline unsigned ddr2ns(struct platform_device
*dsidev
, unsigned ddr
)
2155 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2157 unsigned long ddr_clk
= dsi
->current_cinfo
.clkin4ddr
/ 4;
2158 return ddr
* 1000 * 1000 / (ddr_clk
/ 1000);
2161 static void dsi_cio_timings(struct platform_device
*dsidev
)
2164 u32 ths_prepare
, ths_prepare_ths_zero
, ths_trail
, ths_exit
;
2165 u32 tlpx_half
, tclk_trail
, tclk_zero
;
2168 /* calculate timings */
2170 /* 1 * DDR_CLK = 2 * UI */
2172 /* min 40ns + 4*UI max 85ns + 6*UI */
2173 ths_prepare
= ns2ddr(dsidev
, 70) + 2;
2175 /* min 145ns + 10*UI */
2176 ths_prepare_ths_zero
= ns2ddr(dsidev
, 175) + 2;
2178 /* min max(8*UI, 60ns+4*UI) */
2179 ths_trail
= ns2ddr(dsidev
, 60) + 5;
2182 ths_exit
= ns2ddr(dsidev
, 145);
2185 tlpx_half
= ns2ddr(dsidev
, 25);
2188 tclk_trail
= ns2ddr(dsidev
, 60) + 2;
2190 /* min 38ns, max 95ns */
2191 tclk_prepare
= ns2ddr(dsidev
, 65);
2193 /* min tclk-prepare + tclk-zero = 300ns */
2194 tclk_zero
= ns2ddr(dsidev
, 260);
2196 DSSDBG("ths_prepare %u (%uns), ths_prepare_ths_zero %u (%uns)\n",
2197 ths_prepare
, ddr2ns(dsidev
, ths_prepare
),
2198 ths_prepare_ths_zero
, ddr2ns(dsidev
, ths_prepare_ths_zero
));
2199 DSSDBG("ths_trail %u (%uns), ths_exit %u (%uns)\n",
2200 ths_trail
, ddr2ns(dsidev
, ths_trail
),
2201 ths_exit
, ddr2ns(dsidev
, ths_exit
));
2203 DSSDBG("tlpx_half %u (%uns), tclk_trail %u (%uns), "
2204 "tclk_zero %u (%uns)\n",
2205 tlpx_half
, ddr2ns(dsidev
, tlpx_half
),
2206 tclk_trail
, ddr2ns(dsidev
, tclk_trail
),
2207 tclk_zero
, ddr2ns(dsidev
, tclk_zero
));
2208 DSSDBG("tclk_prepare %u (%uns)\n",
2209 tclk_prepare
, ddr2ns(dsidev
, tclk_prepare
));
2211 /* program timings */
2213 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG0
);
2214 r
= FLD_MOD(r
, ths_prepare
, 31, 24);
2215 r
= FLD_MOD(r
, ths_prepare_ths_zero
, 23, 16);
2216 r
= FLD_MOD(r
, ths_trail
, 15, 8);
2217 r
= FLD_MOD(r
, ths_exit
, 7, 0);
2218 dsi_write_reg(dsidev
, DSI_DSIPHY_CFG0
, r
);
2220 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG1
);
2221 r
= FLD_MOD(r
, tlpx_half
, 22, 16);
2222 r
= FLD_MOD(r
, tclk_trail
, 15, 8);
2223 r
= FLD_MOD(r
, tclk_zero
, 7, 0);
2224 dsi_write_reg(dsidev
, DSI_DSIPHY_CFG1
, r
);
2226 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG2
);
2227 r
= FLD_MOD(r
, tclk_prepare
, 7, 0);
2228 dsi_write_reg(dsidev
, DSI_DSIPHY_CFG2
, r
);
2231 static void dsi_cio_enable_lane_override(struct omap_dss_device
*dssdev
,
2232 enum dsi_lane lanes
)
2234 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2235 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2236 int clk_lane
= dssdev
->phy
.dsi
.clk_lane
;
2237 int data1_lane
= dssdev
->phy
.dsi
.data1_lane
;
2238 int data2_lane
= dssdev
->phy
.dsi
.data2_lane
;
2239 int data3_lane
= dssdev
->phy
.dsi
.data3_lane
;
2240 int data4_lane
= dssdev
->phy
.dsi
.data4_lane
;
2241 int clk_pol
= dssdev
->phy
.dsi
.clk_pol
;
2242 int data1_pol
= dssdev
->phy
.dsi
.data1_pol
;
2243 int data2_pol
= dssdev
->phy
.dsi
.data2_pol
;
2244 int data3_pol
= dssdev
->phy
.dsi
.data3_pol
;
2245 int data4_pol
= dssdev
->phy
.dsi
.data4_pol
;
2248 u8 lptxscp_start
= dsi
->num_data_lanes
== 2 ? 22 : 26;
2250 if (lanes
& DSI_CLK_P
)
2251 l
|= 1 << ((clk_lane
- 1) * 2 + (clk_pol
? 0 : 1));
2252 if (lanes
& DSI_CLK_N
)
2253 l
|= 1 << ((clk_lane
- 1) * 2 + (clk_pol
? 1 : 0));
2255 if (lanes
& DSI_DATA1_P
)
2256 l
|= 1 << ((data1_lane
- 1) * 2 + (data1_pol
? 0 : 1));
2257 if (lanes
& DSI_DATA1_N
)
2258 l
|= 1 << ((data1_lane
- 1) * 2 + (data1_pol
? 1 : 0));
2260 if (lanes
& DSI_DATA2_P
)
2261 l
|= 1 << ((data2_lane
- 1) * 2 + (data2_pol
? 0 : 1));
2262 if (lanes
& DSI_DATA2_N
)
2263 l
|= 1 << ((data2_lane
- 1) * 2 + (data2_pol
? 1 : 0));
2265 if (lanes
& DSI_DATA3_P
)
2266 l
|= 1 << ((data3_lane
- 1) * 2 + (data3_pol
? 0 : 1));
2267 if (lanes
& DSI_DATA3_N
)
2268 l
|= 1 << ((data3_lane
- 1) * 2 + (data3_pol
? 1 : 0));
2270 if (lanes
& DSI_DATA4_P
)
2271 l
|= 1 << ((data4_lane
- 1) * 2 + (data4_pol
? 0 : 1));
2272 if (lanes
& DSI_DATA4_N
)
2273 l
|= 1 << ((data4_lane
- 1) * 2 + (data4_pol
? 1 : 0));
2275 * Bits in REGLPTXSCPDAT4TO0DXDY:
2283 /* Set the lane override configuration */
2285 /* REGLPTXSCPDAT4TO0DXDY */
2286 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, l
, lptxscp_start
, 17);
2288 /* Enable lane override */
2291 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, 1, 27, 27);
2294 static void dsi_cio_disable_lane_override(struct platform_device
*dsidev
)
2296 /* Disable lane override */
2297 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, 0, 27, 27); /* ENLPTXSCPDAT */
2298 /* Reset the lane override configuration */
2299 /* REGLPTXSCPDAT4TO0DXDY */
2300 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, 0, 22, 17);
2303 static int dsi_cio_wait_tx_clk_esc_reset(struct omap_dss_device
*dssdev
)
2305 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2310 if (dss_has_feature(FEAT_DSI_REVERSE_TXCLKESC
)) {
2324 if (dssdev
->phy
.dsi
.clk_lane
!= 0)
2325 in_use
[dssdev
->phy
.dsi
.clk_lane
- 1] = true;
2326 if (dssdev
->phy
.dsi
.data1_lane
!= 0)
2327 in_use
[dssdev
->phy
.dsi
.data1_lane
- 1] = true;
2328 if (dssdev
->phy
.dsi
.data2_lane
!= 0)
2329 in_use
[dssdev
->phy
.dsi
.data2_lane
- 1] = true;
2337 l
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
2340 for (i
= 0; i
< 3; ++i
) {
2341 if (!in_use
[i
] || (l
& (1 << bits
[i
])))
2349 for (i
= 0; i
< 3; ++i
) {
2350 if (!in_use
[i
] || (l
& (1 << bits
[i
])))
2353 DSSERR("CIO TXCLKESC%d domain not coming " \
2354 "out of reset\n", i
);
2363 static int dsi_cio_init(struct omap_dss_device
*dssdev
)
2365 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2366 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2368 int num_data_lanes_dssdev
= dsi_get_num_data_lanes_dssdev(dssdev
);
2373 if (dsi
->dsi_mux_pads
)
2374 dsi
->dsi_mux_pads(true);
2376 dsi_enable_scp_clk(dsidev
);
2378 /* A dummy read using the SCP interface to any DSIPHY register is
2379 * required after DSIPHY reset to complete the reset of the DSI complex
2381 dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
2383 if (wait_for_bit_change(dsidev
, DSI_DSIPHY_CFG5
, 30, 1) != 1) {
2384 DSSERR("CIO SCP Clock domain not coming out of reset.\n");
2386 goto err_scp_clk_dom
;
2389 dsi_set_lane_config(dssdev
);
2391 /* set TX STOP MODE timer to maximum for this operation */
2392 l
= dsi_read_reg(dsidev
, DSI_TIMING1
);
2393 l
= FLD_MOD(l
, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
2394 l
= FLD_MOD(l
, 1, 14, 14); /* STOP_STATE_X16_IO */
2395 l
= FLD_MOD(l
, 1, 13, 13); /* STOP_STATE_X4_IO */
2396 l
= FLD_MOD(l
, 0x1fff, 12, 0); /* STOP_STATE_COUNTER_IO */
2397 dsi_write_reg(dsidev
, DSI_TIMING1
, l
);
2399 if (dsi
->ulps_enabled
) {
2400 u32 lane_mask
= DSI_CLK_P
| DSI_DATA1_P
| DSI_DATA2_P
;
2402 DSSDBG("manual ulps exit\n");
2404 /* ULPS is exited by Mark-1 state for 1ms, followed by
2405 * stop state. DSS HW cannot do this via the normal
2406 * ULPS exit sequence, as after reset the DSS HW thinks
2407 * that we are not in ULPS mode, and refuses to send the
2408 * sequence. So we need to send the ULPS exit sequence
2412 if (num_data_lanes_dssdev
> 2)
2413 lane_mask
|= DSI_DATA3_P
;
2415 if (num_data_lanes_dssdev
> 3)
2416 lane_mask
|= DSI_DATA4_P
;
2418 dsi_cio_enable_lane_override(dssdev
, lane_mask
);
2421 r
= dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_ON
);
2425 if (wait_for_bit_change(dsidev
, DSI_COMPLEXIO_CFG1
, 29, 1) != 1) {
2426 DSSERR("CIO PWR clock domain not coming out of reset.\n");
2428 goto err_cio_pwr_dom
;
2431 dsi_if_enable(dsidev
, true);
2432 dsi_if_enable(dsidev
, false);
2433 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 1, 20, 20); /* LP_CLK_ENABLE */
2435 r
= dsi_cio_wait_tx_clk_esc_reset(dssdev
);
2437 goto err_tx_clk_esc_rst
;
2439 if (dsi
->ulps_enabled
) {
2440 /* Keep Mark-1 state for 1ms (as per DSI spec) */
2441 ktime_t wait
= ns_to_ktime(1000 * 1000);
2442 set_current_state(TASK_UNINTERRUPTIBLE
);
2443 schedule_hrtimeout(&wait
, HRTIMER_MODE_REL
);
2445 /* Disable the override. The lanes should be set to Mark-11
2446 * state by the HW */
2447 dsi_cio_disable_lane_override(dsidev
);
2450 /* FORCE_TX_STOP_MODE_IO */
2451 REG_FLD_MOD(dsidev
, DSI_TIMING1
, 0, 15, 15);
2453 dsi_cio_timings(dsidev
);
2455 dsi
->ulps_enabled
= false;
2457 DSSDBG("CIO init done\n");
2462 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 0, 20, 20); /* LP_CLK_ENABLE */
2464 dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_OFF
);
2466 if (dsi
->ulps_enabled
)
2467 dsi_cio_disable_lane_override(dsidev
);
2469 dsi_disable_scp_clk(dsidev
);
2470 if (dsi
->dsi_mux_pads
)
2471 dsi
->dsi_mux_pads(false);
2475 static void dsi_cio_uninit(struct platform_device
*dsidev
)
2477 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2479 dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_OFF
);
2480 dsi_disable_scp_clk(dsidev
);
2481 if (dsi
->dsi_mux_pads
)
2482 dsi
->dsi_mux_pads(false);
2485 static void dsi_config_tx_fifo(struct platform_device
*dsidev
,
2486 enum fifo_size size1
, enum fifo_size size2
,
2487 enum fifo_size size3
, enum fifo_size size4
)
2489 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2494 dsi
->vc
[0].fifo_size
= size1
;
2495 dsi
->vc
[1].fifo_size
= size2
;
2496 dsi
->vc
[2].fifo_size
= size3
;
2497 dsi
->vc
[3].fifo_size
= size4
;
2499 for (i
= 0; i
< 4; i
++) {
2501 int size
= dsi
->vc
[i
].fifo_size
;
2503 if (add
+ size
> 4) {
2504 DSSERR("Illegal FIFO configuration\n");
2508 v
= FLD_VAL(add
, 2, 0) | FLD_VAL(size
, 7, 4);
2510 /*DSSDBG("TX FIFO vc %d: size %d, add %d\n", i, size, add); */
2514 dsi_write_reg(dsidev
, DSI_TX_FIFO_VC_SIZE
, r
);
2517 static void dsi_config_rx_fifo(struct platform_device
*dsidev
,
2518 enum fifo_size size1
, enum fifo_size size2
,
2519 enum fifo_size size3
, enum fifo_size size4
)
2521 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2526 dsi
->vc
[0].fifo_size
= size1
;
2527 dsi
->vc
[1].fifo_size
= size2
;
2528 dsi
->vc
[2].fifo_size
= size3
;
2529 dsi
->vc
[3].fifo_size
= size4
;
2531 for (i
= 0; i
< 4; i
++) {
2533 int size
= dsi
->vc
[i
].fifo_size
;
2535 if (add
+ size
> 4) {
2536 DSSERR("Illegal FIFO configuration\n");
2540 v
= FLD_VAL(add
, 2, 0) | FLD_VAL(size
, 7, 4);
2542 /*DSSDBG("RX FIFO vc %d: size %d, add %d\n", i, size, add); */
2546 dsi_write_reg(dsidev
, DSI_RX_FIFO_VC_SIZE
, r
);
2549 static int dsi_force_tx_stop_mode_io(struct platform_device
*dsidev
)
2553 r
= dsi_read_reg(dsidev
, DSI_TIMING1
);
2554 r
= FLD_MOD(r
, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
2555 dsi_write_reg(dsidev
, DSI_TIMING1
, r
);
2557 if (wait_for_bit_change(dsidev
, DSI_TIMING1
, 15, 0) != 0) {
2558 DSSERR("TX_STOP bit not going down\n");
2565 static bool dsi_vc_is_enabled(struct platform_device
*dsidev
, int channel
)
2567 return REG_GET(dsidev
, DSI_VC_CTRL(channel
), 0, 0);
2570 static void dsi_packet_sent_handler_vp(void *data
, u32 mask
)
2572 struct dsi_packet_sent_handler_data
*vp_data
=
2573 (struct dsi_packet_sent_handler_data
*) data
;
2574 struct dsi_data
*dsi
= dsi_get_dsidrv_data(vp_data
->dsidev
);
2575 const int channel
= dsi
->update_channel
;
2576 u8 bit
= dsi
->te_enabled
? 30 : 31;
2578 if (REG_GET(vp_data
->dsidev
, DSI_VC_TE(channel
), bit
, bit
) == 0)
2579 complete(vp_data
->completion
);
2582 static int dsi_sync_vc_vp(struct platform_device
*dsidev
, int channel
)
2584 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2585 DECLARE_COMPLETION_ONSTACK(completion
);
2586 struct dsi_packet_sent_handler_data vp_data
= { dsidev
, &completion
};
2590 bit
= dsi
->te_enabled
? 30 : 31;
2592 r
= dsi_register_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_vp
,
2593 &vp_data
, DSI_VC_IRQ_PACKET_SENT
);
2597 /* Wait for completion only if TE_EN/TE_START is still set */
2598 if (REG_GET(dsidev
, DSI_VC_TE(channel
), bit
, bit
)) {
2599 if (wait_for_completion_timeout(&completion
,
2600 msecs_to_jiffies(10)) == 0) {
2601 DSSERR("Failed to complete previous frame transfer\n");
2607 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_vp
,
2608 &vp_data
, DSI_VC_IRQ_PACKET_SENT
);
2612 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_vp
,
2613 &vp_data
, DSI_VC_IRQ_PACKET_SENT
);
2618 static void dsi_packet_sent_handler_l4(void *data
, u32 mask
)
2620 struct dsi_packet_sent_handler_data
*l4_data
=
2621 (struct dsi_packet_sent_handler_data
*) data
;
2622 struct dsi_data
*dsi
= dsi_get_dsidrv_data(l4_data
->dsidev
);
2623 const int channel
= dsi
->update_channel
;
2625 if (REG_GET(l4_data
->dsidev
, DSI_VC_CTRL(channel
), 5, 5) == 0)
2626 complete(l4_data
->completion
);
2629 static int dsi_sync_vc_l4(struct platform_device
*dsidev
, int channel
)
2631 DECLARE_COMPLETION_ONSTACK(completion
);
2632 struct dsi_packet_sent_handler_data l4_data
= { dsidev
, &completion
};
2635 r
= dsi_register_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_l4
,
2636 &l4_data
, DSI_VC_IRQ_PACKET_SENT
);
2640 /* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */
2641 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 5, 5)) {
2642 if (wait_for_completion_timeout(&completion
,
2643 msecs_to_jiffies(10)) == 0) {
2644 DSSERR("Failed to complete previous l4 transfer\n");
2650 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_l4
,
2651 &l4_data
, DSI_VC_IRQ_PACKET_SENT
);
2655 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_l4
,
2656 &l4_data
, DSI_VC_IRQ_PACKET_SENT
);
2661 static int dsi_sync_vc(struct platform_device
*dsidev
, int channel
)
2663 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2665 WARN_ON(!dsi_bus_is_locked(dsidev
));
2667 WARN_ON(in_interrupt());
2669 if (!dsi_vc_is_enabled(dsidev
, channel
))
2672 switch (dsi
->vc
[channel
].mode
) {
2673 case DSI_VC_MODE_VP
:
2674 return dsi_sync_vc_vp(dsidev
, channel
);
2675 case DSI_VC_MODE_L4
:
2676 return dsi_sync_vc_l4(dsidev
, channel
);
2682 static int dsi_vc_enable(struct platform_device
*dsidev
, int channel
,
2685 DSSDBG("dsi_vc_enable channel %d, enable %d\n",
2688 enable
= enable
? 1 : 0;
2690 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), enable
, 0, 0);
2692 if (wait_for_bit_change(dsidev
, DSI_VC_CTRL(channel
),
2693 0, enable
) != enable
) {
2694 DSSERR("Failed to set dsi_vc_enable to %d\n", enable
);
2701 static void dsi_vc_initial_config(struct platform_device
*dsidev
, int channel
)
2705 DSSDBGF("%d", channel
);
2707 r
= dsi_read_reg(dsidev
, DSI_VC_CTRL(channel
));
2709 if (FLD_GET(r
, 15, 15)) /* VC_BUSY */
2710 DSSERR("VC(%d) busy when trying to configure it!\n",
2713 r
= FLD_MOD(r
, 0, 1, 1); /* SOURCE, 0 = L4 */
2714 r
= FLD_MOD(r
, 0, 2, 2); /* BTA_SHORT_EN */
2715 r
= FLD_MOD(r
, 0, 3, 3); /* BTA_LONG_EN */
2716 r
= FLD_MOD(r
, 0, 4, 4); /* MODE, 0 = command */
2717 r
= FLD_MOD(r
, 1, 7, 7); /* CS_TX_EN */
2718 r
= FLD_MOD(r
, 1, 8, 8); /* ECC_TX_EN */
2719 r
= FLD_MOD(r
, 0, 9, 9); /* MODE_SPEED, high speed on/off */
2720 if (dss_has_feature(FEAT_DSI_VC_OCP_WIDTH
))
2721 r
= FLD_MOD(r
, 3, 11, 10); /* OCP_WIDTH = 32 bit */
2723 r
= FLD_MOD(r
, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */
2724 r
= FLD_MOD(r
, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */
2726 dsi_write_reg(dsidev
, DSI_VC_CTRL(channel
), r
);
2729 static int dsi_vc_config_l4(struct platform_device
*dsidev
, int channel
)
2731 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2733 if (dsi
->vc
[channel
].mode
== DSI_VC_MODE_L4
)
2736 DSSDBGF("%d", channel
);
2738 dsi_sync_vc(dsidev
, channel
);
2740 dsi_vc_enable(dsidev
, channel
, 0);
2743 if (wait_for_bit_change(dsidev
, DSI_VC_CTRL(channel
), 15, 0) != 0) {
2744 DSSERR("vc(%d) busy when trying to config for L4\n", channel
);
2748 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 0, 1, 1); /* SOURCE, 0 = L4 */
2750 /* DCS_CMD_ENABLE */
2751 if (dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC
))
2752 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 0, 30, 30);
2754 dsi_vc_enable(dsidev
, channel
, 1);
2756 dsi
->vc
[channel
].mode
= DSI_VC_MODE_L4
;
2761 static int dsi_vc_config_vp(struct platform_device
*dsidev
, int channel
)
2763 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2765 if (dsi
->vc
[channel
].mode
== DSI_VC_MODE_VP
)
2768 DSSDBGF("%d", channel
);
2770 dsi_sync_vc(dsidev
, channel
);
2772 dsi_vc_enable(dsidev
, channel
, 0);
2775 if (wait_for_bit_change(dsidev
, DSI_VC_CTRL(channel
), 15, 0) != 0) {
2776 DSSERR("vc(%d) busy when trying to config for VP\n", channel
);
2780 /* SOURCE, 1 = video port */
2781 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 1, 1, 1);
2783 /* DCS_CMD_ENABLE */
2784 if (dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC
))
2785 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 1, 30, 30);
2787 dsi_vc_enable(dsidev
, channel
, 1);
2789 dsi
->vc
[channel
].mode
= DSI_VC_MODE_VP
;
2795 void omapdss_dsi_vc_enable_hs(struct omap_dss_device
*dssdev
, int channel
,
2798 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2800 DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel
, enable
);
2802 WARN_ON(!dsi_bus_is_locked(dsidev
));
2804 dsi_vc_enable(dsidev
, channel
, 0);
2805 dsi_if_enable(dsidev
, 0);
2807 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), enable
, 9, 9);
2809 dsi_vc_enable(dsidev
, channel
, 1);
2810 dsi_if_enable(dsidev
, 1);
2812 dsi_force_tx_stop_mode_io(dsidev
);
2814 EXPORT_SYMBOL(omapdss_dsi_vc_enable_hs
);
2816 static void dsi_vc_flush_long_data(struct platform_device
*dsidev
, int channel
)
2818 while (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
2820 val
= dsi_read_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
));
2821 DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
2825 (val
>> 24) & 0xff);
2829 static void dsi_show_rx_ack_with_err(u16 err
)
2831 DSSERR("\tACK with ERROR (%#x):\n", err
);
2833 DSSERR("\t\tSoT Error\n");
2835 DSSERR("\t\tSoT Sync Error\n");
2837 DSSERR("\t\tEoT Sync Error\n");
2839 DSSERR("\t\tEscape Mode Entry Command Error\n");
2841 DSSERR("\t\tLP Transmit Sync Error\n");
2843 DSSERR("\t\tHS Receive Timeout Error\n");
2845 DSSERR("\t\tFalse Control Error\n");
2847 DSSERR("\t\t(reserved7)\n");
2849 DSSERR("\t\tECC Error, single-bit (corrected)\n");
2851 DSSERR("\t\tECC Error, multi-bit (not corrected)\n");
2852 if (err
& (1 << 10))
2853 DSSERR("\t\tChecksum Error\n");
2854 if (err
& (1 << 11))
2855 DSSERR("\t\tData type not recognized\n");
2856 if (err
& (1 << 12))
2857 DSSERR("\t\tInvalid VC ID\n");
2858 if (err
& (1 << 13))
2859 DSSERR("\t\tInvalid Transmission Length\n");
2860 if (err
& (1 << 14))
2861 DSSERR("\t\t(reserved14)\n");
2862 if (err
& (1 << 15))
2863 DSSERR("\t\tDSI Protocol Violation\n");
2866 static u16
dsi_vc_flush_receive_data(struct platform_device
*dsidev
,
2869 /* RX_FIFO_NOT_EMPTY */
2870 while (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
2873 val
= dsi_read_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
));
2874 DSSERR("\trawval %#08x\n", val
);
2875 dt
= FLD_GET(val
, 5, 0);
2876 if (dt
== DSI_DT_RX_ACK_WITH_ERR
) {
2877 u16 err
= FLD_GET(val
, 23, 8);
2878 dsi_show_rx_ack_with_err(err
);
2879 } else if (dt
== DSI_DT_RX_SHORT_READ_1
) {
2880 DSSERR("\tDCS short response, 1 byte: %#x\n",
2881 FLD_GET(val
, 23, 8));
2882 } else if (dt
== DSI_DT_RX_SHORT_READ_2
) {
2883 DSSERR("\tDCS short response, 2 byte: %#x\n",
2884 FLD_GET(val
, 23, 8));
2885 } else if (dt
== DSI_DT_RX_DCS_LONG_READ
) {
2886 DSSERR("\tDCS long response, len %d\n",
2887 FLD_GET(val
, 23, 8));
2888 dsi_vc_flush_long_data(dsidev
, channel
);
2890 DSSERR("\tunknown datatype 0x%02x\n", dt
);
2896 static int dsi_vc_send_bta(struct platform_device
*dsidev
, int channel
)
2898 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2900 if (dsi
->debug_write
|| dsi
->debug_read
)
2901 DSSDBG("dsi_vc_send_bta %d\n", channel
);
2903 WARN_ON(!dsi_bus_is_locked(dsidev
));
2905 /* RX_FIFO_NOT_EMPTY */
2906 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
2907 DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
2908 dsi_vc_flush_receive_data(dsidev
, channel
);
2911 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 1, 6, 6); /* BTA_EN */
2916 int dsi_vc_send_bta_sync(struct omap_dss_device
*dssdev
, int channel
)
2918 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2919 DECLARE_COMPLETION_ONSTACK(completion
);
2923 r
= dsi_register_isr_vc(dsidev
, channel
, dsi_completion_handler
,
2924 &completion
, DSI_VC_IRQ_BTA
);
2928 r
= dsi_register_isr(dsidev
, dsi_completion_handler
, &completion
,
2929 DSI_IRQ_ERROR_MASK
);
2933 r
= dsi_vc_send_bta(dsidev
, channel
);
2937 if (wait_for_completion_timeout(&completion
,
2938 msecs_to_jiffies(500)) == 0) {
2939 DSSERR("Failed to receive BTA\n");
2944 err
= dsi_get_errors(dsidev
);
2946 DSSERR("Error while sending BTA: %x\n", err
);
2951 dsi_unregister_isr(dsidev
, dsi_completion_handler
, &completion
,
2952 DSI_IRQ_ERROR_MASK
);
2954 dsi_unregister_isr_vc(dsidev
, channel
, dsi_completion_handler
,
2955 &completion
, DSI_VC_IRQ_BTA
);
2959 EXPORT_SYMBOL(dsi_vc_send_bta_sync
);
2961 static inline void dsi_vc_write_long_header(struct platform_device
*dsidev
,
2962 int channel
, u8 data_type
, u16 len
, u8 ecc
)
2964 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2968 WARN_ON(!dsi_bus_is_locked(dsidev
));
2970 data_id
= data_type
| dsi
->vc
[channel
].vc_id
<< 6;
2972 val
= FLD_VAL(data_id
, 7, 0) | FLD_VAL(len
, 23, 8) |
2973 FLD_VAL(ecc
, 31, 24);
2975 dsi_write_reg(dsidev
, DSI_VC_LONG_PACKET_HEADER(channel
), val
);
2978 static inline void dsi_vc_write_long_payload(struct platform_device
*dsidev
,
2979 int channel
, u8 b1
, u8 b2
, u8 b3
, u8 b4
)
2983 val
= b4
<< 24 | b3
<< 16 | b2
<< 8 | b1
<< 0;
2985 /* DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n",
2986 b1, b2, b3, b4, val); */
2988 dsi_write_reg(dsidev
, DSI_VC_LONG_PACKET_PAYLOAD(channel
), val
);
2991 static int dsi_vc_send_long(struct platform_device
*dsidev
, int channel
,
2992 u8 data_type
, u8
*data
, u16 len
, u8 ecc
)
2995 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3001 if (dsi
->debug_write
)
3002 DSSDBG("dsi_vc_send_long, %d bytes\n", len
);
3005 if (dsi
->vc
[channel
].fifo_size
* 32 * 4 < len
+ 4) {
3006 DSSERR("unable to send long packet: packet too long.\n");
3010 dsi_vc_config_l4(dsidev
, channel
);
3012 dsi_vc_write_long_header(dsidev
, channel
, data_type
, len
, ecc
);
3015 for (i
= 0; i
< len
>> 2; i
++) {
3016 if (dsi
->debug_write
)
3017 DSSDBG("\tsending full packet %d\n", i
);
3024 dsi_vc_write_long_payload(dsidev
, channel
, b1
, b2
, b3
, b4
);
3029 b1
= 0; b2
= 0; b3
= 0;
3031 if (dsi
->debug_write
)
3032 DSSDBG("\tsending remainder bytes %d\n", i
);
3049 dsi_vc_write_long_payload(dsidev
, channel
, b1
, b2
, b3
, 0);
3055 static int dsi_vc_send_short(struct platform_device
*dsidev
, int channel
,
3056 u8 data_type
, u16 data
, u8 ecc
)
3058 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3062 WARN_ON(!dsi_bus_is_locked(dsidev
));
3064 if (dsi
->debug_write
)
3065 DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
3067 data_type
, data
& 0xff, (data
>> 8) & 0xff);
3069 dsi_vc_config_l4(dsidev
, channel
);
3071 if (FLD_GET(dsi_read_reg(dsidev
, DSI_VC_CTRL(channel
)), 16, 16)) {
3072 DSSERR("ERROR FIFO FULL, aborting transfer\n");
3076 data_id
= data_type
| dsi
->vc
[channel
].vc_id
<< 6;
3078 r
= (data_id
<< 0) | (data
<< 8) | (ecc
<< 24);
3080 dsi_write_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
), r
);
3085 int dsi_vc_send_null(struct omap_dss_device
*dssdev
, int channel
)
3087 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3088 u8 nullpkg
[] = {0, 0, 0, 0};
3090 return dsi_vc_send_long(dsidev
, channel
, DSI_DT_NULL_PACKET
, nullpkg
,
3093 EXPORT_SYMBOL(dsi_vc_send_null
);
3095 int dsi_vc_dcs_write_nosync(struct omap_dss_device
*dssdev
, int channel
,
3098 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3104 r
= dsi_vc_send_short(dsidev
, channel
, DSI_DT_DCS_SHORT_WRITE_0
,
3106 } else if (len
== 2) {
3107 r
= dsi_vc_send_short(dsidev
, channel
, DSI_DT_DCS_SHORT_WRITE_1
,
3108 data
[0] | (data
[1] << 8), 0);
3110 /* 0x39 = DCS Long Write */
3111 r
= dsi_vc_send_long(dsidev
, channel
, DSI_DT_DCS_LONG_WRITE
,
3117 EXPORT_SYMBOL(dsi_vc_dcs_write_nosync
);
3119 int dsi_vc_dcs_write(struct omap_dss_device
*dssdev
, int channel
, u8
*data
,
3122 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3125 r
= dsi_vc_dcs_write_nosync(dssdev
, channel
, data
, len
);
3129 r
= dsi_vc_send_bta_sync(dssdev
, channel
);
3133 /* RX_FIFO_NOT_EMPTY */
3134 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
3135 DSSERR("rx fifo not empty after write, dumping data:\n");
3136 dsi_vc_flush_receive_data(dsidev
, channel
);
3143 DSSERR("dsi_vc_dcs_write(ch %d, cmd 0x%02x, len %d) failed\n",
3144 channel
, data
[0], len
);
3147 EXPORT_SYMBOL(dsi_vc_dcs_write
);
3149 int dsi_vc_dcs_write_0(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
)
3151 return dsi_vc_dcs_write(dssdev
, channel
, &dcs_cmd
, 1);
3153 EXPORT_SYMBOL(dsi_vc_dcs_write_0
);
3155 int dsi_vc_dcs_write_1(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3161 return dsi_vc_dcs_write(dssdev
, channel
, buf
, 2);
3163 EXPORT_SYMBOL(dsi_vc_dcs_write_1
);
3165 int dsi_vc_dcs_read(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3166 u8
*buf
, int buflen
)
3168 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3169 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3174 if (dsi
->debug_read
)
3175 DSSDBG("dsi_vc_dcs_read(ch%d, dcs_cmd %x)\n", channel
, dcs_cmd
);
3177 r
= dsi_vc_send_short(dsidev
, channel
, DSI_DT_DCS_READ
, dcs_cmd
, 0);
3181 r
= dsi_vc_send_bta_sync(dssdev
, channel
);
3185 /* RX_FIFO_NOT_EMPTY */
3186 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20) == 0) {
3187 DSSERR("RX fifo empty when trying to read.\n");
3192 val
= dsi_read_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
));
3193 if (dsi
->debug_read
)
3194 DSSDBG("\theader: %08x\n", val
);
3195 dt
= FLD_GET(val
, 5, 0);
3196 if (dt
== DSI_DT_RX_ACK_WITH_ERR
) {
3197 u16 err
= FLD_GET(val
, 23, 8);
3198 dsi_show_rx_ack_with_err(err
);
3202 } else if (dt
== DSI_DT_RX_SHORT_READ_1
) {
3203 u8 data
= FLD_GET(val
, 15, 8);
3204 if (dsi
->debug_read
)
3205 DSSDBG("\tDCS short response, 1 byte: %02x\n", data
);
3215 } else if (dt
== DSI_DT_RX_SHORT_READ_2
) {
3216 u16 data
= FLD_GET(val
, 23, 8);
3217 if (dsi
->debug_read
)
3218 DSSDBG("\tDCS short response, 2 byte: %04x\n", data
);
3225 buf
[0] = data
& 0xff;
3226 buf
[1] = (data
>> 8) & 0xff;
3229 } else if (dt
== DSI_DT_RX_DCS_LONG_READ
) {
3231 int len
= FLD_GET(val
, 23, 8);
3232 if (dsi
->debug_read
)
3233 DSSDBG("\tDCS long response, len %d\n", len
);
3240 /* two byte checksum ends the packet, not included in len */
3241 for (w
= 0; w
< len
+ 2;) {
3243 val
= dsi_read_reg(dsidev
,
3244 DSI_VC_SHORT_PACKET_HEADER(channel
));
3245 if (dsi
->debug_read
)
3246 DSSDBG("\t\t%02x %02x %02x %02x\n",
3250 (val
>> 24) & 0xff);
3252 for (b
= 0; b
< 4; ++b
) {
3254 buf
[w
] = (val
>> (b
* 8)) & 0xff;
3255 /* we discard the 2 byte checksum */
3262 DSSERR("\tunknown datatype 0x%02x\n", dt
);
3269 DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
3274 EXPORT_SYMBOL(dsi_vc_dcs_read
);
3276 int dsi_vc_dcs_read_1(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3281 r
= dsi_vc_dcs_read(dssdev
, channel
, dcs_cmd
, data
, 1);
3291 EXPORT_SYMBOL(dsi_vc_dcs_read_1
);
3293 int dsi_vc_dcs_read_2(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3294 u8
*data1
, u8
*data2
)
3299 r
= dsi_vc_dcs_read(dssdev
, channel
, dcs_cmd
, buf
, 2);
3312 EXPORT_SYMBOL(dsi_vc_dcs_read_2
);
3314 int dsi_vc_set_max_rx_packet_size(struct omap_dss_device
*dssdev
, int channel
,
3317 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3319 return dsi_vc_send_short(dsidev
, channel
, DSI_DT_SET_MAX_RET_PKG_SIZE
,
3322 EXPORT_SYMBOL(dsi_vc_set_max_rx_packet_size
);
3324 static int dsi_enter_ulps(struct platform_device
*dsidev
)
3326 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3327 DECLARE_COMPLETION_ONSTACK(completion
);
3332 WARN_ON(!dsi_bus_is_locked(dsidev
));
3334 WARN_ON(dsi
->ulps_enabled
);
3336 if (dsi
->ulps_enabled
)
3339 if (REG_GET(dsidev
, DSI_CLK_CTRL
, 13, 13)) {
3340 DSSERR("DDR_CLK_ALWAYS_ON enabled when entering ULPS\n");
3344 dsi_sync_vc(dsidev
, 0);
3345 dsi_sync_vc(dsidev
, 1);
3346 dsi_sync_vc(dsidev
, 2);
3347 dsi_sync_vc(dsidev
, 3);
3349 dsi_force_tx_stop_mode_io(dsidev
);
3351 dsi_vc_enable(dsidev
, 0, false);
3352 dsi_vc_enable(dsidev
, 1, false);
3353 dsi_vc_enable(dsidev
, 2, false);
3354 dsi_vc_enable(dsidev
, 3, false);
3356 if (REG_GET(dsidev
, DSI_COMPLEXIO_CFG2
, 16, 16)) { /* HS_BUSY */
3357 DSSERR("HS busy when enabling ULPS\n");
3361 if (REG_GET(dsidev
, DSI_COMPLEXIO_CFG2
, 17, 17)) { /* LP_BUSY */
3362 DSSERR("LP busy when enabling ULPS\n");
3366 r
= dsi_register_isr_cio(dsidev
, dsi_completion_handler
, &completion
,
3367 DSI_CIO_IRQ_ULPSACTIVENOT_ALL0
);
3371 /* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */
3372 /* LANEx_ULPS_SIG2 */
3373 REG_FLD_MOD(dsidev
, DSI_COMPLEXIO_CFG2
, (1 << 0) | (1 << 1) | (1 << 2),
3376 if (wait_for_completion_timeout(&completion
,
3377 msecs_to_jiffies(1000)) == 0) {
3378 DSSERR("ULPS enable timeout\n");
3383 dsi_unregister_isr_cio(dsidev
, dsi_completion_handler
, &completion
,
3384 DSI_CIO_IRQ_ULPSACTIVENOT_ALL0
);
3386 /* Reset LANEx_ULPS_SIG2 */
3387 REG_FLD_MOD(dsidev
, DSI_COMPLEXIO_CFG2
, (0 << 0) | (0 << 1) | (0 << 2),
3390 dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_ULPS
);
3392 dsi_if_enable(dsidev
, false);
3394 dsi
->ulps_enabled
= true;
3399 dsi_unregister_isr_cio(dsidev
, dsi_completion_handler
, &completion
,
3400 DSI_CIO_IRQ_ULPSACTIVENOT_ALL0
);
3404 static void dsi_set_lp_rx_timeout(struct platform_device
*dsidev
,
3405 unsigned ticks
, bool x4
, bool x16
)
3408 unsigned long total_ticks
;
3411 BUG_ON(ticks
> 0x1fff);
3413 /* ticks in DSI_FCK */
3414 fck
= dsi_fclk_rate(dsidev
);
3416 r
= dsi_read_reg(dsidev
, DSI_TIMING2
);
3417 r
= FLD_MOD(r
, 1, 15, 15); /* LP_RX_TO */
3418 r
= FLD_MOD(r
, x16
? 1 : 0, 14, 14); /* LP_RX_TO_X16 */
3419 r
= FLD_MOD(r
, x4
? 1 : 0, 13, 13); /* LP_RX_TO_X4 */
3420 r
= FLD_MOD(r
, ticks
, 12, 0); /* LP_RX_COUNTER */
3421 dsi_write_reg(dsidev
, DSI_TIMING2
, r
);
3423 total_ticks
= ticks
* (x16
? 16 : 1) * (x4
? 4 : 1);
3425 DSSDBG("LP_RX_TO %lu ticks (%#x%s%s) = %lu ns\n",
3427 ticks
, x4
? " x4" : "", x16
? " x16" : "",
3428 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3431 static void dsi_set_ta_timeout(struct platform_device
*dsidev
, unsigned ticks
,
3435 unsigned long total_ticks
;
3438 BUG_ON(ticks
> 0x1fff);
3440 /* ticks in DSI_FCK */
3441 fck
= dsi_fclk_rate(dsidev
);
3443 r
= dsi_read_reg(dsidev
, DSI_TIMING1
);
3444 r
= FLD_MOD(r
, 1, 31, 31); /* TA_TO */
3445 r
= FLD_MOD(r
, x16
? 1 : 0, 30, 30); /* TA_TO_X16 */
3446 r
= FLD_MOD(r
, x8
? 1 : 0, 29, 29); /* TA_TO_X8 */
3447 r
= FLD_MOD(r
, ticks
, 28, 16); /* TA_TO_COUNTER */
3448 dsi_write_reg(dsidev
, DSI_TIMING1
, r
);
3450 total_ticks
= ticks
* (x16
? 16 : 1) * (x8
? 8 : 1);
3452 DSSDBG("TA_TO %lu ticks (%#x%s%s) = %lu ns\n",
3454 ticks
, x8
? " x8" : "", x16
? " x16" : "",
3455 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3458 static void dsi_set_stop_state_counter(struct platform_device
*dsidev
,
3459 unsigned ticks
, bool x4
, bool x16
)
3462 unsigned long total_ticks
;
3465 BUG_ON(ticks
> 0x1fff);
3467 /* ticks in DSI_FCK */
3468 fck
= dsi_fclk_rate(dsidev
);
3470 r
= dsi_read_reg(dsidev
, DSI_TIMING1
);
3471 r
= FLD_MOD(r
, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
3472 r
= FLD_MOD(r
, x16
? 1 : 0, 14, 14); /* STOP_STATE_X16_IO */
3473 r
= FLD_MOD(r
, x4
? 1 : 0, 13, 13); /* STOP_STATE_X4_IO */
3474 r
= FLD_MOD(r
, ticks
, 12, 0); /* STOP_STATE_COUNTER_IO */
3475 dsi_write_reg(dsidev
, DSI_TIMING1
, r
);
3477 total_ticks
= ticks
* (x16
? 16 : 1) * (x4
? 4 : 1);
3479 DSSDBG("STOP_STATE_COUNTER %lu ticks (%#x%s%s) = %lu ns\n",
3481 ticks
, x4
? " x4" : "", x16
? " x16" : "",
3482 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3485 static void dsi_set_hs_tx_timeout(struct platform_device
*dsidev
,
3486 unsigned ticks
, bool x4
, bool x16
)
3489 unsigned long total_ticks
;
3492 BUG_ON(ticks
> 0x1fff);
3494 /* ticks in TxByteClkHS */
3495 fck
= dsi_get_txbyteclkhs(dsidev
);
3497 r
= dsi_read_reg(dsidev
, DSI_TIMING2
);
3498 r
= FLD_MOD(r
, 1, 31, 31); /* HS_TX_TO */
3499 r
= FLD_MOD(r
, x16
? 1 : 0, 30, 30); /* HS_TX_TO_X16 */
3500 r
= FLD_MOD(r
, x4
? 1 : 0, 29, 29); /* HS_TX_TO_X8 (4 really) */
3501 r
= FLD_MOD(r
, ticks
, 28, 16); /* HS_TX_TO_COUNTER */
3502 dsi_write_reg(dsidev
, DSI_TIMING2
, r
);
3504 total_ticks
= ticks
* (x16
? 16 : 1) * (x4
? 4 : 1);
3506 DSSDBG("HS_TX_TO %lu ticks (%#x%s%s) = %lu ns\n",
3508 ticks
, x4
? " x4" : "", x16
? " x16" : "",
3509 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3511 static int dsi_proto_config(struct omap_dss_device
*dssdev
)
3513 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3517 dsi_config_tx_fifo(dsidev
, DSI_FIFO_SIZE_32
,
3522 dsi_config_rx_fifo(dsidev
, DSI_FIFO_SIZE_32
,
3527 /* XXX what values for the timeouts? */
3528 dsi_set_stop_state_counter(dsidev
, 0x1000, false, false);
3529 dsi_set_ta_timeout(dsidev
, 0x1fff, true, true);
3530 dsi_set_lp_rx_timeout(dsidev
, 0x1fff, true, true);
3531 dsi_set_hs_tx_timeout(dsidev
, 0x1fff, true, true);
3533 switch (dssdev
->ctrl
.pixel_size
) {
3547 r
= dsi_read_reg(dsidev
, DSI_CTRL
);
3548 r
= FLD_MOD(r
, 1, 1, 1); /* CS_RX_EN */
3549 r
= FLD_MOD(r
, 1, 2, 2); /* ECC_RX_EN */
3550 r
= FLD_MOD(r
, 1, 3, 3); /* TX_FIFO_ARBITRATION */
3551 r
= FLD_MOD(r
, 1, 4, 4); /* VP_CLK_RATIO, always 1, see errata*/
3552 r
= FLD_MOD(r
, buswidth
, 7, 6); /* VP_DATA_BUS_WIDTH */
3553 r
= FLD_MOD(r
, 0, 8, 8); /* VP_CLK_POL */
3554 r
= FLD_MOD(r
, 2, 13, 12); /* LINE_BUFFER, 2 lines */
3555 r
= FLD_MOD(r
, 1, 14, 14); /* TRIGGER_RESET_MODE */
3556 r
= FLD_MOD(r
, 1, 19, 19); /* EOT_ENABLE */
3557 if (!dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC
)) {
3558 r
= FLD_MOD(r
, 1, 24, 24); /* DCS_CMD_ENABLE */
3559 /* DCS_CMD_CODE, 1=start, 0=continue */
3560 r
= FLD_MOD(r
, 0, 25, 25);
3563 dsi_write_reg(dsidev
, DSI_CTRL
, r
);
3565 dsi_vc_initial_config(dsidev
, 0);
3566 dsi_vc_initial_config(dsidev
, 1);
3567 dsi_vc_initial_config(dsidev
, 2);
3568 dsi_vc_initial_config(dsidev
, 3);
3573 static void dsi_proto_timings(struct omap_dss_device
*dssdev
)
3575 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3576 unsigned tlpx
, tclk_zero
, tclk_prepare
, tclk_trail
;
3577 unsigned tclk_pre
, tclk_post
;
3578 unsigned ths_prepare
, ths_prepare_ths_zero
, ths_zero
;
3579 unsigned ths_trail
, ths_exit
;
3580 unsigned ddr_clk_pre
, ddr_clk_post
;
3581 unsigned enter_hs_mode_lat
, exit_hs_mode_lat
;
3585 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG0
);
3586 ths_prepare
= FLD_GET(r
, 31, 24);
3587 ths_prepare_ths_zero
= FLD_GET(r
, 23, 16);
3588 ths_zero
= ths_prepare_ths_zero
- ths_prepare
;
3589 ths_trail
= FLD_GET(r
, 15, 8);
3590 ths_exit
= FLD_GET(r
, 7, 0);
3592 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG1
);
3593 tlpx
= FLD_GET(r
, 22, 16) * 2;
3594 tclk_trail
= FLD_GET(r
, 15, 8);
3595 tclk_zero
= FLD_GET(r
, 7, 0);
3597 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG2
);
3598 tclk_prepare
= FLD_GET(r
, 7, 0);
3602 /* min 60ns + 52*UI */
3603 tclk_post
= ns2ddr(dsidev
, 60) + 26;
3605 ths_eot
= DIV_ROUND_UP(4, dsi_get_num_data_lanes_dssdev(dssdev
));
3607 ddr_clk_pre
= DIV_ROUND_UP(tclk_pre
+ tlpx
+ tclk_zero
+ tclk_prepare
,
3609 ddr_clk_post
= DIV_ROUND_UP(tclk_post
+ ths_trail
, 4) + ths_eot
;
3611 BUG_ON(ddr_clk_pre
== 0 || ddr_clk_pre
> 255);
3612 BUG_ON(ddr_clk_post
== 0 || ddr_clk_post
> 255);
3614 r
= dsi_read_reg(dsidev
, DSI_CLK_TIMING
);
3615 r
= FLD_MOD(r
, ddr_clk_pre
, 15, 8);
3616 r
= FLD_MOD(r
, ddr_clk_post
, 7, 0);
3617 dsi_write_reg(dsidev
, DSI_CLK_TIMING
, r
);
3619 DSSDBG("ddr_clk_pre %u, ddr_clk_post %u\n",
3623 enter_hs_mode_lat
= 1 + DIV_ROUND_UP(tlpx
, 4) +
3624 DIV_ROUND_UP(ths_prepare
, 4) +
3625 DIV_ROUND_UP(ths_zero
+ 3, 4);
3627 exit_hs_mode_lat
= DIV_ROUND_UP(ths_trail
+ ths_exit
, 4) + 1 + ths_eot
;
3629 r
= FLD_VAL(enter_hs_mode_lat
, 31, 16) |
3630 FLD_VAL(exit_hs_mode_lat
, 15, 0);
3631 dsi_write_reg(dsidev
, DSI_VM_TIMING7
, r
);
3633 DSSDBG("enter_hs_mode_lat %u, exit_hs_mode_lat %u\n",
3634 enter_hs_mode_lat
, exit_hs_mode_lat
);
3638 #define DSI_DECL_VARS \
3639 int __dsi_cb = 0; u32 __dsi_cv = 0;
3641 #define DSI_FLUSH(dsidev, ch) \
3642 if (__dsi_cb > 0) { \
3643 /*DSSDBG("sending long packet %#010x\n", __dsi_cv);*/ \
3644 dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_PAYLOAD(ch), __dsi_cv); \
3645 __dsi_cb = __dsi_cv = 0; \
3648 #define DSI_PUSH(dsidev, ch, data) \
3650 __dsi_cv |= (data) << (__dsi_cb * 8); \
3651 /*DSSDBG("cv = %#010x, cb = %d\n", __dsi_cv, __dsi_cb);*/ \
3652 if (++__dsi_cb > 3) \
3653 DSI_FLUSH(dsidev, ch); \
3656 static int dsi_update_screen_l4(struct omap_dss_device
*dssdev
,
3657 int x
, int y
, int w
, int h
)
3659 /* Note: supports only 24bit colors in 32bit container */
3660 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3661 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3663 int fifo_stalls
= 0;
3664 int max_dsi_packet_size
;
3665 int max_data_per_packet
;
3666 int max_pixels_per_packet
;
3668 int bytespp
= dssdev
->ctrl
.pixel_size
/ 8;
3674 struct omap_overlay
*ovl
;
3678 DSSDBG("dsi_update_screen_l4 (%d,%d %dx%d)\n",
3681 ovl
= dssdev
->manager
->overlays
[0];
3683 if (ovl
->info
.color_mode
!= OMAP_DSS_COLOR_RGB24U
)
3686 if (dssdev
->ctrl
.pixel_size
!= 24)
3689 scr_width
= ovl
->info
.screen_width
;
3690 data
= ovl
->info
.vaddr
;
3692 start_offset
= scr_width
* y
+ x
;
3693 horiz_inc
= scr_width
- w
;
3696 /* We need header(4) + DCSCMD(1) + pixels(numpix*bytespp) bytes
3699 /* When using CPU, max long packet size is TX buffer size */
3700 max_dsi_packet_size
= dsi
->vc
[0].fifo_size
* 32 * 4;
3702 /* we seem to get better perf if we divide the tx fifo to half,
3703 and while the other half is being sent, we fill the other half
3704 max_dsi_packet_size /= 2; */
3706 max_data_per_packet
= max_dsi_packet_size
- 4 - 1;
3708 max_pixels_per_packet
= max_data_per_packet
/ bytespp
;
3710 DSSDBG("max_pixels_per_packet %d\n", max_pixels_per_packet
);
3712 pixels_left
= w
* h
;
3714 DSSDBG("total pixels %d\n", pixels_left
);
3716 data
+= start_offset
;
3718 while (pixels_left
> 0) {
3719 /* 0x2c = write_memory_start */
3720 /* 0x3c = write_memory_continue */
3721 u8 dcs_cmd
= first
? 0x2c : 0x3c;
3727 /* using fifo not empty */
3728 /* TX_FIFO_NOT_EMPTY */
3729 while (FLD_GET(dsi_read_reg(dsidev
, DSI_VC_CTRL(0)), 5, 5)) {
3731 if (fifo_stalls
> 0xfffff) {
3732 DSSERR("fifo stalls overflow, pixels left %d\n",
3734 dsi_if_enable(dsidev
, 0);
3740 /* using fifo emptiness */
3741 while ((REG_GET(dsidev
, DSI_TX_FIFO_VC_EMPTINESS
, 7, 0)+1)*4 <
3742 max_dsi_packet_size
) {
3744 if (fifo_stalls
> 0xfffff) {
3745 DSSERR("fifo stalls overflow, pixels left %d\n",
3747 dsi_if_enable(dsidev
, 0);
3752 while ((REG_GET(dsidev
, DSI_TX_FIFO_VC_EMPTINESS
,
3753 7, 0) + 1) * 4 == 0) {
3755 if (fifo_stalls
> 0xfffff) {
3756 DSSERR("fifo stalls overflow, pixels left %d\n",
3758 dsi_if_enable(dsidev
, 0);
3763 pixels
= min(max_pixels_per_packet
, pixels_left
);
3765 pixels_left
-= pixels
;
3767 dsi_vc_write_long_header(dsidev
, 0, DSI_DT_DCS_LONG_WRITE
,
3768 1 + pixels
* bytespp
, 0);
3770 DSI_PUSH(dsidev
, 0, dcs_cmd
);
3772 while (pixels
-- > 0) {
3773 u32 pix
= __raw_readl(data
++);
3775 DSI_PUSH(dsidev
, 0, (pix
>> 16) & 0xff);
3776 DSI_PUSH(dsidev
, 0, (pix
>> 8) & 0xff);
3777 DSI_PUSH(dsidev
, 0, (pix
>> 0) & 0xff);
3780 if (current_x
== x
+w
) {
3786 DSI_FLUSH(dsidev
, 0);
3792 static void dsi_update_screen_dispc(struct omap_dss_device
*dssdev
,
3793 u16 x
, u16 y
, u16 w
, u16 h
)
3795 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3796 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3801 unsigned packet_payload
;
3802 unsigned packet_len
;
3805 const unsigned channel
= dsi
->update_channel
;
3806 const unsigned line_buf_size
= dsi_get_line_buf_size(dsidev
);
3808 DSSDBG("dsi_update_screen_dispc(%d,%d %dx%d)\n",
3811 dsi_vc_config_vp(dsidev
, channel
);
3813 bytespp
= dssdev
->ctrl
.pixel_size
/ 8;
3814 bytespl
= w
* bytespp
;
3815 bytespf
= bytespl
* h
;
3817 /* NOTE: packet_payload has to be equal to N * bytespl, where N is
3818 * number of lines in a packet. See errata about VP_CLK_RATIO */
3820 if (bytespf
< line_buf_size
)
3821 packet_payload
= bytespf
;
3823 packet_payload
= (line_buf_size
) / bytespl
* bytespl
;
3825 packet_len
= packet_payload
+ 1; /* 1 byte for DCS cmd */
3826 total_len
= (bytespf
/ packet_payload
) * packet_len
;
3828 if (bytespf
% packet_payload
)
3829 total_len
+= (bytespf
% packet_payload
) + 1;
3831 l
= FLD_VAL(total_len
, 23, 0); /* TE_SIZE */
3832 dsi_write_reg(dsidev
, DSI_VC_TE(channel
), l
);
3834 dsi_vc_write_long_header(dsidev
, channel
, DSI_DT_DCS_LONG_WRITE
,
3837 if (dsi
->te_enabled
)
3838 l
= FLD_MOD(l
, 1, 30, 30); /* TE_EN */
3840 l
= FLD_MOD(l
, 1, 31, 31); /* TE_START */
3841 dsi_write_reg(dsidev
, DSI_VC_TE(channel
), l
);
3843 /* We put SIDLEMODE to no-idle for the duration of the transfer,
3844 * because DSS interrupts are not capable of waking up the CPU and the
3845 * framedone interrupt could be delayed for quite a long time. I think
3846 * the same goes for any DSS interrupts, but for some reason I have not
3847 * seen the problem anywhere else than here.
3849 dispc_disable_sidle();
3851 dsi_perf_mark_start(dsidev
);
3853 r
= schedule_delayed_work(&dsi
->framedone_timeout_work
,
3854 msecs_to_jiffies(250));
3857 dss_start_update(dssdev
);
3859 if (dsi
->te_enabled
) {
3860 /* disable LP_RX_TO, so that we can receive TE. Time to wait
3861 * for TE is longer than the timer allows */
3862 REG_FLD_MOD(dsidev
, DSI_TIMING2
, 0, 15, 15); /* LP_RX_TO */
3864 dsi_vc_send_bta(dsidev
, channel
);
3866 #ifdef DSI_CATCH_MISSING_TE
3867 mod_timer(&dsi
->te_timer
, jiffies
+ msecs_to_jiffies(250));
3872 #ifdef DSI_CATCH_MISSING_TE
3873 static void dsi_te_timeout(unsigned long arg
)
3875 DSSERR("TE not received for 250ms!\n");
3879 static void dsi_handle_framedone(struct platform_device
*dsidev
, int error
)
3881 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3883 /* SIDLEMODE back to smart-idle */
3884 dispc_enable_sidle();
3886 if (dsi
->te_enabled
) {
3887 /* enable LP_RX_TO again after the TE */
3888 REG_FLD_MOD(dsidev
, DSI_TIMING2
, 1, 15, 15); /* LP_RX_TO */
3891 dsi
->framedone_callback(error
, dsi
->framedone_data
);
3894 dsi_perf_show(dsidev
, "DISPC");
3897 static void dsi_framedone_timeout_work_callback(struct work_struct
*work
)
3899 struct dsi_data
*dsi
= container_of(work
, struct dsi_data
,
3900 framedone_timeout_work
.work
);
3901 /* XXX While extremely unlikely, we could get FRAMEDONE interrupt after
3902 * 250ms which would conflict with this timeout work. What should be
3903 * done is first cancel the transfer on the HW, and then cancel the
3904 * possibly scheduled framedone work. However, cancelling the transfer
3905 * on the HW is buggy, and would probably require resetting the whole
3908 DSSERR("Framedone not received for 250ms!\n");
3910 dsi_handle_framedone(dsi
->pdev
, -ETIMEDOUT
);
3913 static void dsi_framedone_irq_callback(void *data
, u32 mask
)
3915 struct omap_dss_device
*dssdev
= (struct omap_dss_device
*) data
;
3916 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3917 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3919 /* Note: We get FRAMEDONE when DISPC has finished sending pixels and
3920 * turns itself off. However, DSI still has the pixels in its buffers,
3921 * and is sending the data.
3924 __cancel_delayed_work(&dsi
->framedone_timeout_work
);
3926 dsi_handle_framedone(dsidev
, 0);
3928 #ifdef CONFIG_OMAP2_DSS_FAKE_VSYNC
3929 dispc_fake_vsync_irq();
3933 int omap_dsi_prepare_update(struct omap_dss_device
*dssdev
,
3934 u16
*x
, u16
*y
, u16
*w
, u16
*h
,
3935 bool enlarge_update_area
)
3937 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3940 dssdev
->driver
->get_resolution(dssdev
, &dw
, &dh
);
3942 if (*x
> dw
|| *y
> dh
)
3954 if (*w
== 0 || *h
== 0)
3957 dsi_perf_mark_setup(dsidev
);
3959 if (dssdev
->manager
->caps
& OMAP_DSS_OVL_MGR_CAP_DISPC
) {
3960 dss_setup_partial_planes(dssdev
, x
, y
, w
, h
,
3961 enlarge_update_area
);
3962 dispc_set_lcd_size(dssdev
->manager
->id
, *w
, *h
);
3967 EXPORT_SYMBOL(omap_dsi_prepare_update
);
3969 int omap_dsi_update(struct omap_dss_device
*dssdev
,
3971 u16 x
, u16 y
, u16 w
, u16 h
,
3972 void (*callback
)(int, void *), void *data
)
3974 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3975 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3977 dsi
->update_channel
= channel
;
3979 /* OMAP DSS cannot send updates of odd widths.
3980 * omap_dsi_prepare_update() makes the widths even, but add a BUG_ON
3981 * here to make sure we catch erroneous updates. Otherwise we'll only
3982 * see rather obscure HW error happening, as DSS halts. */
3985 if (dssdev
->manager
->caps
& OMAP_DSS_OVL_MGR_CAP_DISPC
) {
3986 dsi
->framedone_callback
= callback
;
3987 dsi
->framedone_data
= data
;
3989 dsi
->update_region
.x
= x
;
3990 dsi
->update_region
.y
= y
;
3991 dsi
->update_region
.w
= w
;
3992 dsi
->update_region
.h
= h
;
3993 dsi
->update_region
.device
= dssdev
;
3995 dsi_update_screen_dispc(dssdev
, x
, y
, w
, h
);
3999 r
= dsi_update_screen_l4(dssdev
, x
, y
, w
, h
);
4003 dsi_perf_show(dsidev
, "L4");
4009 EXPORT_SYMBOL(omap_dsi_update
);
4013 static int dsi_display_init_dispc(struct omap_dss_device
*dssdev
)
4018 irq
= dssdev
->manager
->id
== OMAP_DSS_CHANNEL_LCD
?
4019 DISPC_IRQ_FRAMEDONE
: DISPC_IRQ_FRAMEDONE2
;
4021 r
= omap_dispc_register_isr(dsi_framedone_irq_callback
, (void *) dssdev
,
4024 DSSERR("can't get FRAMEDONE irq\n");
4028 dispc_set_lcd_display_type(dssdev
->manager
->id
,
4029 OMAP_DSS_LCD_DISPLAY_TFT
);
4031 dispc_set_parallel_interface_mode(dssdev
->manager
->id
,
4032 OMAP_DSS_PARALLELMODE_DSI
);
4033 dispc_enable_fifohandcheck(dssdev
->manager
->id
, 1);
4035 dispc_set_tft_data_lines(dssdev
->manager
->id
, dssdev
->ctrl
.pixel_size
);
4038 struct omap_video_timings timings
= {
4047 dispc_set_lcd_timings(dssdev
->manager
->id
, &timings
);
4053 static void dsi_display_uninit_dispc(struct omap_dss_device
*dssdev
)
4057 irq
= dssdev
->manager
->id
== OMAP_DSS_CHANNEL_LCD
?
4058 DISPC_IRQ_FRAMEDONE
: DISPC_IRQ_FRAMEDONE2
;
4060 omap_dispc_unregister_isr(dsi_framedone_irq_callback
, (void *) dssdev
,
4064 static int dsi_configure_dsi_clocks(struct omap_dss_device
*dssdev
)
4066 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4067 struct dsi_clock_info cinfo
;
4070 /* we always use DSS_CLK_SYSCK as input clock */
4071 cinfo
.use_sys_clk
= true;
4072 cinfo
.regn
= dssdev
->clocks
.dsi
.regn
;
4073 cinfo
.regm
= dssdev
->clocks
.dsi
.regm
;
4074 cinfo
.regm_dispc
= dssdev
->clocks
.dsi
.regm_dispc
;
4075 cinfo
.regm_dsi
= dssdev
->clocks
.dsi
.regm_dsi
;
4076 r
= dsi_calc_clock_rates(dssdev
, &cinfo
);
4078 DSSERR("Failed to calc dsi clocks\n");
4082 r
= dsi_pll_set_clock_div(dsidev
, &cinfo
);
4084 DSSERR("Failed to set dsi clocks\n");
4091 static int dsi_configure_dispc_clocks(struct omap_dss_device
*dssdev
)
4093 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4094 struct dispc_clock_info dispc_cinfo
;
4096 unsigned long long fck
;
4098 fck
= dsi_get_pll_hsdiv_dispc_rate(dsidev
);
4100 dispc_cinfo
.lck_div
= dssdev
->clocks
.dispc
.channel
.lck_div
;
4101 dispc_cinfo
.pck_div
= dssdev
->clocks
.dispc
.channel
.pck_div
;
4103 r
= dispc_calc_clock_rates(fck
, &dispc_cinfo
);
4105 DSSERR("Failed to calc dispc clocks\n");
4109 r
= dispc_set_clock_div(dssdev
->manager
->id
, &dispc_cinfo
);
4111 DSSERR("Failed to set dispc clocks\n");
4118 static int dsi_display_init_dsi(struct omap_dss_device
*dssdev
)
4120 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4121 int dsi_module
= dsi_get_dsidev_id(dsidev
);
4124 r
= dsi_pll_init(dsidev
, true, true);
4128 r
= dsi_configure_dsi_clocks(dssdev
);
4132 dss_select_dispc_clk_source(dssdev
->clocks
.dispc
.dispc_fclk_src
);
4133 dss_select_dsi_clk_source(dsi_module
, dssdev
->clocks
.dsi
.dsi_fclk_src
);
4134 dss_select_lcd_clk_source(dssdev
->manager
->id
,
4135 dssdev
->clocks
.dispc
.channel
.lcd_clk_src
);
4139 r
= dsi_configure_dispc_clocks(dssdev
);
4143 r
= dsi_cio_init(dssdev
);
4147 _dsi_print_reset_status(dsidev
);
4149 dsi_proto_timings(dssdev
);
4150 dsi_set_lp_clk_divisor(dssdev
);
4153 _dsi_print_reset_status(dsidev
);
4155 r
= dsi_proto_config(dssdev
);
4159 /* enable interface */
4160 dsi_vc_enable(dsidev
, 0, 1);
4161 dsi_vc_enable(dsidev
, 1, 1);
4162 dsi_vc_enable(dsidev
, 2, 1);
4163 dsi_vc_enable(dsidev
, 3, 1);
4164 dsi_if_enable(dsidev
, 1);
4165 dsi_force_tx_stop_mode_io(dsidev
);
4169 dsi_cio_uninit(dsidev
);
4171 dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK
);
4172 dss_select_dsi_clk_source(dsi_module
, OMAP_DSS_CLK_SRC_FCK
);
4174 dsi_pll_uninit(dsidev
, true);
4179 static void dsi_display_uninit_dsi(struct omap_dss_device
*dssdev
,
4180 bool disconnect_lanes
, bool enter_ulps
)
4182 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4183 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4184 int dsi_module
= dsi_get_dsidev_id(dsidev
);
4186 if (enter_ulps
&& !dsi
->ulps_enabled
)
4187 dsi_enter_ulps(dsidev
);
4189 /* disable interface */
4190 dsi_if_enable(dsidev
, 0);
4191 dsi_vc_enable(dsidev
, 0, 0);
4192 dsi_vc_enable(dsidev
, 1, 0);
4193 dsi_vc_enable(dsidev
, 2, 0);
4194 dsi_vc_enable(dsidev
, 3, 0);
4196 dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK
);
4197 dss_select_dsi_clk_source(dsi_module
, OMAP_DSS_CLK_SRC_FCK
);
4198 dsi_cio_uninit(dsidev
);
4199 dsi_pll_uninit(dsidev
, disconnect_lanes
);
4202 int omapdss_dsi_display_enable(struct omap_dss_device
*dssdev
)
4204 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4205 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4208 DSSDBG("dsi_display_enable\n");
4210 WARN_ON(!dsi_bus_is_locked(dsidev
));
4212 mutex_lock(&dsi
->lock
);
4214 r
= omap_dss_start_device(dssdev
);
4216 DSSERR("failed to start device\n");
4220 r
= dsi_runtime_get(dsidev
);
4224 dsi_enable_pll_clock(dsidev
, 1);
4226 _dsi_initialize_irq(dsidev
);
4228 r
= dsi_display_init_dispc(dssdev
);
4230 goto err_init_dispc
;
4232 r
= dsi_display_init_dsi(dssdev
);
4236 mutex_unlock(&dsi
->lock
);
4241 dsi_display_uninit_dispc(dssdev
);
4243 dsi_enable_pll_clock(dsidev
, 0);
4244 dsi_runtime_put(dsidev
);
4246 omap_dss_stop_device(dssdev
);
4248 mutex_unlock(&dsi
->lock
);
4249 DSSDBG("dsi_display_enable FAILED\n");
4252 EXPORT_SYMBOL(omapdss_dsi_display_enable
);
4254 void omapdss_dsi_display_disable(struct omap_dss_device
*dssdev
,
4255 bool disconnect_lanes
, bool enter_ulps
)
4257 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4258 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4260 DSSDBG("dsi_display_disable\n");
4262 WARN_ON(!dsi_bus_is_locked(dsidev
));
4264 mutex_lock(&dsi
->lock
);
4266 dsi_sync_vc(dsidev
, 0);
4267 dsi_sync_vc(dsidev
, 1);
4268 dsi_sync_vc(dsidev
, 2);
4269 dsi_sync_vc(dsidev
, 3);
4271 dsi_display_uninit_dispc(dssdev
);
4273 dsi_display_uninit_dsi(dssdev
, disconnect_lanes
, enter_ulps
);
4275 dsi_runtime_put(dsidev
);
4276 dsi_enable_pll_clock(dsidev
, 0);
4278 omap_dss_stop_device(dssdev
);
4280 mutex_unlock(&dsi
->lock
);
4282 EXPORT_SYMBOL(omapdss_dsi_display_disable
);
4284 int omapdss_dsi_enable_te(struct omap_dss_device
*dssdev
, bool enable
)
4286 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4287 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4289 dsi
->te_enabled
= enable
;
4292 EXPORT_SYMBOL(omapdss_dsi_enable_te
);
4294 void dsi_get_overlay_fifo_thresholds(enum omap_plane plane
,
4295 u32 fifo_size
, u32 burst_size
,
4296 u32
*fifo_low
, u32
*fifo_high
)
4298 *fifo_high
= fifo_size
- burst_size
;
4299 *fifo_low
= fifo_size
- burst_size
* 2;
4302 int dsi_init_display(struct omap_dss_device
*dssdev
)
4304 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4305 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4306 int dsi_module
= dsi_get_dsidev_id(dsidev
);
4308 DSSDBG("DSI init\n");
4310 /* XXX these should be figured out dynamically */
4311 dssdev
->caps
= OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
|
4312 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM
;
4314 if (dsi
->vdds_dsi_reg
== NULL
) {
4315 struct regulator
*vdds_dsi
;
4317 vdds_dsi
= regulator_get(&dsi
->pdev
->dev
, "vdds_dsi");
4319 if (IS_ERR(vdds_dsi
)) {
4320 DSSERR("can't get VDDS_DSI regulator\n");
4321 return PTR_ERR(vdds_dsi
);
4324 dsi
->vdds_dsi_reg
= vdds_dsi
;
4327 if (dsi_get_num_data_lanes_dssdev(dssdev
) > dsi
->num_data_lanes
) {
4328 DSSERR("DSI%d can't support more than %d data lanes\n",
4329 dsi_module
+ 1, dsi
->num_data_lanes
);
4336 int omap_dsi_request_vc(struct omap_dss_device
*dssdev
, int *channel
)
4338 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4339 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4342 for (i
= 0; i
< ARRAY_SIZE(dsi
->vc
); i
++) {
4343 if (!dsi
->vc
[i
].dssdev
) {
4344 dsi
->vc
[i
].dssdev
= dssdev
;
4350 DSSERR("cannot get VC for display %s", dssdev
->name
);
4353 EXPORT_SYMBOL(omap_dsi_request_vc
);
4355 int omap_dsi_set_vc_id(struct omap_dss_device
*dssdev
, int channel
, int vc_id
)
4357 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4358 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4360 if (vc_id
< 0 || vc_id
> 3) {
4361 DSSERR("VC ID out of range\n");
4365 if (channel
< 0 || channel
> 3) {
4366 DSSERR("Virtual Channel out of range\n");
4370 if (dsi
->vc
[channel
].dssdev
!= dssdev
) {
4371 DSSERR("Virtual Channel not allocated to display %s\n",
4376 dsi
->vc
[channel
].vc_id
= vc_id
;
4380 EXPORT_SYMBOL(omap_dsi_set_vc_id
);
4382 void omap_dsi_release_vc(struct omap_dss_device
*dssdev
, int channel
)
4384 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4385 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4387 if ((channel
>= 0 && channel
<= 3) &&
4388 dsi
->vc
[channel
].dssdev
== dssdev
) {
4389 dsi
->vc
[channel
].dssdev
= NULL
;
4390 dsi
->vc
[channel
].vc_id
= 0;
4393 EXPORT_SYMBOL(omap_dsi_release_vc
);
4395 void dsi_wait_pll_hsdiv_dispc_active(struct platform_device
*dsidev
)
4397 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 7, 1) != 1)
4398 DSSERR("%s (%s) not active\n",
4399 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
),
4400 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
));
4403 void dsi_wait_pll_hsdiv_dsi_active(struct platform_device
*dsidev
)
4405 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 8, 1) != 1)
4406 DSSERR("%s (%s) not active\n",
4407 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
),
4408 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
));
4411 static void dsi_calc_clock_param_ranges(struct platform_device
*dsidev
)
4413 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4415 dsi
->regn_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGN
);
4416 dsi
->regm_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM
);
4417 dsi
->regm_dispc_max
=
4418 dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DISPC
);
4419 dsi
->regm_dsi_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DSI
);
4420 dsi
->fint_min
= dss_feat_get_param_min(FEAT_PARAM_DSIPLL_FINT
);
4421 dsi
->fint_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_FINT
);
4422 dsi
->lpdiv_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_LPDIV
);
4425 static int dsi_get_clocks(struct platform_device
*dsidev
)
4427 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4430 clk
= clk_get(&dsidev
->dev
, "fck");
4432 DSSERR("can't get fck\n");
4433 return PTR_ERR(clk
);
4438 if (cpu_is_omap34xx() || cpu_is_omap3630())
4439 clk
= clk_get(&dsidev
->dev
, "dss2_alwon_fck");
4441 clk
= clk_get(&dsidev
->dev
, "sys_clk");
4443 DSSERR("can't get sys_clk\n");
4444 clk_put(dsi
->dss_clk
);
4445 dsi
->dss_clk
= NULL
;
4446 return PTR_ERR(clk
);
4454 static void dsi_put_clocks(struct platform_device
*dsidev
)
4456 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4459 clk_put(dsi
->dss_clk
);
4461 clk_put(dsi
->sys_clk
);
4464 /* DSI1 HW IP initialisation */
4465 static int omap_dsi1hw_probe(struct platform_device
*dsidev
)
4467 struct omap_display_platform_data
*dss_plat_data
;
4468 struct omap_dss_board_info
*board_info
;
4470 int r
, i
, dsi_module
= dsi_get_dsidev_id(dsidev
);
4471 struct resource
*dsi_mem
;
4472 struct dsi_data
*dsi
;
4474 dsi
= kzalloc(sizeof(*dsi
), GFP_KERNEL
);
4481 dsi_pdev_map
[dsi_module
] = dsidev
;
4482 dev_set_drvdata(&dsidev
->dev
, dsi
);
4484 dss_plat_data
= dsidev
->dev
.platform_data
;
4485 board_info
= dss_plat_data
->board_data
;
4486 dsi
->dsi_mux_pads
= board_info
->dsi_mux_pads
;
4488 spin_lock_init(&dsi
->irq_lock
);
4489 spin_lock_init(&dsi
->errors_lock
);
4492 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
4493 spin_lock_init(&dsi
->irq_stats_lock
);
4494 dsi
->irq_stats
.last_reset
= jiffies
;
4497 mutex_init(&dsi
->lock
);
4498 sema_init(&dsi
->bus_lock
, 1);
4500 r
= dsi_get_clocks(dsidev
);
4504 pm_runtime_enable(&dsidev
->dev
);
4506 INIT_DELAYED_WORK_DEFERRABLE(&dsi
->framedone_timeout_work
,
4507 dsi_framedone_timeout_work_callback
);
4509 #ifdef DSI_CATCH_MISSING_TE
4510 init_timer(&dsi
->te_timer
);
4511 dsi
->te_timer
.function
= dsi_te_timeout
;
4512 dsi
->te_timer
.data
= 0;
4514 dsi_mem
= platform_get_resource(dsi
->pdev
, IORESOURCE_MEM
, 0);
4516 DSSERR("can't get IORESOURCE_MEM DSI\n");
4520 dsi
->base
= ioremap(dsi_mem
->start
, resource_size(dsi_mem
));
4522 DSSERR("can't ioremap DSI\n");
4526 dsi
->irq
= platform_get_irq(dsi
->pdev
, 0);
4528 DSSERR("platform_get_irq failed\n");
4533 r
= request_irq(dsi
->irq
, omap_dsi_irq_handler
, IRQF_SHARED
,
4534 dev_name(&dsidev
->dev
), dsi
->pdev
);
4536 DSSERR("request_irq failed\n");
4540 /* DSI VCs initialization */
4541 for (i
= 0; i
< ARRAY_SIZE(dsi
->vc
); i
++) {
4542 dsi
->vc
[i
].mode
= DSI_VC_MODE_L4
;
4543 dsi
->vc
[i
].dssdev
= NULL
;
4544 dsi
->vc
[i
].vc_id
= 0;
4547 dsi_calc_clock_param_ranges(dsidev
);
4549 r
= dsi_runtime_get(dsidev
);
4553 rev
= dsi_read_reg(dsidev
, DSI_REVISION
);
4554 dev_dbg(&dsidev
->dev
, "OMAP DSI rev %d.%d\n",
4555 FLD_GET(rev
, 7, 4), FLD_GET(rev
, 3, 0));
4557 dsi
->num_data_lanes
= dsi_get_num_data_lanes(dsidev
);
4559 dsi_runtime_put(dsidev
);
4564 free_irq(dsi
->irq
, dsi
->pdev
);
4568 pm_runtime_disable(&dsidev
->dev
);
4575 static int omap_dsi1hw_remove(struct platform_device
*dsidev
)
4577 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4579 WARN_ON(dsi
->scp_clk_refcount
> 0);
4581 pm_runtime_disable(&dsidev
->dev
);
4583 dsi_put_clocks(dsidev
);
4585 if (dsi
->vdds_dsi_reg
!= NULL
) {
4586 if (dsi
->vdds_dsi_enabled
) {
4587 regulator_disable(dsi
->vdds_dsi_reg
);
4588 dsi
->vdds_dsi_enabled
= false;
4591 regulator_put(dsi
->vdds_dsi_reg
);
4592 dsi
->vdds_dsi_reg
= NULL
;
4595 free_irq(dsi
->irq
, dsi
->pdev
);
4603 static int dsi_runtime_suspend(struct device
*dev
)
4605 struct dsi_data
*dsi
= dsi_get_dsidrv_data(to_platform_device(dev
));
4607 clk_disable(dsi
->dss_clk
);
4609 dispc_runtime_put();
4615 static int dsi_runtime_resume(struct device
*dev
)
4617 struct dsi_data
*dsi
= dsi_get_dsidrv_data(to_platform_device(dev
));
4620 r
= dss_runtime_get();
4624 r
= dispc_runtime_get();
4628 clk_enable(dsi
->dss_clk
);
4638 static const struct dev_pm_ops dsi_pm_ops
= {
4639 .runtime_suspend
= dsi_runtime_suspend
,
4640 .runtime_resume
= dsi_runtime_resume
,
4643 static struct platform_driver omap_dsi1hw_driver
= {
4644 .probe
= omap_dsi1hw_probe
,
4645 .remove
= omap_dsi1hw_remove
,
4647 .name
= "omapdss_dsi1",
4648 .owner
= THIS_MODULE
,
4653 int dsi_init_platform_driver(void)
4655 return platform_driver_register(&omap_dsi1hw_driver
);
4658 void dsi_uninit_platform_driver(void)
4660 return platform_driver_unregister(&omap_dsi1hw_driver
);