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/module.h>
31 #include <linux/semaphore.h>
32 #include <linux/seq_file.h>
33 #include <linux/platform_device.h>
34 #include <linux/regulator/consumer.h>
35 #include <linux/wait.h>
36 #include <linux/workqueue.h>
37 #include <linux/sched.h>
38 #include <linux/slab.h>
39 #include <linux/debugfs.h>
40 #include <linux/pm_runtime.h>
42 #include <video/omapdss.h>
43 #include <plat/clock.h>
46 #include "dss_features.h"
48 /*#define VERBOSE_IRQ*/
49 #define DSI_CATCH_MISSING_TE
51 struct dsi_reg
{ u16 idx
; };
53 #define DSI_REG(idx) ((const struct dsi_reg) { idx })
55 #define DSI_SZ_REGS SZ_1K
56 /* DSI Protocol Engine */
58 #define DSI_REVISION DSI_REG(0x0000)
59 #define DSI_SYSCONFIG DSI_REG(0x0010)
60 #define DSI_SYSSTATUS DSI_REG(0x0014)
61 #define DSI_IRQSTATUS DSI_REG(0x0018)
62 #define DSI_IRQENABLE DSI_REG(0x001C)
63 #define DSI_CTRL DSI_REG(0x0040)
64 #define DSI_GNQ DSI_REG(0x0044)
65 #define DSI_COMPLEXIO_CFG1 DSI_REG(0x0048)
66 #define DSI_COMPLEXIO_IRQ_STATUS DSI_REG(0x004C)
67 #define DSI_COMPLEXIO_IRQ_ENABLE DSI_REG(0x0050)
68 #define DSI_CLK_CTRL DSI_REG(0x0054)
69 #define DSI_TIMING1 DSI_REG(0x0058)
70 #define DSI_TIMING2 DSI_REG(0x005C)
71 #define DSI_VM_TIMING1 DSI_REG(0x0060)
72 #define DSI_VM_TIMING2 DSI_REG(0x0064)
73 #define DSI_VM_TIMING3 DSI_REG(0x0068)
74 #define DSI_CLK_TIMING DSI_REG(0x006C)
75 #define DSI_TX_FIFO_VC_SIZE DSI_REG(0x0070)
76 #define DSI_RX_FIFO_VC_SIZE DSI_REG(0x0074)
77 #define DSI_COMPLEXIO_CFG2 DSI_REG(0x0078)
78 #define DSI_RX_FIFO_VC_FULLNESS DSI_REG(0x007C)
79 #define DSI_VM_TIMING4 DSI_REG(0x0080)
80 #define DSI_TX_FIFO_VC_EMPTINESS DSI_REG(0x0084)
81 #define DSI_VM_TIMING5 DSI_REG(0x0088)
82 #define DSI_VM_TIMING6 DSI_REG(0x008C)
83 #define DSI_VM_TIMING7 DSI_REG(0x0090)
84 #define DSI_STOPCLK_TIMING DSI_REG(0x0094)
85 #define DSI_VC_CTRL(n) DSI_REG(0x0100 + (n * 0x20))
86 #define DSI_VC_TE(n) DSI_REG(0x0104 + (n * 0x20))
87 #define DSI_VC_LONG_PACKET_HEADER(n) DSI_REG(0x0108 + (n * 0x20))
88 #define DSI_VC_LONG_PACKET_PAYLOAD(n) DSI_REG(0x010C + (n * 0x20))
89 #define DSI_VC_SHORT_PACKET_HEADER(n) DSI_REG(0x0110 + (n * 0x20))
90 #define DSI_VC_IRQSTATUS(n) DSI_REG(0x0118 + (n * 0x20))
91 #define DSI_VC_IRQENABLE(n) DSI_REG(0x011C + (n * 0x20))
95 #define DSI_DSIPHY_CFG0 DSI_REG(0x200 + 0x0000)
96 #define DSI_DSIPHY_CFG1 DSI_REG(0x200 + 0x0004)
97 #define DSI_DSIPHY_CFG2 DSI_REG(0x200 + 0x0008)
98 #define DSI_DSIPHY_CFG5 DSI_REG(0x200 + 0x0014)
99 #define DSI_DSIPHY_CFG10 DSI_REG(0x200 + 0x0028)
101 /* DSI_PLL_CTRL_SCP */
103 #define DSI_PLL_CONTROL DSI_REG(0x300 + 0x0000)
104 #define DSI_PLL_STATUS DSI_REG(0x300 + 0x0004)
105 #define DSI_PLL_GO DSI_REG(0x300 + 0x0008)
106 #define DSI_PLL_CONFIGURATION1 DSI_REG(0x300 + 0x000C)
107 #define DSI_PLL_CONFIGURATION2 DSI_REG(0x300 + 0x0010)
109 #define REG_GET(dsidev, idx, start, end) \
110 FLD_GET(dsi_read_reg(dsidev, idx), start, end)
112 #define REG_FLD_MOD(dsidev, idx, val, start, end) \
113 dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, start, end))
115 /* Global interrupts */
116 #define DSI_IRQ_VC0 (1 << 0)
117 #define DSI_IRQ_VC1 (1 << 1)
118 #define DSI_IRQ_VC2 (1 << 2)
119 #define DSI_IRQ_VC3 (1 << 3)
120 #define DSI_IRQ_WAKEUP (1 << 4)
121 #define DSI_IRQ_RESYNC (1 << 5)
122 #define DSI_IRQ_PLL_LOCK (1 << 7)
123 #define DSI_IRQ_PLL_UNLOCK (1 << 8)
124 #define DSI_IRQ_PLL_RECALL (1 << 9)
125 #define DSI_IRQ_COMPLEXIO_ERR (1 << 10)
126 #define DSI_IRQ_HS_TX_TIMEOUT (1 << 14)
127 #define DSI_IRQ_LP_RX_TIMEOUT (1 << 15)
128 #define DSI_IRQ_TE_TRIGGER (1 << 16)
129 #define DSI_IRQ_ACK_TRIGGER (1 << 17)
130 #define DSI_IRQ_SYNC_LOST (1 << 18)
131 #define DSI_IRQ_LDO_POWER_GOOD (1 << 19)
132 #define DSI_IRQ_TA_TIMEOUT (1 << 20)
133 #define DSI_IRQ_ERROR_MASK \
134 (DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \
136 #define DSI_IRQ_CHANNEL_MASK 0xf
138 /* Virtual channel interrupts */
139 #define DSI_VC_IRQ_CS (1 << 0)
140 #define DSI_VC_IRQ_ECC_CORR (1 << 1)
141 #define DSI_VC_IRQ_PACKET_SENT (1 << 2)
142 #define DSI_VC_IRQ_FIFO_TX_OVF (1 << 3)
143 #define DSI_VC_IRQ_FIFO_RX_OVF (1 << 4)
144 #define DSI_VC_IRQ_BTA (1 << 5)
145 #define DSI_VC_IRQ_ECC_NO_CORR (1 << 6)
146 #define DSI_VC_IRQ_FIFO_TX_UDF (1 << 7)
147 #define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8)
148 #define DSI_VC_IRQ_ERROR_MASK \
149 (DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \
150 DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \
151 DSI_VC_IRQ_FIFO_TX_UDF)
153 /* ComplexIO interrupts */
154 #define DSI_CIO_IRQ_ERRSYNCESC1 (1 << 0)
155 #define DSI_CIO_IRQ_ERRSYNCESC2 (1 << 1)
156 #define DSI_CIO_IRQ_ERRSYNCESC3 (1 << 2)
157 #define DSI_CIO_IRQ_ERRSYNCESC4 (1 << 3)
158 #define DSI_CIO_IRQ_ERRSYNCESC5 (1 << 4)
159 #define DSI_CIO_IRQ_ERRESC1 (1 << 5)
160 #define DSI_CIO_IRQ_ERRESC2 (1 << 6)
161 #define DSI_CIO_IRQ_ERRESC3 (1 << 7)
162 #define DSI_CIO_IRQ_ERRESC4 (1 << 8)
163 #define DSI_CIO_IRQ_ERRESC5 (1 << 9)
164 #define DSI_CIO_IRQ_ERRCONTROL1 (1 << 10)
165 #define DSI_CIO_IRQ_ERRCONTROL2 (1 << 11)
166 #define DSI_CIO_IRQ_ERRCONTROL3 (1 << 12)
167 #define DSI_CIO_IRQ_ERRCONTROL4 (1 << 13)
168 #define DSI_CIO_IRQ_ERRCONTROL5 (1 << 14)
169 #define DSI_CIO_IRQ_STATEULPS1 (1 << 15)
170 #define DSI_CIO_IRQ_STATEULPS2 (1 << 16)
171 #define DSI_CIO_IRQ_STATEULPS3 (1 << 17)
172 #define DSI_CIO_IRQ_STATEULPS4 (1 << 18)
173 #define DSI_CIO_IRQ_STATEULPS5 (1 << 19)
174 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_1 (1 << 20)
175 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_1 (1 << 21)
176 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_2 (1 << 22)
177 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_2 (1 << 23)
178 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_3 (1 << 24)
179 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_3 (1 << 25)
180 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_4 (1 << 26)
181 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_4 (1 << 27)
182 #define DSI_CIO_IRQ_ERRCONTENTIONLP0_5 (1 << 28)
183 #define DSI_CIO_IRQ_ERRCONTENTIONLP1_5 (1 << 29)
184 #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0 (1 << 30)
185 #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1 (1 << 31)
186 #define DSI_CIO_IRQ_ERROR_MASK \
187 (DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \
188 DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \
189 DSI_CIO_IRQ_ERRSYNCESC5 | \
190 DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \
191 DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \
192 DSI_CIO_IRQ_ERRESC5 | \
193 DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \
194 DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \
195 DSI_CIO_IRQ_ERRCONTROL5 | \
196 DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \
197 DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \
198 DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \
199 DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \
200 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
202 #define DSI_DT_DCS_SHORT_WRITE_0 0x05
203 #define DSI_DT_DCS_SHORT_WRITE_1 0x15
204 #define DSI_DT_DCS_READ 0x06
205 #define DSI_DT_SET_MAX_RET_PKG_SIZE 0x37
206 #define DSI_DT_NULL_PACKET 0x09
207 #define DSI_DT_DCS_LONG_WRITE 0x39
209 #define DSI_DT_RX_ACK_WITH_ERR 0x02
210 #define DSI_DT_RX_DCS_LONG_READ 0x1c
211 #define DSI_DT_RX_SHORT_READ_1 0x21
212 #define DSI_DT_RX_SHORT_READ_2 0x22
214 typedef void (*omap_dsi_isr_t
) (void *arg
, u32 mask
);
216 #define DSI_MAX_NR_ISRS 2
218 struct dsi_isr_data
{
226 DSI_FIFO_SIZE_32
= 1,
227 DSI_FIFO_SIZE_64
= 2,
228 DSI_FIFO_SIZE_96
= 3,
229 DSI_FIFO_SIZE_128
= 4,
240 DSI_DATA1_P
= 1 << 2,
241 DSI_DATA1_N
= 1 << 3,
242 DSI_DATA2_P
= 1 << 4,
243 DSI_DATA2_N
= 1 << 5,
244 DSI_DATA3_P
= 1 << 6,
245 DSI_DATA3_N
= 1 << 7,
246 DSI_DATA4_P
= 1 << 8,
247 DSI_DATA4_N
= 1 << 9,
250 struct dsi_update_region
{
252 struct omap_dss_device
*device
;
255 struct dsi_irq_stats
{
256 unsigned long last_reset
;
258 unsigned dsi_irqs
[32];
259 unsigned vc_irqs
[4][32];
260 unsigned cio_irqs
[32];
263 struct dsi_isr_tables
{
264 struct dsi_isr_data isr_table
[DSI_MAX_NR_ISRS
];
265 struct dsi_isr_data isr_table_vc
[4][DSI_MAX_NR_ISRS
];
266 struct dsi_isr_data isr_table_cio
[DSI_MAX_NR_ISRS
];
270 struct platform_device
*pdev
;
278 void (*dsi_mux_pads
)(bool enable
);
280 struct dsi_clock_info current_cinfo
;
282 bool vdds_dsi_enabled
;
283 struct regulator
*vdds_dsi_reg
;
286 enum dsi_vc_mode mode
;
287 struct omap_dss_device
*dssdev
;
288 enum fifo_size fifo_size
;
293 struct semaphore bus_lock
;
298 struct dsi_isr_tables isr_tables
;
299 /* space for a copy used by the interrupt handler */
300 struct dsi_isr_tables isr_tables_copy
;
303 struct dsi_update_region update_region
;
308 void (*framedone_callback
)(int, void *);
309 void *framedone_data
;
311 struct delayed_work framedone_timeout_work
;
313 #ifdef DSI_CATCH_MISSING_TE
314 struct timer_list te_timer
;
317 unsigned long cache_req_pck
;
318 unsigned long cache_clk_freq
;
319 struct dsi_clock_info cache_cinfo
;
322 spinlock_t errors_lock
;
324 ktime_t perf_setup_time
;
325 ktime_t perf_start_time
;
330 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
331 spinlock_t irq_stats_lock
;
332 struct dsi_irq_stats irq_stats
;
334 /* DSI PLL Parameter Ranges */
335 unsigned long regm_max
, regn_max
;
336 unsigned long regm_dispc_max
, regm_dsi_max
;
337 unsigned long fint_min
, fint_max
;
338 unsigned long lpdiv_max
;
342 unsigned scp_clk_refcount
;
345 struct dsi_packet_sent_handler_data
{
346 struct platform_device
*dsidev
;
347 struct completion
*completion
;
350 static struct platform_device
*dsi_pdev_map
[MAX_NUM_DSI
];
353 static unsigned int dsi_perf
;
354 module_param_named(dsi_perf
, dsi_perf
, bool, 0644);
357 static inline struct dsi_data
*dsi_get_dsidrv_data(struct platform_device
*dsidev
)
359 return dev_get_drvdata(&dsidev
->dev
);
362 static inline struct platform_device
*dsi_get_dsidev_from_dssdev(struct omap_dss_device
*dssdev
)
364 return dsi_pdev_map
[dssdev
->phy
.dsi
.module
];
367 struct platform_device
*dsi_get_dsidev_from_id(int module
)
369 return dsi_pdev_map
[module
];
372 static int dsi_get_dsidev_id(struct platform_device
*dsidev
)
374 /* TEMP: Pass 0 as the dsi module index till the time the dsi platform
375 * device names aren't changed to the form "omapdss_dsi.0",
376 * "omapdss_dsi.1" and so on */
377 BUG_ON(dsidev
->id
!= -1);
382 static inline void dsi_write_reg(struct platform_device
*dsidev
,
383 const struct dsi_reg idx
, u32 val
)
385 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
387 __raw_writel(val
, dsi
->base
+ idx
.idx
);
390 static inline u32
dsi_read_reg(struct platform_device
*dsidev
,
391 const struct dsi_reg idx
)
393 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
395 return __raw_readl(dsi
->base
+ idx
.idx
);
398 void dsi_bus_lock(struct omap_dss_device
*dssdev
)
400 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
401 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
403 down(&dsi
->bus_lock
);
405 EXPORT_SYMBOL(dsi_bus_lock
);
407 void dsi_bus_unlock(struct omap_dss_device
*dssdev
)
409 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
410 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
414 EXPORT_SYMBOL(dsi_bus_unlock
);
416 static bool dsi_bus_is_locked(struct platform_device
*dsidev
)
418 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
420 return dsi
->bus_lock
.count
== 0;
423 static void dsi_completion_handler(void *data
, u32 mask
)
425 complete((struct completion
*)data
);
428 static inline int wait_for_bit_change(struct platform_device
*dsidev
,
429 const struct dsi_reg idx
, int bitnum
, int value
)
433 while (REG_GET(dsidev
, idx
, bitnum
, bitnum
) != value
) {
442 static void dsi_perf_mark_setup(struct platform_device
*dsidev
)
444 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
445 dsi
->perf_setup_time
= ktime_get();
448 static void dsi_perf_mark_start(struct platform_device
*dsidev
)
450 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
451 dsi
->perf_start_time
= ktime_get();
454 static void dsi_perf_show(struct platform_device
*dsidev
, const char *name
)
456 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
457 ktime_t t
, setup_time
, trans_time
;
459 u32 setup_us
, trans_us
, total_us
;
466 setup_time
= ktime_sub(dsi
->perf_start_time
, dsi
->perf_setup_time
);
467 setup_us
= (u32
)ktime_to_us(setup_time
);
471 trans_time
= ktime_sub(t
, dsi
->perf_start_time
);
472 trans_us
= (u32
)ktime_to_us(trans_time
);
476 total_us
= setup_us
+ trans_us
;
478 total_bytes
= dsi
->update_region
.w
*
479 dsi
->update_region
.h
*
480 dsi
->update_region
.device
->ctrl
.pixel_size
/ 8;
482 printk(KERN_INFO
"DSI(%s): %u us + %u us = %u us (%uHz), "
483 "%u bytes, %u kbytes/sec\n",
488 1000*1000 / total_us
,
490 total_bytes
* 1000 / total_us
);
493 static inline void dsi_perf_mark_setup(struct platform_device
*dsidev
)
497 static inline void dsi_perf_mark_start(struct platform_device
*dsidev
)
501 static inline void dsi_perf_show(struct platform_device
*dsidev
,
507 static void print_irq_status(u32 status
)
513 if ((status
& ~DSI_IRQ_CHANNEL_MASK
) == 0)
516 printk(KERN_DEBUG
"DSI IRQ: 0x%x: ", status
);
519 if (status & DSI_IRQ_##x) \
545 static void print_irq_status_vc(int channel
, u32 status
)
551 if ((status
& ~DSI_VC_IRQ_PACKET_SENT
) == 0)
554 printk(KERN_DEBUG
"DSI VC(%d) IRQ 0x%x: ", channel
, status
);
557 if (status & DSI_VC_IRQ_##x) \
574 static void print_irq_status_cio(u32 status
)
579 printk(KERN_DEBUG
"DSI CIO IRQ 0x%x: ", status
);
582 if (status & DSI_CIO_IRQ_##x) \
596 PIS(ERRCONTENTIONLP0_1
);
597 PIS(ERRCONTENTIONLP1_1
);
598 PIS(ERRCONTENTIONLP0_2
);
599 PIS(ERRCONTENTIONLP1_2
);
600 PIS(ERRCONTENTIONLP0_3
);
601 PIS(ERRCONTENTIONLP1_3
);
602 PIS(ULPSACTIVENOT_ALL0
);
603 PIS(ULPSACTIVENOT_ALL1
);
609 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
610 static void dsi_collect_irq_stats(struct platform_device
*dsidev
, u32 irqstatus
,
611 u32
*vcstatus
, u32 ciostatus
)
613 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
616 spin_lock(&dsi
->irq_stats_lock
);
618 dsi
->irq_stats
.irq_count
++;
619 dss_collect_irq_stats(irqstatus
, dsi
->irq_stats
.dsi_irqs
);
621 for (i
= 0; i
< 4; ++i
)
622 dss_collect_irq_stats(vcstatus
[i
], dsi
->irq_stats
.vc_irqs
[i
]);
624 dss_collect_irq_stats(ciostatus
, dsi
->irq_stats
.cio_irqs
);
626 spin_unlock(&dsi
->irq_stats_lock
);
629 #define dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus)
632 static int debug_irq
;
634 static void dsi_handle_irq_errors(struct platform_device
*dsidev
, u32 irqstatus
,
635 u32
*vcstatus
, u32 ciostatus
)
637 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
640 if (irqstatus
& DSI_IRQ_ERROR_MASK
) {
641 DSSERR("DSI error, irqstatus %x\n", irqstatus
);
642 print_irq_status(irqstatus
);
643 spin_lock(&dsi
->errors_lock
);
644 dsi
->errors
|= irqstatus
& DSI_IRQ_ERROR_MASK
;
645 spin_unlock(&dsi
->errors_lock
);
646 } else if (debug_irq
) {
647 print_irq_status(irqstatus
);
650 for (i
= 0; i
< 4; ++i
) {
651 if (vcstatus
[i
] & DSI_VC_IRQ_ERROR_MASK
) {
652 DSSERR("DSI VC(%d) error, vc irqstatus %x\n",
654 print_irq_status_vc(i
, vcstatus
[i
]);
655 } else if (debug_irq
) {
656 print_irq_status_vc(i
, vcstatus
[i
]);
660 if (ciostatus
& DSI_CIO_IRQ_ERROR_MASK
) {
661 DSSERR("DSI CIO error, cio irqstatus %x\n", ciostatus
);
662 print_irq_status_cio(ciostatus
);
663 } else if (debug_irq
) {
664 print_irq_status_cio(ciostatus
);
668 static void dsi_call_isrs(struct dsi_isr_data
*isr_array
,
669 unsigned isr_array_size
, u32 irqstatus
)
671 struct dsi_isr_data
*isr_data
;
674 for (i
= 0; i
< isr_array_size
; i
++) {
675 isr_data
= &isr_array
[i
];
676 if (isr_data
->isr
&& isr_data
->mask
& irqstatus
)
677 isr_data
->isr(isr_data
->arg
, irqstatus
);
681 static void dsi_handle_isrs(struct dsi_isr_tables
*isr_tables
,
682 u32 irqstatus
, u32
*vcstatus
, u32 ciostatus
)
686 dsi_call_isrs(isr_tables
->isr_table
,
687 ARRAY_SIZE(isr_tables
->isr_table
),
690 for (i
= 0; i
< 4; ++i
) {
691 if (vcstatus
[i
] == 0)
693 dsi_call_isrs(isr_tables
->isr_table_vc
[i
],
694 ARRAY_SIZE(isr_tables
->isr_table_vc
[i
]),
699 dsi_call_isrs(isr_tables
->isr_table_cio
,
700 ARRAY_SIZE(isr_tables
->isr_table_cio
),
704 static irqreturn_t
omap_dsi_irq_handler(int irq
, void *arg
)
706 struct platform_device
*dsidev
;
707 struct dsi_data
*dsi
;
708 u32 irqstatus
, vcstatus
[4], ciostatus
;
711 dsidev
= (struct platform_device
*) arg
;
712 dsi
= dsi_get_dsidrv_data(dsidev
);
714 spin_lock(&dsi
->irq_lock
);
716 irqstatus
= dsi_read_reg(dsidev
, DSI_IRQSTATUS
);
718 /* IRQ is not for us */
720 spin_unlock(&dsi
->irq_lock
);
724 dsi_write_reg(dsidev
, DSI_IRQSTATUS
, irqstatus
& ~DSI_IRQ_CHANNEL_MASK
);
725 /* flush posted write */
726 dsi_read_reg(dsidev
, DSI_IRQSTATUS
);
728 for (i
= 0; i
< 4; ++i
) {
729 if ((irqstatus
& (1 << i
)) == 0) {
734 vcstatus
[i
] = dsi_read_reg(dsidev
, DSI_VC_IRQSTATUS(i
));
736 dsi_write_reg(dsidev
, DSI_VC_IRQSTATUS(i
), vcstatus
[i
]);
737 /* flush posted write */
738 dsi_read_reg(dsidev
, DSI_VC_IRQSTATUS(i
));
741 if (irqstatus
& DSI_IRQ_COMPLEXIO_ERR
) {
742 ciostatus
= dsi_read_reg(dsidev
, DSI_COMPLEXIO_IRQ_STATUS
);
744 dsi_write_reg(dsidev
, DSI_COMPLEXIO_IRQ_STATUS
, ciostatus
);
745 /* flush posted write */
746 dsi_read_reg(dsidev
, DSI_COMPLEXIO_IRQ_STATUS
);
751 #ifdef DSI_CATCH_MISSING_TE
752 if (irqstatus
& DSI_IRQ_TE_TRIGGER
)
753 del_timer(&dsi
->te_timer
);
756 /* make a copy and unlock, so that isrs can unregister
758 memcpy(&dsi
->isr_tables_copy
, &dsi
->isr_tables
,
759 sizeof(dsi
->isr_tables
));
761 spin_unlock(&dsi
->irq_lock
);
763 dsi_handle_isrs(&dsi
->isr_tables_copy
, irqstatus
, vcstatus
, ciostatus
);
765 dsi_handle_irq_errors(dsidev
, irqstatus
, vcstatus
, ciostatus
);
767 dsi_collect_irq_stats(dsidev
, irqstatus
, vcstatus
, ciostatus
);
772 /* dsi->irq_lock has to be locked by the caller */
773 static void _omap_dsi_configure_irqs(struct platform_device
*dsidev
,
774 struct dsi_isr_data
*isr_array
,
775 unsigned isr_array_size
, u32 default_mask
,
776 const struct dsi_reg enable_reg
,
777 const struct dsi_reg status_reg
)
779 struct dsi_isr_data
*isr_data
;
786 for (i
= 0; i
< isr_array_size
; i
++) {
787 isr_data
= &isr_array
[i
];
789 if (isr_data
->isr
== NULL
)
792 mask
|= isr_data
->mask
;
795 old_mask
= dsi_read_reg(dsidev
, enable_reg
);
796 /* clear the irqstatus for newly enabled irqs */
797 dsi_write_reg(dsidev
, status_reg
, (mask
^ old_mask
) & mask
);
798 dsi_write_reg(dsidev
, enable_reg
, mask
);
800 /* flush posted writes */
801 dsi_read_reg(dsidev
, enable_reg
);
802 dsi_read_reg(dsidev
, status_reg
);
805 /* dsi->irq_lock has to be locked by the caller */
806 static void _omap_dsi_set_irqs(struct platform_device
*dsidev
)
808 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
809 u32 mask
= DSI_IRQ_ERROR_MASK
;
810 #ifdef DSI_CATCH_MISSING_TE
811 mask
|= DSI_IRQ_TE_TRIGGER
;
813 _omap_dsi_configure_irqs(dsidev
, dsi
->isr_tables
.isr_table
,
814 ARRAY_SIZE(dsi
->isr_tables
.isr_table
), mask
,
815 DSI_IRQENABLE
, DSI_IRQSTATUS
);
818 /* dsi->irq_lock has to be locked by the caller */
819 static void _omap_dsi_set_irqs_vc(struct platform_device
*dsidev
, int vc
)
821 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
823 _omap_dsi_configure_irqs(dsidev
, dsi
->isr_tables
.isr_table_vc
[vc
],
824 ARRAY_SIZE(dsi
->isr_tables
.isr_table_vc
[vc
]),
825 DSI_VC_IRQ_ERROR_MASK
,
826 DSI_VC_IRQENABLE(vc
), DSI_VC_IRQSTATUS(vc
));
829 /* dsi->irq_lock has to be locked by the caller */
830 static void _omap_dsi_set_irqs_cio(struct platform_device
*dsidev
)
832 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
834 _omap_dsi_configure_irqs(dsidev
, dsi
->isr_tables
.isr_table_cio
,
835 ARRAY_SIZE(dsi
->isr_tables
.isr_table_cio
),
836 DSI_CIO_IRQ_ERROR_MASK
,
837 DSI_COMPLEXIO_IRQ_ENABLE
, DSI_COMPLEXIO_IRQ_STATUS
);
840 static void _dsi_initialize_irq(struct platform_device
*dsidev
)
842 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
846 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
848 memset(&dsi
->isr_tables
, 0, sizeof(dsi
->isr_tables
));
850 _omap_dsi_set_irqs(dsidev
);
851 for (vc
= 0; vc
< 4; ++vc
)
852 _omap_dsi_set_irqs_vc(dsidev
, vc
);
853 _omap_dsi_set_irqs_cio(dsidev
);
855 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
858 static int _dsi_register_isr(omap_dsi_isr_t isr
, void *arg
, u32 mask
,
859 struct dsi_isr_data
*isr_array
, unsigned isr_array_size
)
861 struct dsi_isr_data
*isr_data
;
867 /* check for duplicate entry and find a free slot */
869 for (i
= 0; i
< isr_array_size
; i
++) {
870 isr_data
= &isr_array
[i
];
872 if (isr_data
->isr
== isr
&& isr_data
->arg
== arg
&&
873 isr_data
->mask
== mask
) {
877 if (isr_data
->isr
== NULL
&& free_idx
== -1)
884 isr_data
= &isr_array
[free_idx
];
887 isr_data
->mask
= mask
;
892 static int _dsi_unregister_isr(omap_dsi_isr_t isr
, void *arg
, u32 mask
,
893 struct dsi_isr_data
*isr_array
, unsigned isr_array_size
)
895 struct dsi_isr_data
*isr_data
;
898 for (i
= 0; i
< isr_array_size
; i
++) {
899 isr_data
= &isr_array
[i
];
900 if (isr_data
->isr
!= isr
|| isr_data
->arg
!= arg
||
901 isr_data
->mask
!= mask
)
904 isr_data
->isr
= NULL
;
905 isr_data
->arg
= NULL
;
914 static int dsi_register_isr(struct platform_device
*dsidev
, omap_dsi_isr_t isr
,
917 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
921 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
923 r
= _dsi_register_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table
,
924 ARRAY_SIZE(dsi
->isr_tables
.isr_table
));
927 _omap_dsi_set_irqs(dsidev
);
929 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
934 static int dsi_unregister_isr(struct platform_device
*dsidev
,
935 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
937 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
941 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
943 r
= _dsi_unregister_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table
,
944 ARRAY_SIZE(dsi
->isr_tables
.isr_table
));
947 _omap_dsi_set_irqs(dsidev
);
949 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
954 static int dsi_register_isr_vc(struct platform_device
*dsidev
, int channel
,
955 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
957 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
961 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
963 r
= _dsi_register_isr(isr
, arg
, mask
,
964 dsi
->isr_tables
.isr_table_vc
[channel
],
965 ARRAY_SIZE(dsi
->isr_tables
.isr_table_vc
[channel
]));
968 _omap_dsi_set_irqs_vc(dsidev
, channel
);
970 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
975 static int dsi_unregister_isr_vc(struct platform_device
*dsidev
, int channel
,
976 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
978 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
982 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
984 r
= _dsi_unregister_isr(isr
, arg
, mask
,
985 dsi
->isr_tables
.isr_table_vc
[channel
],
986 ARRAY_SIZE(dsi
->isr_tables
.isr_table_vc
[channel
]));
989 _omap_dsi_set_irqs_vc(dsidev
, channel
);
991 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
996 static int dsi_register_isr_cio(struct platform_device
*dsidev
,
997 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
999 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1000 unsigned long flags
;
1003 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
1005 r
= _dsi_register_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table_cio
,
1006 ARRAY_SIZE(dsi
->isr_tables
.isr_table_cio
));
1009 _omap_dsi_set_irqs_cio(dsidev
);
1011 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
1016 static int dsi_unregister_isr_cio(struct platform_device
*dsidev
,
1017 omap_dsi_isr_t isr
, void *arg
, u32 mask
)
1019 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1020 unsigned long flags
;
1023 spin_lock_irqsave(&dsi
->irq_lock
, flags
);
1025 r
= _dsi_unregister_isr(isr
, arg
, mask
, dsi
->isr_tables
.isr_table_cio
,
1026 ARRAY_SIZE(dsi
->isr_tables
.isr_table_cio
));
1029 _omap_dsi_set_irqs_cio(dsidev
);
1031 spin_unlock_irqrestore(&dsi
->irq_lock
, flags
);
1036 static u32
dsi_get_errors(struct platform_device
*dsidev
)
1038 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1039 unsigned long flags
;
1041 spin_lock_irqsave(&dsi
->errors_lock
, flags
);
1044 spin_unlock_irqrestore(&dsi
->errors_lock
, flags
);
1048 int dsi_runtime_get(struct platform_device
*dsidev
)
1051 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1053 DSSDBG("dsi_runtime_get\n");
1055 r
= pm_runtime_get_sync(&dsi
->pdev
->dev
);
1057 return r
< 0 ? r
: 0;
1060 void dsi_runtime_put(struct platform_device
*dsidev
)
1062 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1065 DSSDBG("dsi_runtime_put\n");
1067 r
= pm_runtime_put(&dsi
->pdev
->dev
);
1071 /* source clock for DSI PLL. this could also be PCLKFREE */
1072 static inline void dsi_enable_pll_clock(struct platform_device
*dsidev
,
1075 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1078 clk_enable(dsi
->sys_clk
);
1080 clk_disable(dsi
->sys_clk
);
1082 if (enable
&& dsi
->pll_locked
) {
1083 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 1, 1) != 1)
1084 DSSERR("cannot lock PLL when enabling clocks\n");
1089 static void _dsi_print_reset_status(struct platform_device
*dsidev
)
1097 /* A dummy read using the SCP interface to any DSIPHY register is
1098 * required after DSIPHY reset to complete the reset of the DSI complex
1100 l
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
1102 printk(KERN_DEBUG
"DSI resets: ");
1104 l
= dsi_read_reg(dsidev
, DSI_PLL_STATUS
);
1105 printk("PLL (%d) ", FLD_GET(l
, 0, 0));
1107 l
= dsi_read_reg(dsidev
, DSI_COMPLEXIO_CFG1
);
1108 printk("CIO (%d) ", FLD_GET(l
, 29, 29));
1110 if (dss_has_feature(FEAT_DSI_REVERSE_TXCLKESC
)) {
1120 l
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
1121 printk("PHY (%x%x%x, %d, %d, %d)\n",
1127 FLD_GET(l
, 31, 31));
1130 #define _dsi_print_reset_status(x)
1133 static inline int dsi_if_enable(struct platform_device
*dsidev
, bool enable
)
1135 DSSDBG("dsi_if_enable(%d)\n", enable
);
1137 enable
= enable
? 1 : 0;
1138 REG_FLD_MOD(dsidev
, DSI_CTRL
, enable
, 0, 0); /* IF_EN */
1140 if (wait_for_bit_change(dsidev
, DSI_CTRL
, 0, enable
) != enable
) {
1141 DSSERR("Failed to set dsi_if_enable to %d\n", enable
);
1148 unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device
*dsidev
)
1150 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1152 return dsi
->current_cinfo
.dsi_pll_hsdiv_dispc_clk
;
1155 static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device
*dsidev
)
1157 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1159 return dsi
->current_cinfo
.dsi_pll_hsdiv_dsi_clk
;
1162 static unsigned long dsi_get_txbyteclkhs(struct platform_device
*dsidev
)
1164 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1166 return dsi
->current_cinfo
.clkin4ddr
/ 16;
1169 static unsigned long dsi_fclk_rate(struct platform_device
*dsidev
)
1172 int dsi_module
= dsi_get_dsidev_id(dsidev
);
1173 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1175 if (dss_get_dsi_clk_source(dsi_module
) == OMAP_DSS_CLK_SRC_FCK
) {
1176 /* DSI FCLK source is DSS_CLK_FCK */
1177 r
= clk_get_rate(dsi
->dss_clk
);
1179 /* DSI FCLK source is dsi_pll_hsdiv_dsi_clk */
1180 r
= dsi_get_pll_hsdiv_dsi_rate(dsidev
);
1186 static int dsi_set_lp_clk_divisor(struct omap_dss_device
*dssdev
)
1188 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
1189 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1190 unsigned long dsi_fclk
;
1191 unsigned lp_clk_div
;
1192 unsigned long lp_clk
;
1194 lp_clk_div
= dssdev
->clocks
.dsi
.lp_clk_div
;
1196 if (lp_clk_div
== 0 || lp_clk_div
> dsi
->lpdiv_max
)
1199 dsi_fclk
= dsi_fclk_rate(dsidev
);
1201 lp_clk
= dsi_fclk
/ 2 / lp_clk_div
;
1203 DSSDBG("LP_CLK_DIV %u, LP_CLK %lu\n", lp_clk_div
, lp_clk
);
1204 dsi
->current_cinfo
.lp_clk
= lp_clk
;
1205 dsi
->current_cinfo
.lp_clk_div
= lp_clk_div
;
1207 /* LP_CLK_DIVISOR */
1208 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, lp_clk_div
, 12, 0);
1210 /* LP_RX_SYNCHRO_ENABLE */
1211 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, dsi_fclk
> 30000000 ? 1 : 0, 21, 21);
1216 static void dsi_enable_scp_clk(struct platform_device
*dsidev
)
1218 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1220 if (dsi
->scp_clk_refcount
++ == 0)
1221 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 1, 14, 14); /* CIO_CLK_ICG */
1224 static void dsi_disable_scp_clk(struct platform_device
*dsidev
)
1226 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1228 WARN_ON(dsi
->scp_clk_refcount
== 0);
1229 if (--dsi
->scp_clk_refcount
== 0)
1230 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 0, 14, 14); /* CIO_CLK_ICG */
1233 enum dsi_pll_power_state
{
1234 DSI_PLL_POWER_OFF
= 0x0,
1235 DSI_PLL_POWER_ON_HSCLK
= 0x1,
1236 DSI_PLL_POWER_ON_ALL
= 0x2,
1237 DSI_PLL_POWER_ON_DIV
= 0x3,
1240 static int dsi_pll_power(struct platform_device
*dsidev
,
1241 enum dsi_pll_power_state state
)
1245 /* DSI-PLL power command 0x3 is not working */
1246 if (dss_has_feature(FEAT_DSI_PLL_PWR_BUG
) &&
1247 state
== DSI_PLL_POWER_ON_DIV
)
1248 state
= DSI_PLL_POWER_ON_ALL
;
1251 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, state
, 31, 30);
1253 /* PLL_PWR_STATUS */
1254 while (FLD_GET(dsi_read_reg(dsidev
, DSI_CLK_CTRL
), 29, 28) != state
) {
1256 DSSERR("Failed to set DSI PLL power mode to %d\n",
1266 /* calculate clock rates using dividers in cinfo */
1267 static int dsi_calc_clock_rates(struct omap_dss_device
*dssdev
,
1268 struct dsi_clock_info
*cinfo
)
1270 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
1271 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1273 if (cinfo
->regn
== 0 || cinfo
->regn
> dsi
->regn_max
)
1276 if (cinfo
->regm
== 0 || cinfo
->regm
> dsi
->regm_max
)
1279 if (cinfo
->regm_dispc
> dsi
->regm_dispc_max
)
1282 if (cinfo
->regm_dsi
> dsi
->regm_dsi_max
)
1285 if (cinfo
->use_sys_clk
) {
1286 cinfo
->clkin
= clk_get_rate(dsi
->sys_clk
);
1287 /* XXX it is unclear if highfreq should be used
1288 * with DSS_SYS_CLK source also */
1289 cinfo
->highfreq
= 0;
1291 cinfo
->clkin
= dispc_pclk_rate(dssdev
->manager
->id
);
1293 if (cinfo
->clkin
< 32000000)
1294 cinfo
->highfreq
= 0;
1296 cinfo
->highfreq
= 1;
1299 cinfo
->fint
= cinfo
->clkin
/ (cinfo
->regn
* (cinfo
->highfreq
? 2 : 1));
1301 if (cinfo
->fint
> dsi
->fint_max
|| cinfo
->fint
< dsi
->fint_min
)
1304 cinfo
->clkin4ddr
= 2 * cinfo
->regm
* cinfo
->fint
;
1306 if (cinfo
->clkin4ddr
> 1800 * 1000 * 1000)
1309 if (cinfo
->regm_dispc
> 0)
1310 cinfo
->dsi_pll_hsdiv_dispc_clk
=
1311 cinfo
->clkin4ddr
/ cinfo
->regm_dispc
;
1313 cinfo
->dsi_pll_hsdiv_dispc_clk
= 0;
1315 if (cinfo
->regm_dsi
> 0)
1316 cinfo
->dsi_pll_hsdiv_dsi_clk
=
1317 cinfo
->clkin4ddr
/ cinfo
->regm_dsi
;
1319 cinfo
->dsi_pll_hsdiv_dsi_clk
= 0;
1324 int dsi_pll_calc_clock_div_pck(struct platform_device
*dsidev
, bool is_tft
,
1325 unsigned long req_pck
, struct dsi_clock_info
*dsi_cinfo
,
1326 struct dispc_clock_info
*dispc_cinfo
)
1328 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1329 struct dsi_clock_info cur
, best
;
1330 struct dispc_clock_info best_dispc
;
1331 int min_fck_per_pck
;
1333 unsigned long dss_sys_clk
, max_dss_fck
;
1335 dss_sys_clk
= clk_get_rate(dsi
->sys_clk
);
1337 max_dss_fck
= dss_feat_get_param_max(FEAT_PARAM_DSS_FCK
);
1339 if (req_pck
== dsi
->cache_req_pck
&&
1340 dsi
->cache_cinfo
.clkin
== dss_sys_clk
) {
1341 DSSDBG("DSI clock info found from cache\n");
1342 *dsi_cinfo
= dsi
->cache_cinfo
;
1343 dispc_find_clk_divs(is_tft
, req_pck
,
1344 dsi_cinfo
->dsi_pll_hsdiv_dispc_clk
, dispc_cinfo
);
1348 min_fck_per_pck
= CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK
;
1350 if (min_fck_per_pck
&&
1351 req_pck
* min_fck_per_pck
> max_dss_fck
) {
1352 DSSERR("Requested pixel clock not possible with the current "
1353 "OMAP2_DSS_MIN_FCK_PER_PCK setting. Turning "
1354 "the constraint off.\n");
1355 min_fck_per_pck
= 0;
1358 DSSDBG("dsi_pll_calc\n");
1361 memset(&best
, 0, sizeof(best
));
1362 memset(&best_dispc
, 0, sizeof(best_dispc
));
1364 memset(&cur
, 0, sizeof(cur
));
1365 cur
.clkin
= dss_sys_clk
;
1366 cur
.use_sys_clk
= 1;
1369 /* no highfreq: 0.75MHz < Fint = clkin / regn < 2.1MHz */
1370 /* highfreq: 0.75MHz < Fint = clkin / (2*regn) < 2.1MHz */
1371 /* To reduce PLL lock time, keep Fint high (around 2 MHz) */
1372 for (cur
.regn
= 1; cur
.regn
< dsi
->regn_max
; ++cur
.regn
) {
1373 if (cur
.highfreq
== 0)
1374 cur
.fint
= cur
.clkin
/ cur
.regn
;
1376 cur
.fint
= cur
.clkin
/ (2 * cur
.regn
);
1378 if (cur
.fint
> dsi
->fint_max
|| cur
.fint
< dsi
->fint_min
)
1381 /* DSIPHY(MHz) = (2 * regm / regn) * (clkin / (highfreq + 1)) */
1382 for (cur
.regm
= 1; cur
.regm
< dsi
->regm_max
; ++cur
.regm
) {
1385 a
= 2 * cur
.regm
* (cur
.clkin
/1000);
1386 b
= cur
.regn
* (cur
.highfreq
+ 1);
1387 cur
.clkin4ddr
= a
/ b
* 1000;
1389 if (cur
.clkin4ddr
> 1800 * 1000 * 1000)
1392 /* dsi_pll_hsdiv_dispc_clk(MHz) =
1393 * DSIPHY(MHz) / regm_dispc < 173MHz/186Mhz */
1394 for (cur
.regm_dispc
= 1; cur
.regm_dispc
<
1395 dsi
->regm_dispc_max
; ++cur
.regm_dispc
) {
1396 struct dispc_clock_info cur_dispc
;
1397 cur
.dsi_pll_hsdiv_dispc_clk
=
1398 cur
.clkin4ddr
/ cur
.regm_dispc
;
1400 /* this will narrow down the search a bit,
1401 * but still give pixclocks below what was
1403 if (cur
.dsi_pll_hsdiv_dispc_clk
< req_pck
)
1406 if (cur
.dsi_pll_hsdiv_dispc_clk
> max_dss_fck
)
1409 if (min_fck_per_pck
&&
1410 cur
.dsi_pll_hsdiv_dispc_clk
<
1411 req_pck
* min_fck_per_pck
)
1416 dispc_find_clk_divs(is_tft
, req_pck
,
1417 cur
.dsi_pll_hsdiv_dispc_clk
,
1420 if (abs(cur_dispc
.pck
- req_pck
) <
1421 abs(best_dispc
.pck
- req_pck
)) {
1423 best_dispc
= cur_dispc
;
1425 if (cur_dispc
.pck
== req_pck
)
1433 if (min_fck_per_pck
) {
1434 DSSERR("Could not find suitable clock settings.\n"
1435 "Turning FCK/PCK constraint off and"
1437 min_fck_per_pck
= 0;
1441 DSSERR("Could not find suitable clock settings.\n");
1446 /* dsi_pll_hsdiv_dsi_clk (regm_dsi) is not used */
1448 best
.dsi_pll_hsdiv_dsi_clk
= 0;
1453 *dispc_cinfo
= best_dispc
;
1455 dsi
->cache_req_pck
= req_pck
;
1456 dsi
->cache_clk_freq
= 0;
1457 dsi
->cache_cinfo
= best
;
1462 int dsi_pll_set_clock_div(struct platform_device
*dsidev
,
1463 struct dsi_clock_info
*cinfo
)
1465 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1469 u8 regn_start
, regn_end
, regm_start
, regm_end
;
1470 u8 regm_dispc_start
, regm_dispc_end
, regm_dsi_start
, regm_dsi_end
;
1474 dsi
->current_cinfo
.use_sys_clk
= cinfo
->use_sys_clk
;
1475 dsi
->current_cinfo
.highfreq
= cinfo
->highfreq
;
1477 dsi
->current_cinfo
.fint
= cinfo
->fint
;
1478 dsi
->current_cinfo
.clkin4ddr
= cinfo
->clkin4ddr
;
1479 dsi
->current_cinfo
.dsi_pll_hsdiv_dispc_clk
=
1480 cinfo
->dsi_pll_hsdiv_dispc_clk
;
1481 dsi
->current_cinfo
.dsi_pll_hsdiv_dsi_clk
=
1482 cinfo
->dsi_pll_hsdiv_dsi_clk
;
1484 dsi
->current_cinfo
.regn
= cinfo
->regn
;
1485 dsi
->current_cinfo
.regm
= cinfo
->regm
;
1486 dsi
->current_cinfo
.regm_dispc
= cinfo
->regm_dispc
;
1487 dsi
->current_cinfo
.regm_dsi
= cinfo
->regm_dsi
;
1489 DSSDBG("DSI Fint %ld\n", cinfo
->fint
);
1491 DSSDBG("clkin (%s) rate %ld, highfreq %d\n",
1492 cinfo
->use_sys_clk
? "dss_sys_clk" : "pclkfree",
1496 /* DSIPHY == CLKIN4DDR */
1497 DSSDBG("CLKIN4DDR = 2 * %d / %d * %lu / %d = %lu\n",
1501 cinfo
->highfreq
+ 1,
1504 DSSDBG("Data rate on 1 DSI lane %ld Mbps\n",
1505 cinfo
->clkin4ddr
/ 1000 / 1000 / 2);
1507 DSSDBG("Clock lane freq %ld Hz\n", cinfo
->clkin4ddr
/ 4);
1509 DSSDBG("regm_dispc = %d, %s (%s) = %lu\n", cinfo
->regm_dispc
,
1510 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
),
1511 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
),
1512 cinfo
->dsi_pll_hsdiv_dispc_clk
);
1513 DSSDBG("regm_dsi = %d, %s (%s) = %lu\n", cinfo
->regm_dsi
,
1514 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
),
1515 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
),
1516 cinfo
->dsi_pll_hsdiv_dsi_clk
);
1518 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGN
, ®n_start
, ®n_end
);
1519 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM
, ®m_start
, ®m_end
);
1520 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DISPC
, ®m_dispc_start
,
1522 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DSI
, ®m_dsi_start
,
1525 /* DSI_PLL_AUTOMODE = manual */
1526 REG_FLD_MOD(dsidev
, DSI_PLL_CONTROL
, 0, 0, 0);
1528 l
= dsi_read_reg(dsidev
, DSI_PLL_CONFIGURATION1
);
1529 l
= FLD_MOD(l
, 1, 0, 0); /* DSI_PLL_STOPMODE */
1531 l
= FLD_MOD(l
, cinfo
->regn
- 1, regn_start
, regn_end
);
1533 l
= FLD_MOD(l
, cinfo
->regm
, regm_start
, regm_end
);
1535 l
= FLD_MOD(l
, cinfo
->regm_dispc
> 0 ? cinfo
->regm_dispc
- 1 : 0,
1536 regm_dispc_start
, regm_dispc_end
);
1537 /* DSIPROTO_CLOCK_DIV */
1538 l
= FLD_MOD(l
, cinfo
->regm_dsi
> 0 ? cinfo
->regm_dsi
- 1 : 0,
1539 regm_dsi_start
, regm_dsi_end
);
1540 dsi_write_reg(dsidev
, DSI_PLL_CONFIGURATION1
, l
);
1542 BUG_ON(cinfo
->fint
< dsi
->fint_min
|| cinfo
->fint
> dsi
->fint_max
);
1544 if (dss_has_feature(FEAT_DSI_PLL_FREQSEL
)) {
1545 f
= cinfo
->fint
< 1000000 ? 0x3 :
1546 cinfo
->fint
< 1250000 ? 0x4 :
1547 cinfo
->fint
< 1500000 ? 0x5 :
1548 cinfo
->fint
< 1750000 ? 0x6 :
1552 l
= dsi_read_reg(dsidev
, DSI_PLL_CONFIGURATION2
);
1554 if (dss_has_feature(FEAT_DSI_PLL_FREQSEL
))
1555 l
= FLD_MOD(l
, f
, 4, 1); /* DSI_PLL_FREQSEL */
1556 l
= FLD_MOD(l
, cinfo
->use_sys_clk
? 0 : 1,
1557 11, 11); /* DSI_PLL_CLKSEL */
1558 l
= FLD_MOD(l
, cinfo
->highfreq
,
1559 12, 12); /* DSI_PLL_HIGHFREQ */
1560 l
= FLD_MOD(l
, 1, 13, 13); /* DSI_PLL_REFEN */
1561 l
= FLD_MOD(l
, 0, 14, 14); /* DSIPHY_CLKINEN */
1562 l
= FLD_MOD(l
, 1, 20, 20); /* DSI_HSDIVBYPASS */
1563 dsi_write_reg(dsidev
, DSI_PLL_CONFIGURATION2
, l
);
1565 REG_FLD_MOD(dsidev
, DSI_PLL_GO
, 1, 0, 0); /* DSI_PLL_GO */
1567 if (wait_for_bit_change(dsidev
, DSI_PLL_GO
, 0, 0) != 0) {
1568 DSSERR("dsi pll go bit not going down.\n");
1573 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 1, 1) != 1) {
1574 DSSERR("cannot lock PLL\n");
1579 dsi
->pll_locked
= 1;
1581 l
= dsi_read_reg(dsidev
, DSI_PLL_CONFIGURATION2
);
1582 l
= FLD_MOD(l
, 0, 0, 0); /* DSI_PLL_IDLE */
1583 l
= FLD_MOD(l
, 0, 5, 5); /* DSI_PLL_PLLLPMODE */
1584 l
= FLD_MOD(l
, 0, 6, 6); /* DSI_PLL_LOWCURRSTBY */
1585 l
= FLD_MOD(l
, 0, 7, 7); /* DSI_PLL_TIGHTPHASELOCK */
1586 l
= FLD_MOD(l
, 0, 8, 8); /* DSI_PLL_DRIFTGUARDEN */
1587 l
= FLD_MOD(l
, 0, 10, 9); /* DSI_PLL_LOCKSEL */
1588 l
= FLD_MOD(l
, 1, 13, 13); /* DSI_PLL_REFEN */
1589 l
= FLD_MOD(l
, 1, 14, 14); /* DSIPHY_CLKINEN */
1590 l
= FLD_MOD(l
, 0, 15, 15); /* DSI_BYPASSEN */
1591 l
= FLD_MOD(l
, 1, 16, 16); /* DSS_CLOCK_EN */
1592 l
= FLD_MOD(l
, 0, 17, 17); /* DSS_CLOCK_PWDN */
1593 l
= FLD_MOD(l
, 1, 18, 18); /* DSI_PROTO_CLOCK_EN */
1594 l
= FLD_MOD(l
, 0, 19, 19); /* DSI_PROTO_CLOCK_PWDN */
1595 l
= FLD_MOD(l
, 0, 20, 20); /* DSI_HSDIVBYPASS */
1596 dsi_write_reg(dsidev
, DSI_PLL_CONFIGURATION2
, l
);
1598 DSSDBG("PLL config done\n");
1603 int dsi_pll_init(struct platform_device
*dsidev
, bool enable_hsclk
,
1606 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1608 enum dsi_pll_power_state pwstate
;
1610 DSSDBG("PLL init\n");
1612 if (dsi
->vdds_dsi_reg
== NULL
) {
1613 struct regulator
*vdds_dsi
;
1615 vdds_dsi
= regulator_get(&dsi
->pdev
->dev
, "vdds_dsi");
1617 if (IS_ERR(vdds_dsi
)) {
1618 DSSERR("can't get VDDS_DSI regulator\n");
1619 return PTR_ERR(vdds_dsi
);
1622 dsi
->vdds_dsi_reg
= vdds_dsi
;
1625 dsi_enable_pll_clock(dsidev
, 1);
1627 * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4.
1629 dsi_enable_scp_clk(dsidev
);
1631 if (!dsi
->vdds_dsi_enabled
) {
1632 r
= regulator_enable(dsi
->vdds_dsi_reg
);
1635 dsi
->vdds_dsi_enabled
= true;
1638 /* XXX PLL does not come out of reset without this... */
1639 dispc_pck_free_enable(1);
1641 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 0, 1) != 1) {
1642 DSSERR("PLL not coming out of reset.\n");
1644 dispc_pck_free_enable(0);
1648 /* XXX ... but if left on, we get problems when planes do not
1649 * fill the whole display. No idea about this */
1650 dispc_pck_free_enable(0);
1652 if (enable_hsclk
&& enable_hsdiv
)
1653 pwstate
= DSI_PLL_POWER_ON_ALL
;
1654 else if (enable_hsclk
)
1655 pwstate
= DSI_PLL_POWER_ON_HSCLK
;
1656 else if (enable_hsdiv
)
1657 pwstate
= DSI_PLL_POWER_ON_DIV
;
1659 pwstate
= DSI_PLL_POWER_OFF
;
1661 r
= dsi_pll_power(dsidev
, pwstate
);
1666 DSSDBG("PLL init done\n");
1670 if (dsi
->vdds_dsi_enabled
) {
1671 regulator_disable(dsi
->vdds_dsi_reg
);
1672 dsi
->vdds_dsi_enabled
= false;
1675 dsi_disable_scp_clk(dsidev
);
1676 dsi_enable_pll_clock(dsidev
, 0);
1680 void dsi_pll_uninit(struct platform_device
*dsidev
, bool disconnect_lanes
)
1682 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1684 dsi
->pll_locked
= 0;
1685 dsi_pll_power(dsidev
, DSI_PLL_POWER_OFF
);
1686 if (disconnect_lanes
) {
1687 WARN_ON(!dsi
->vdds_dsi_enabled
);
1688 regulator_disable(dsi
->vdds_dsi_reg
);
1689 dsi
->vdds_dsi_enabled
= false;
1692 dsi_disable_scp_clk(dsidev
);
1693 dsi_enable_pll_clock(dsidev
, 0);
1695 DSSDBG("PLL uninit done\n");
1698 static void dsi_dump_dsidev_clocks(struct platform_device
*dsidev
,
1701 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1702 struct dsi_clock_info
*cinfo
= &dsi
->current_cinfo
;
1703 enum omap_dss_clk_source dispc_clk_src
, dsi_clk_src
;
1704 int dsi_module
= dsi_get_dsidev_id(dsidev
);
1706 dispc_clk_src
= dss_get_dispc_clk_source();
1707 dsi_clk_src
= dss_get_dsi_clk_source(dsi_module
);
1709 if (dsi_runtime_get(dsidev
))
1712 seq_printf(s
, "- DSI%d PLL -\n", dsi_module
+ 1);
1714 seq_printf(s
, "dsi pll source = %s\n",
1715 cinfo
->use_sys_clk
? "dss_sys_clk" : "pclkfree");
1717 seq_printf(s
, "Fint\t\t%-16luregn %u\n", cinfo
->fint
, cinfo
->regn
);
1719 seq_printf(s
, "CLKIN4DDR\t%-16luregm %u\n",
1720 cinfo
->clkin4ddr
, cinfo
->regm
);
1722 seq_printf(s
, "%s (%s)\t%-16luregm_dispc %u\t(%s)\n",
1723 dss_get_generic_clk_source_name(dispc_clk_src
),
1724 dss_feat_get_clk_source_name(dispc_clk_src
),
1725 cinfo
->dsi_pll_hsdiv_dispc_clk
,
1727 dispc_clk_src
== OMAP_DSS_CLK_SRC_FCK
?
1730 seq_printf(s
, "%s (%s)\t%-16luregm_dsi %u\t(%s)\n",
1731 dss_get_generic_clk_source_name(dsi_clk_src
),
1732 dss_feat_get_clk_source_name(dsi_clk_src
),
1733 cinfo
->dsi_pll_hsdiv_dsi_clk
,
1735 dsi_clk_src
== OMAP_DSS_CLK_SRC_FCK
?
1738 seq_printf(s
, "- DSI%d -\n", dsi_module
+ 1);
1740 seq_printf(s
, "dsi fclk source = %s (%s)\n",
1741 dss_get_generic_clk_source_name(dsi_clk_src
),
1742 dss_feat_get_clk_source_name(dsi_clk_src
));
1744 seq_printf(s
, "DSI_FCLK\t%lu\n", dsi_fclk_rate(dsidev
));
1746 seq_printf(s
, "DDR_CLK\t\t%lu\n",
1747 cinfo
->clkin4ddr
/ 4);
1749 seq_printf(s
, "TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsidev
));
1751 seq_printf(s
, "LP_CLK\t\t%lu\n", cinfo
->lp_clk
);
1753 dsi_runtime_put(dsidev
);
1756 void dsi_dump_clocks(struct seq_file
*s
)
1758 struct platform_device
*dsidev
;
1761 for (i
= 0; i
< MAX_NUM_DSI
; i
++) {
1762 dsidev
= dsi_get_dsidev_from_id(i
);
1764 dsi_dump_dsidev_clocks(dsidev
, s
);
1768 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
1769 static void dsi_dump_dsidev_irqs(struct platform_device
*dsidev
,
1772 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
1773 unsigned long flags
;
1774 struct dsi_irq_stats stats
;
1775 int dsi_module
= dsi_get_dsidev_id(dsidev
);
1777 spin_lock_irqsave(&dsi
->irq_stats_lock
, flags
);
1779 stats
= dsi
->irq_stats
;
1780 memset(&dsi
->irq_stats
, 0, sizeof(dsi
->irq_stats
));
1781 dsi
->irq_stats
.last_reset
= jiffies
;
1783 spin_unlock_irqrestore(&dsi
->irq_stats_lock
, flags
);
1785 seq_printf(s
, "period %u ms\n",
1786 jiffies_to_msecs(jiffies
- stats
.last_reset
));
1788 seq_printf(s
, "irqs %d\n", stats
.irq_count
);
1790 seq_printf(s, "%-20s %10d\n", #x, stats.dsi_irqs[ffs(DSI_IRQ_##x)-1]);
1792 seq_printf(s
, "-- DSI%d interrupts --\n", dsi_module
+ 1);
1808 PIS(LDO_POWER_GOOD
);
1813 seq_printf(s, "%-20s %10d %10d %10d %10d\n", #x, \
1814 stats.vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \
1815 stats.vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \
1816 stats.vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \
1817 stats.vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]);
1819 seq_printf(s
, "-- VC interrupts --\n");
1828 PIS(PP_BUSY_CHANGE
);
1832 seq_printf(s, "%-20s %10d\n", #x, \
1833 stats.cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]);
1835 seq_printf(s
, "-- CIO interrupts --\n");
1848 PIS(ERRCONTENTIONLP0_1
);
1849 PIS(ERRCONTENTIONLP1_1
);
1850 PIS(ERRCONTENTIONLP0_2
);
1851 PIS(ERRCONTENTIONLP1_2
);
1852 PIS(ERRCONTENTIONLP0_3
);
1853 PIS(ERRCONTENTIONLP1_3
);
1854 PIS(ULPSACTIVENOT_ALL0
);
1855 PIS(ULPSACTIVENOT_ALL1
);
1859 static void dsi1_dump_irqs(struct seq_file
*s
)
1861 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(0);
1863 dsi_dump_dsidev_irqs(dsidev
, s
);
1866 static void dsi2_dump_irqs(struct seq_file
*s
)
1868 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(1);
1870 dsi_dump_dsidev_irqs(dsidev
, s
);
1873 void dsi_create_debugfs_files_irq(struct dentry
*debugfs_dir
,
1874 const struct file_operations
*debug_fops
)
1876 struct platform_device
*dsidev
;
1878 dsidev
= dsi_get_dsidev_from_id(0);
1880 debugfs_create_file("dsi1_irqs", S_IRUGO
, debugfs_dir
,
1881 &dsi1_dump_irqs
, debug_fops
);
1883 dsidev
= dsi_get_dsidev_from_id(1);
1885 debugfs_create_file("dsi2_irqs", S_IRUGO
, debugfs_dir
,
1886 &dsi2_dump_irqs
, debug_fops
);
1890 static void dsi_dump_dsidev_regs(struct platform_device
*dsidev
,
1893 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsidev, r))
1895 if (dsi_runtime_get(dsidev
))
1897 dsi_enable_scp_clk(dsidev
);
1899 DUMPREG(DSI_REVISION
);
1900 DUMPREG(DSI_SYSCONFIG
);
1901 DUMPREG(DSI_SYSSTATUS
);
1902 DUMPREG(DSI_IRQSTATUS
);
1903 DUMPREG(DSI_IRQENABLE
);
1905 DUMPREG(DSI_COMPLEXIO_CFG1
);
1906 DUMPREG(DSI_COMPLEXIO_IRQ_STATUS
);
1907 DUMPREG(DSI_COMPLEXIO_IRQ_ENABLE
);
1908 DUMPREG(DSI_CLK_CTRL
);
1909 DUMPREG(DSI_TIMING1
);
1910 DUMPREG(DSI_TIMING2
);
1911 DUMPREG(DSI_VM_TIMING1
);
1912 DUMPREG(DSI_VM_TIMING2
);
1913 DUMPREG(DSI_VM_TIMING3
);
1914 DUMPREG(DSI_CLK_TIMING
);
1915 DUMPREG(DSI_TX_FIFO_VC_SIZE
);
1916 DUMPREG(DSI_RX_FIFO_VC_SIZE
);
1917 DUMPREG(DSI_COMPLEXIO_CFG2
);
1918 DUMPREG(DSI_RX_FIFO_VC_FULLNESS
);
1919 DUMPREG(DSI_VM_TIMING4
);
1920 DUMPREG(DSI_TX_FIFO_VC_EMPTINESS
);
1921 DUMPREG(DSI_VM_TIMING5
);
1922 DUMPREG(DSI_VM_TIMING6
);
1923 DUMPREG(DSI_VM_TIMING7
);
1924 DUMPREG(DSI_STOPCLK_TIMING
);
1926 DUMPREG(DSI_VC_CTRL(0));
1927 DUMPREG(DSI_VC_TE(0));
1928 DUMPREG(DSI_VC_LONG_PACKET_HEADER(0));
1929 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(0));
1930 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(0));
1931 DUMPREG(DSI_VC_IRQSTATUS(0));
1932 DUMPREG(DSI_VC_IRQENABLE(0));
1934 DUMPREG(DSI_VC_CTRL(1));
1935 DUMPREG(DSI_VC_TE(1));
1936 DUMPREG(DSI_VC_LONG_PACKET_HEADER(1));
1937 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(1));
1938 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(1));
1939 DUMPREG(DSI_VC_IRQSTATUS(1));
1940 DUMPREG(DSI_VC_IRQENABLE(1));
1942 DUMPREG(DSI_VC_CTRL(2));
1943 DUMPREG(DSI_VC_TE(2));
1944 DUMPREG(DSI_VC_LONG_PACKET_HEADER(2));
1945 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(2));
1946 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(2));
1947 DUMPREG(DSI_VC_IRQSTATUS(2));
1948 DUMPREG(DSI_VC_IRQENABLE(2));
1950 DUMPREG(DSI_VC_CTRL(3));
1951 DUMPREG(DSI_VC_TE(3));
1952 DUMPREG(DSI_VC_LONG_PACKET_HEADER(3));
1953 DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(3));
1954 DUMPREG(DSI_VC_SHORT_PACKET_HEADER(3));
1955 DUMPREG(DSI_VC_IRQSTATUS(3));
1956 DUMPREG(DSI_VC_IRQENABLE(3));
1958 DUMPREG(DSI_DSIPHY_CFG0
);
1959 DUMPREG(DSI_DSIPHY_CFG1
);
1960 DUMPREG(DSI_DSIPHY_CFG2
);
1961 DUMPREG(DSI_DSIPHY_CFG5
);
1963 DUMPREG(DSI_PLL_CONTROL
);
1964 DUMPREG(DSI_PLL_STATUS
);
1965 DUMPREG(DSI_PLL_GO
);
1966 DUMPREG(DSI_PLL_CONFIGURATION1
);
1967 DUMPREG(DSI_PLL_CONFIGURATION2
);
1969 dsi_disable_scp_clk(dsidev
);
1970 dsi_runtime_put(dsidev
);
1974 static void dsi1_dump_regs(struct seq_file
*s
)
1976 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(0);
1978 dsi_dump_dsidev_regs(dsidev
, s
);
1981 static void dsi2_dump_regs(struct seq_file
*s
)
1983 struct platform_device
*dsidev
= dsi_get_dsidev_from_id(1);
1985 dsi_dump_dsidev_regs(dsidev
, s
);
1988 void dsi_create_debugfs_files_reg(struct dentry
*debugfs_dir
,
1989 const struct file_operations
*debug_fops
)
1991 struct platform_device
*dsidev
;
1993 dsidev
= dsi_get_dsidev_from_id(0);
1995 debugfs_create_file("dsi1_regs", S_IRUGO
, debugfs_dir
,
1996 &dsi1_dump_regs
, debug_fops
);
1998 dsidev
= dsi_get_dsidev_from_id(1);
2000 debugfs_create_file("dsi2_regs", S_IRUGO
, debugfs_dir
,
2001 &dsi2_dump_regs
, debug_fops
);
2003 enum dsi_cio_power_state
{
2004 DSI_COMPLEXIO_POWER_OFF
= 0x0,
2005 DSI_COMPLEXIO_POWER_ON
= 0x1,
2006 DSI_COMPLEXIO_POWER_ULPS
= 0x2,
2009 static int dsi_cio_power(struct platform_device
*dsidev
,
2010 enum dsi_cio_power_state state
)
2015 REG_FLD_MOD(dsidev
, DSI_COMPLEXIO_CFG1
, state
, 28, 27);
2018 while (FLD_GET(dsi_read_reg(dsidev
, DSI_COMPLEXIO_CFG1
),
2021 DSSERR("failed to set complexio power state to "
2031 /* Number of data lanes present on DSI interface */
2032 static inline int dsi_get_num_data_lanes(struct platform_device
*dsidev
)
2034 /* DSI on OMAP3 doesn't have register DSI_GNQ, set number
2035 * of data lanes as 2 by default */
2036 if (dss_has_feature(FEAT_DSI_GNQ
))
2037 return REG_GET(dsidev
, DSI_GNQ
, 11, 9); /* NB_DATA_LANES */
2042 /* Number of data lanes used by the dss device */
2043 static inline int dsi_get_num_data_lanes_dssdev(struct omap_dss_device
*dssdev
)
2045 int num_data_lanes
= 0;
2047 if (dssdev
->phy
.dsi
.data1_lane
!= 0)
2049 if (dssdev
->phy
.dsi
.data2_lane
!= 0)
2051 if (dssdev
->phy
.dsi
.data3_lane
!= 0)
2053 if (dssdev
->phy
.dsi
.data4_lane
!= 0)
2056 return num_data_lanes
;
2059 static unsigned dsi_get_line_buf_size(struct platform_device
*dsidev
)
2063 /* line buffer on OMAP3 is 1024 x 24bits */
2064 /* XXX: for some reason using full buffer size causes
2065 * considerable TX slowdown with update sizes that fill the
2067 if (!dss_has_feature(FEAT_DSI_GNQ
))
2070 val
= REG_GET(dsidev
, DSI_GNQ
, 14, 12); /* VP1_LINE_BUFFER_SIZE */
2074 return 512 * 3; /* 512x24 bits */
2076 return 682 * 3; /* 682x24 bits */
2078 return 853 * 3; /* 853x24 bits */
2080 return 1024 * 3; /* 1024x24 bits */
2082 return 1194 * 3; /* 1194x24 bits */
2084 return 1365 * 3; /* 1365x24 bits */
2090 static void dsi_set_lane_config(struct omap_dss_device
*dssdev
)
2092 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2094 int num_data_lanes_dssdev
= dsi_get_num_data_lanes_dssdev(dssdev
);
2096 int clk_lane
= dssdev
->phy
.dsi
.clk_lane
;
2097 int data1_lane
= dssdev
->phy
.dsi
.data1_lane
;
2098 int data2_lane
= dssdev
->phy
.dsi
.data2_lane
;
2099 int clk_pol
= dssdev
->phy
.dsi
.clk_pol
;
2100 int data1_pol
= dssdev
->phy
.dsi
.data1_pol
;
2101 int data2_pol
= dssdev
->phy
.dsi
.data2_pol
;
2103 r
= dsi_read_reg(dsidev
, DSI_COMPLEXIO_CFG1
);
2104 r
= FLD_MOD(r
, clk_lane
, 2, 0);
2105 r
= FLD_MOD(r
, clk_pol
, 3, 3);
2106 r
= FLD_MOD(r
, data1_lane
, 6, 4);
2107 r
= FLD_MOD(r
, data1_pol
, 7, 7);
2108 r
= FLD_MOD(r
, data2_lane
, 10, 8);
2109 r
= FLD_MOD(r
, data2_pol
, 11, 11);
2110 if (num_data_lanes_dssdev
> 2) {
2111 int data3_lane
= dssdev
->phy
.dsi
.data3_lane
;
2112 int data3_pol
= dssdev
->phy
.dsi
.data3_pol
;
2114 r
= FLD_MOD(r
, data3_lane
, 14, 12);
2115 r
= FLD_MOD(r
, data3_pol
, 15, 15);
2117 if (num_data_lanes_dssdev
> 3) {
2118 int data4_lane
= dssdev
->phy
.dsi
.data4_lane
;
2119 int data4_pol
= dssdev
->phy
.dsi
.data4_pol
;
2121 r
= FLD_MOD(r
, data4_lane
, 18, 16);
2122 r
= FLD_MOD(r
, data4_pol
, 19, 19);
2124 dsi_write_reg(dsidev
, DSI_COMPLEXIO_CFG1
, r
);
2126 /* The configuration of the DSI complex I/O (number of data lanes,
2127 position, differential order) should not be changed while
2128 DSS.DSI_CLK_CRTRL[20] LP_CLK_ENABLE bit is set to 1. In order for
2129 the hardware to take into account a new configuration of the complex
2130 I/O (done in DSS.DSI_COMPLEXIO_CFG1 register), it is recommended to
2131 follow this sequence: First set the DSS.DSI_CTRL[0] IF_EN bit to 1,
2132 then reset the DSS.DSI_CTRL[0] IF_EN to 0, then set
2133 DSS.DSI_CLK_CTRL[20] LP_CLK_ENABLE to 1 and finally set again the
2134 DSS.DSI_CTRL[0] IF_EN bit to 1. If the sequence is not followed, the
2135 DSI complex I/O configuration is unknown. */
2138 REG_FLD_MOD(dsidev, DSI_CTRL, 1, 0, 0);
2139 REG_FLD_MOD(dsidev, DSI_CTRL, 0, 0, 0);
2140 REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 20, 20);
2141 REG_FLD_MOD(dsidev, DSI_CTRL, 1, 0, 0);
2145 static inline unsigned ns2ddr(struct platform_device
*dsidev
, unsigned ns
)
2147 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2149 /* convert time in ns to ddr ticks, rounding up */
2150 unsigned long ddr_clk
= dsi
->current_cinfo
.clkin4ddr
/ 4;
2151 return (ns
* (ddr_clk
/ 1000 / 1000) + 999) / 1000;
2154 static inline unsigned ddr2ns(struct platform_device
*dsidev
, unsigned ddr
)
2156 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2158 unsigned long ddr_clk
= dsi
->current_cinfo
.clkin4ddr
/ 4;
2159 return ddr
* 1000 * 1000 / (ddr_clk
/ 1000);
2162 static void dsi_cio_timings(struct platform_device
*dsidev
)
2165 u32 ths_prepare
, ths_prepare_ths_zero
, ths_trail
, ths_exit
;
2166 u32 tlpx_half
, tclk_trail
, tclk_zero
;
2169 /* calculate timings */
2171 /* 1 * DDR_CLK = 2 * UI */
2173 /* min 40ns + 4*UI max 85ns + 6*UI */
2174 ths_prepare
= ns2ddr(dsidev
, 70) + 2;
2176 /* min 145ns + 10*UI */
2177 ths_prepare_ths_zero
= ns2ddr(dsidev
, 175) + 2;
2179 /* min max(8*UI, 60ns+4*UI) */
2180 ths_trail
= ns2ddr(dsidev
, 60) + 5;
2183 ths_exit
= ns2ddr(dsidev
, 145);
2186 tlpx_half
= ns2ddr(dsidev
, 25);
2189 tclk_trail
= ns2ddr(dsidev
, 60) + 2;
2191 /* min 38ns, max 95ns */
2192 tclk_prepare
= ns2ddr(dsidev
, 65);
2194 /* min tclk-prepare + tclk-zero = 300ns */
2195 tclk_zero
= ns2ddr(dsidev
, 260);
2197 DSSDBG("ths_prepare %u (%uns), ths_prepare_ths_zero %u (%uns)\n",
2198 ths_prepare
, ddr2ns(dsidev
, ths_prepare
),
2199 ths_prepare_ths_zero
, ddr2ns(dsidev
, ths_prepare_ths_zero
));
2200 DSSDBG("ths_trail %u (%uns), ths_exit %u (%uns)\n",
2201 ths_trail
, ddr2ns(dsidev
, ths_trail
),
2202 ths_exit
, ddr2ns(dsidev
, ths_exit
));
2204 DSSDBG("tlpx_half %u (%uns), tclk_trail %u (%uns), "
2205 "tclk_zero %u (%uns)\n",
2206 tlpx_half
, ddr2ns(dsidev
, tlpx_half
),
2207 tclk_trail
, ddr2ns(dsidev
, tclk_trail
),
2208 tclk_zero
, ddr2ns(dsidev
, tclk_zero
));
2209 DSSDBG("tclk_prepare %u (%uns)\n",
2210 tclk_prepare
, ddr2ns(dsidev
, tclk_prepare
));
2212 /* program timings */
2214 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG0
);
2215 r
= FLD_MOD(r
, ths_prepare
, 31, 24);
2216 r
= FLD_MOD(r
, ths_prepare_ths_zero
, 23, 16);
2217 r
= FLD_MOD(r
, ths_trail
, 15, 8);
2218 r
= FLD_MOD(r
, ths_exit
, 7, 0);
2219 dsi_write_reg(dsidev
, DSI_DSIPHY_CFG0
, r
);
2221 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG1
);
2222 r
= FLD_MOD(r
, tlpx_half
, 22, 16);
2223 r
= FLD_MOD(r
, tclk_trail
, 15, 8);
2224 r
= FLD_MOD(r
, tclk_zero
, 7, 0);
2225 dsi_write_reg(dsidev
, DSI_DSIPHY_CFG1
, r
);
2227 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG2
);
2228 r
= FLD_MOD(r
, tclk_prepare
, 7, 0);
2229 dsi_write_reg(dsidev
, DSI_DSIPHY_CFG2
, r
);
2232 static void dsi_cio_enable_lane_override(struct omap_dss_device
*dssdev
,
2233 enum dsi_lane lanes
)
2235 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2236 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2237 int clk_lane
= dssdev
->phy
.dsi
.clk_lane
;
2238 int data1_lane
= dssdev
->phy
.dsi
.data1_lane
;
2239 int data2_lane
= dssdev
->phy
.dsi
.data2_lane
;
2240 int data3_lane
= dssdev
->phy
.dsi
.data3_lane
;
2241 int data4_lane
= dssdev
->phy
.dsi
.data4_lane
;
2242 int clk_pol
= dssdev
->phy
.dsi
.clk_pol
;
2243 int data1_pol
= dssdev
->phy
.dsi
.data1_pol
;
2244 int data2_pol
= dssdev
->phy
.dsi
.data2_pol
;
2245 int data3_pol
= dssdev
->phy
.dsi
.data3_pol
;
2246 int data4_pol
= dssdev
->phy
.dsi
.data4_pol
;
2249 u8 lptxscp_start
= dsi
->num_data_lanes
== 2 ? 22 : 26;
2251 if (lanes
& DSI_CLK_P
)
2252 l
|= 1 << ((clk_lane
- 1) * 2 + (clk_pol
? 0 : 1));
2253 if (lanes
& DSI_CLK_N
)
2254 l
|= 1 << ((clk_lane
- 1) * 2 + (clk_pol
? 1 : 0));
2256 if (lanes
& DSI_DATA1_P
)
2257 l
|= 1 << ((data1_lane
- 1) * 2 + (data1_pol
? 0 : 1));
2258 if (lanes
& DSI_DATA1_N
)
2259 l
|= 1 << ((data1_lane
- 1) * 2 + (data1_pol
? 1 : 0));
2261 if (lanes
& DSI_DATA2_P
)
2262 l
|= 1 << ((data2_lane
- 1) * 2 + (data2_pol
? 0 : 1));
2263 if (lanes
& DSI_DATA2_N
)
2264 l
|= 1 << ((data2_lane
- 1) * 2 + (data2_pol
? 1 : 0));
2266 if (lanes
& DSI_DATA3_P
)
2267 l
|= 1 << ((data3_lane
- 1) * 2 + (data3_pol
? 0 : 1));
2268 if (lanes
& DSI_DATA3_N
)
2269 l
|= 1 << ((data3_lane
- 1) * 2 + (data3_pol
? 1 : 0));
2271 if (lanes
& DSI_DATA4_P
)
2272 l
|= 1 << ((data4_lane
- 1) * 2 + (data4_pol
? 0 : 1));
2273 if (lanes
& DSI_DATA4_N
)
2274 l
|= 1 << ((data4_lane
- 1) * 2 + (data4_pol
? 1 : 0));
2276 * Bits in REGLPTXSCPDAT4TO0DXDY:
2284 /* Set the lane override configuration */
2286 /* REGLPTXSCPDAT4TO0DXDY */
2287 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, l
, lptxscp_start
, 17);
2289 /* Enable lane override */
2292 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, 1, 27, 27);
2295 static void dsi_cio_disable_lane_override(struct platform_device
*dsidev
)
2297 /* Disable lane override */
2298 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, 0, 27, 27); /* ENLPTXSCPDAT */
2299 /* Reset the lane override configuration */
2300 /* REGLPTXSCPDAT4TO0DXDY */
2301 REG_FLD_MOD(dsidev
, DSI_DSIPHY_CFG10
, 0, 22, 17);
2304 static int dsi_cio_wait_tx_clk_esc_reset(struct omap_dss_device
*dssdev
)
2306 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2311 if (dss_has_feature(FEAT_DSI_REVERSE_TXCLKESC
)) {
2325 if (dssdev
->phy
.dsi
.clk_lane
!= 0)
2326 in_use
[dssdev
->phy
.dsi
.clk_lane
- 1] = true;
2327 if (dssdev
->phy
.dsi
.data1_lane
!= 0)
2328 in_use
[dssdev
->phy
.dsi
.data1_lane
- 1] = true;
2329 if (dssdev
->phy
.dsi
.data2_lane
!= 0)
2330 in_use
[dssdev
->phy
.dsi
.data2_lane
- 1] = true;
2338 l
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
2341 for (i
= 0; i
< 3; ++i
) {
2342 if (!in_use
[i
] || (l
& (1 << bits
[i
])))
2350 for (i
= 0; i
< 3; ++i
) {
2351 if (!in_use
[i
] || (l
& (1 << bits
[i
])))
2354 DSSERR("CIO TXCLKESC%d domain not coming " \
2355 "out of reset\n", i
);
2364 static int dsi_cio_init(struct omap_dss_device
*dssdev
)
2366 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2367 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2369 int num_data_lanes_dssdev
= dsi_get_num_data_lanes_dssdev(dssdev
);
2374 if (dsi
->dsi_mux_pads
)
2375 dsi
->dsi_mux_pads(true);
2377 dsi_enable_scp_clk(dsidev
);
2379 /* A dummy read using the SCP interface to any DSIPHY register is
2380 * required after DSIPHY reset to complete the reset of the DSI complex
2382 dsi_read_reg(dsidev
, DSI_DSIPHY_CFG5
);
2384 if (wait_for_bit_change(dsidev
, DSI_DSIPHY_CFG5
, 30, 1) != 1) {
2385 DSSERR("CIO SCP Clock domain not coming out of reset.\n");
2387 goto err_scp_clk_dom
;
2390 dsi_set_lane_config(dssdev
);
2392 /* set TX STOP MODE timer to maximum for this operation */
2393 l
= dsi_read_reg(dsidev
, DSI_TIMING1
);
2394 l
= FLD_MOD(l
, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
2395 l
= FLD_MOD(l
, 1, 14, 14); /* STOP_STATE_X16_IO */
2396 l
= FLD_MOD(l
, 1, 13, 13); /* STOP_STATE_X4_IO */
2397 l
= FLD_MOD(l
, 0x1fff, 12, 0); /* STOP_STATE_COUNTER_IO */
2398 dsi_write_reg(dsidev
, DSI_TIMING1
, l
);
2400 if (dsi
->ulps_enabled
) {
2401 u32 lane_mask
= DSI_CLK_P
| DSI_DATA1_P
| DSI_DATA2_P
;
2403 DSSDBG("manual ulps exit\n");
2405 /* ULPS is exited by Mark-1 state for 1ms, followed by
2406 * stop state. DSS HW cannot do this via the normal
2407 * ULPS exit sequence, as after reset the DSS HW thinks
2408 * that we are not in ULPS mode, and refuses to send the
2409 * sequence. So we need to send the ULPS exit sequence
2413 if (num_data_lanes_dssdev
> 2)
2414 lane_mask
|= DSI_DATA3_P
;
2416 if (num_data_lanes_dssdev
> 3)
2417 lane_mask
|= DSI_DATA4_P
;
2419 dsi_cio_enable_lane_override(dssdev
, lane_mask
);
2422 r
= dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_ON
);
2426 if (wait_for_bit_change(dsidev
, DSI_COMPLEXIO_CFG1
, 29, 1) != 1) {
2427 DSSERR("CIO PWR clock domain not coming out of reset.\n");
2429 goto err_cio_pwr_dom
;
2432 dsi_if_enable(dsidev
, true);
2433 dsi_if_enable(dsidev
, false);
2434 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 1, 20, 20); /* LP_CLK_ENABLE */
2436 r
= dsi_cio_wait_tx_clk_esc_reset(dssdev
);
2438 goto err_tx_clk_esc_rst
;
2440 if (dsi
->ulps_enabled
) {
2441 /* Keep Mark-1 state for 1ms (as per DSI spec) */
2442 ktime_t wait
= ns_to_ktime(1000 * 1000);
2443 set_current_state(TASK_UNINTERRUPTIBLE
);
2444 schedule_hrtimeout(&wait
, HRTIMER_MODE_REL
);
2446 /* Disable the override. The lanes should be set to Mark-11
2447 * state by the HW */
2448 dsi_cio_disable_lane_override(dsidev
);
2451 /* FORCE_TX_STOP_MODE_IO */
2452 REG_FLD_MOD(dsidev
, DSI_TIMING1
, 0, 15, 15);
2454 dsi_cio_timings(dsidev
);
2456 dsi
->ulps_enabled
= false;
2458 DSSDBG("CIO init done\n");
2463 REG_FLD_MOD(dsidev
, DSI_CLK_CTRL
, 0, 20, 20); /* LP_CLK_ENABLE */
2465 dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_OFF
);
2467 if (dsi
->ulps_enabled
)
2468 dsi_cio_disable_lane_override(dsidev
);
2470 dsi_disable_scp_clk(dsidev
);
2471 if (dsi
->dsi_mux_pads
)
2472 dsi
->dsi_mux_pads(false);
2476 static void dsi_cio_uninit(struct platform_device
*dsidev
)
2478 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2480 dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_OFF
);
2481 dsi_disable_scp_clk(dsidev
);
2482 if (dsi
->dsi_mux_pads
)
2483 dsi
->dsi_mux_pads(false);
2486 static void dsi_config_tx_fifo(struct platform_device
*dsidev
,
2487 enum fifo_size size1
, enum fifo_size size2
,
2488 enum fifo_size size3
, enum fifo_size size4
)
2490 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2495 dsi
->vc
[0].fifo_size
= size1
;
2496 dsi
->vc
[1].fifo_size
= size2
;
2497 dsi
->vc
[2].fifo_size
= size3
;
2498 dsi
->vc
[3].fifo_size
= size4
;
2500 for (i
= 0; i
< 4; i
++) {
2502 int size
= dsi
->vc
[i
].fifo_size
;
2504 if (add
+ size
> 4) {
2505 DSSERR("Illegal FIFO configuration\n");
2509 v
= FLD_VAL(add
, 2, 0) | FLD_VAL(size
, 7, 4);
2511 /*DSSDBG("TX FIFO vc %d: size %d, add %d\n", i, size, add); */
2515 dsi_write_reg(dsidev
, DSI_TX_FIFO_VC_SIZE
, r
);
2518 static void dsi_config_rx_fifo(struct platform_device
*dsidev
,
2519 enum fifo_size size1
, enum fifo_size size2
,
2520 enum fifo_size size3
, enum fifo_size size4
)
2522 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2527 dsi
->vc
[0].fifo_size
= size1
;
2528 dsi
->vc
[1].fifo_size
= size2
;
2529 dsi
->vc
[2].fifo_size
= size3
;
2530 dsi
->vc
[3].fifo_size
= size4
;
2532 for (i
= 0; i
< 4; i
++) {
2534 int size
= dsi
->vc
[i
].fifo_size
;
2536 if (add
+ size
> 4) {
2537 DSSERR("Illegal FIFO configuration\n");
2541 v
= FLD_VAL(add
, 2, 0) | FLD_VAL(size
, 7, 4);
2543 /*DSSDBG("RX FIFO vc %d: size %d, add %d\n", i, size, add); */
2547 dsi_write_reg(dsidev
, DSI_RX_FIFO_VC_SIZE
, r
);
2550 static int dsi_force_tx_stop_mode_io(struct platform_device
*dsidev
)
2554 r
= dsi_read_reg(dsidev
, DSI_TIMING1
);
2555 r
= FLD_MOD(r
, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
2556 dsi_write_reg(dsidev
, DSI_TIMING1
, r
);
2558 if (wait_for_bit_change(dsidev
, DSI_TIMING1
, 15, 0) != 0) {
2559 DSSERR("TX_STOP bit not going down\n");
2566 static bool dsi_vc_is_enabled(struct platform_device
*dsidev
, int channel
)
2568 return REG_GET(dsidev
, DSI_VC_CTRL(channel
), 0, 0);
2571 static void dsi_packet_sent_handler_vp(void *data
, u32 mask
)
2573 struct dsi_packet_sent_handler_data
*vp_data
=
2574 (struct dsi_packet_sent_handler_data
*) data
;
2575 struct dsi_data
*dsi
= dsi_get_dsidrv_data(vp_data
->dsidev
);
2576 const int channel
= dsi
->update_channel
;
2577 u8 bit
= dsi
->te_enabled
? 30 : 31;
2579 if (REG_GET(vp_data
->dsidev
, DSI_VC_TE(channel
), bit
, bit
) == 0)
2580 complete(vp_data
->completion
);
2583 static int dsi_sync_vc_vp(struct platform_device
*dsidev
, int channel
)
2585 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2586 DECLARE_COMPLETION_ONSTACK(completion
);
2587 struct dsi_packet_sent_handler_data vp_data
= { dsidev
, &completion
};
2591 bit
= dsi
->te_enabled
? 30 : 31;
2593 r
= dsi_register_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_vp
,
2594 &vp_data
, DSI_VC_IRQ_PACKET_SENT
);
2598 /* Wait for completion only if TE_EN/TE_START is still set */
2599 if (REG_GET(dsidev
, DSI_VC_TE(channel
), bit
, bit
)) {
2600 if (wait_for_completion_timeout(&completion
,
2601 msecs_to_jiffies(10)) == 0) {
2602 DSSERR("Failed to complete previous frame transfer\n");
2608 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_vp
,
2609 &vp_data
, DSI_VC_IRQ_PACKET_SENT
);
2613 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_vp
,
2614 &vp_data
, DSI_VC_IRQ_PACKET_SENT
);
2619 static void dsi_packet_sent_handler_l4(void *data
, u32 mask
)
2621 struct dsi_packet_sent_handler_data
*l4_data
=
2622 (struct dsi_packet_sent_handler_data
*) data
;
2623 struct dsi_data
*dsi
= dsi_get_dsidrv_data(l4_data
->dsidev
);
2624 const int channel
= dsi
->update_channel
;
2626 if (REG_GET(l4_data
->dsidev
, DSI_VC_CTRL(channel
), 5, 5) == 0)
2627 complete(l4_data
->completion
);
2630 static int dsi_sync_vc_l4(struct platform_device
*dsidev
, int channel
)
2632 DECLARE_COMPLETION_ONSTACK(completion
);
2633 struct dsi_packet_sent_handler_data l4_data
= { dsidev
, &completion
};
2636 r
= dsi_register_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_l4
,
2637 &l4_data
, DSI_VC_IRQ_PACKET_SENT
);
2641 /* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */
2642 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 5, 5)) {
2643 if (wait_for_completion_timeout(&completion
,
2644 msecs_to_jiffies(10)) == 0) {
2645 DSSERR("Failed to complete previous l4 transfer\n");
2651 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_l4
,
2652 &l4_data
, DSI_VC_IRQ_PACKET_SENT
);
2656 dsi_unregister_isr_vc(dsidev
, channel
, dsi_packet_sent_handler_l4
,
2657 &l4_data
, DSI_VC_IRQ_PACKET_SENT
);
2662 static int dsi_sync_vc(struct platform_device
*dsidev
, int channel
)
2664 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2666 WARN_ON(!dsi_bus_is_locked(dsidev
));
2668 WARN_ON(in_interrupt());
2670 if (!dsi_vc_is_enabled(dsidev
, channel
))
2673 switch (dsi
->vc
[channel
].mode
) {
2674 case DSI_VC_MODE_VP
:
2675 return dsi_sync_vc_vp(dsidev
, channel
);
2676 case DSI_VC_MODE_L4
:
2677 return dsi_sync_vc_l4(dsidev
, channel
);
2683 static int dsi_vc_enable(struct platform_device
*dsidev
, int channel
,
2686 DSSDBG("dsi_vc_enable channel %d, enable %d\n",
2689 enable
= enable
? 1 : 0;
2691 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), enable
, 0, 0);
2693 if (wait_for_bit_change(dsidev
, DSI_VC_CTRL(channel
),
2694 0, enable
) != enable
) {
2695 DSSERR("Failed to set dsi_vc_enable to %d\n", enable
);
2702 static void dsi_vc_initial_config(struct platform_device
*dsidev
, int channel
)
2706 DSSDBGF("%d", channel
);
2708 r
= dsi_read_reg(dsidev
, DSI_VC_CTRL(channel
));
2710 if (FLD_GET(r
, 15, 15)) /* VC_BUSY */
2711 DSSERR("VC(%d) busy when trying to configure it!\n",
2714 r
= FLD_MOD(r
, 0, 1, 1); /* SOURCE, 0 = L4 */
2715 r
= FLD_MOD(r
, 0, 2, 2); /* BTA_SHORT_EN */
2716 r
= FLD_MOD(r
, 0, 3, 3); /* BTA_LONG_EN */
2717 r
= FLD_MOD(r
, 0, 4, 4); /* MODE, 0 = command */
2718 r
= FLD_MOD(r
, 1, 7, 7); /* CS_TX_EN */
2719 r
= FLD_MOD(r
, 1, 8, 8); /* ECC_TX_EN */
2720 r
= FLD_MOD(r
, 0, 9, 9); /* MODE_SPEED, high speed on/off */
2721 if (dss_has_feature(FEAT_DSI_VC_OCP_WIDTH
))
2722 r
= FLD_MOD(r
, 3, 11, 10); /* OCP_WIDTH = 32 bit */
2724 r
= FLD_MOD(r
, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */
2725 r
= FLD_MOD(r
, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */
2727 dsi_write_reg(dsidev
, DSI_VC_CTRL(channel
), r
);
2730 static int dsi_vc_config_l4(struct platform_device
*dsidev
, int channel
)
2732 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2734 if (dsi
->vc
[channel
].mode
== DSI_VC_MODE_L4
)
2737 DSSDBGF("%d", channel
);
2739 dsi_sync_vc(dsidev
, channel
);
2741 dsi_vc_enable(dsidev
, channel
, 0);
2744 if (wait_for_bit_change(dsidev
, DSI_VC_CTRL(channel
), 15, 0) != 0) {
2745 DSSERR("vc(%d) busy when trying to config for L4\n", channel
);
2749 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 0, 1, 1); /* SOURCE, 0 = L4 */
2751 /* DCS_CMD_ENABLE */
2752 if (dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC
))
2753 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 0, 30, 30);
2755 dsi_vc_enable(dsidev
, channel
, 1);
2757 dsi
->vc
[channel
].mode
= DSI_VC_MODE_L4
;
2762 static int dsi_vc_config_vp(struct platform_device
*dsidev
, int channel
)
2764 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2766 if (dsi
->vc
[channel
].mode
== DSI_VC_MODE_VP
)
2769 DSSDBGF("%d", channel
);
2771 dsi_sync_vc(dsidev
, channel
);
2773 dsi_vc_enable(dsidev
, channel
, 0);
2776 if (wait_for_bit_change(dsidev
, DSI_VC_CTRL(channel
), 15, 0) != 0) {
2777 DSSERR("vc(%d) busy when trying to config for VP\n", channel
);
2781 /* SOURCE, 1 = video port */
2782 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 1, 1, 1);
2784 /* DCS_CMD_ENABLE */
2785 if (dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC
))
2786 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 1, 30, 30);
2788 dsi_vc_enable(dsidev
, channel
, 1);
2790 dsi
->vc
[channel
].mode
= DSI_VC_MODE_VP
;
2796 void omapdss_dsi_vc_enable_hs(struct omap_dss_device
*dssdev
, int channel
,
2799 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2801 DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel
, enable
);
2803 WARN_ON(!dsi_bus_is_locked(dsidev
));
2805 dsi_vc_enable(dsidev
, channel
, 0);
2806 dsi_if_enable(dsidev
, 0);
2808 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), enable
, 9, 9);
2810 dsi_vc_enable(dsidev
, channel
, 1);
2811 dsi_if_enable(dsidev
, 1);
2813 dsi_force_tx_stop_mode_io(dsidev
);
2815 EXPORT_SYMBOL(omapdss_dsi_vc_enable_hs
);
2817 static void dsi_vc_flush_long_data(struct platform_device
*dsidev
, int channel
)
2819 while (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
2821 val
= dsi_read_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
));
2822 DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n",
2826 (val
>> 24) & 0xff);
2830 static void dsi_show_rx_ack_with_err(u16 err
)
2832 DSSERR("\tACK with ERROR (%#x):\n", err
);
2834 DSSERR("\t\tSoT Error\n");
2836 DSSERR("\t\tSoT Sync Error\n");
2838 DSSERR("\t\tEoT Sync Error\n");
2840 DSSERR("\t\tEscape Mode Entry Command Error\n");
2842 DSSERR("\t\tLP Transmit Sync Error\n");
2844 DSSERR("\t\tHS Receive Timeout Error\n");
2846 DSSERR("\t\tFalse Control Error\n");
2848 DSSERR("\t\t(reserved7)\n");
2850 DSSERR("\t\tECC Error, single-bit (corrected)\n");
2852 DSSERR("\t\tECC Error, multi-bit (not corrected)\n");
2853 if (err
& (1 << 10))
2854 DSSERR("\t\tChecksum Error\n");
2855 if (err
& (1 << 11))
2856 DSSERR("\t\tData type not recognized\n");
2857 if (err
& (1 << 12))
2858 DSSERR("\t\tInvalid VC ID\n");
2859 if (err
& (1 << 13))
2860 DSSERR("\t\tInvalid Transmission Length\n");
2861 if (err
& (1 << 14))
2862 DSSERR("\t\t(reserved14)\n");
2863 if (err
& (1 << 15))
2864 DSSERR("\t\tDSI Protocol Violation\n");
2867 static u16
dsi_vc_flush_receive_data(struct platform_device
*dsidev
,
2870 /* RX_FIFO_NOT_EMPTY */
2871 while (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
2874 val
= dsi_read_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
));
2875 DSSERR("\trawval %#08x\n", val
);
2876 dt
= FLD_GET(val
, 5, 0);
2877 if (dt
== DSI_DT_RX_ACK_WITH_ERR
) {
2878 u16 err
= FLD_GET(val
, 23, 8);
2879 dsi_show_rx_ack_with_err(err
);
2880 } else if (dt
== DSI_DT_RX_SHORT_READ_1
) {
2881 DSSERR("\tDCS short response, 1 byte: %#x\n",
2882 FLD_GET(val
, 23, 8));
2883 } else if (dt
== DSI_DT_RX_SHORT_READ_2
) {
2884 DSSERR("\tDCS short response, 2 byte: %#x\n",
2885 FLD_GET(val
, 23, 8));
2886 } else if (dt
== DSI_DT_RX_DCS_LONG_READ
) {
2887 DSSERR("\tDCS long response, len %d\n",
2888 FLD_GET(val
, 23, 8));
2889 dsi_vc_flush_long_data(dsidev
, channel
);
2891 DSSERR("\tunknown datatype 0x%02x\n", dt
);
2897 static int dsi_vc_send_bta(struct platform_device
*dsidev
, int channel
)
2899 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2901 if (dsi
->debug_write
|| dsi
->debug_read
)
2902 DSSDBG("dsi_vc_send_bta %d\n", channel
);
2904 WARN_ON(!dsi_bus_is_locked(dsidev
));
2906 /* RX_FIFO_NOT_EMPTY */
2907 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
2908 DSSERR("rx fifo not empty when sending BTA, dumping data:\n");
2909 dsi_vc_flush_receive_data(dsidev
, channel
);
2912 REG_FLD_MOD(dsidev
, DSI_VC_CTRL(channel
), 1, 6, 6); /* BTA_EN */
2917 int dsi_vc_send_bta_sync(struct omap_dss_device
*dssdev
, int channel
)
2919 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
2920 DECLARE_COMPLETION_ONSTACK(completion
);
2924 r
= dsi_register_isr_vc(dsidev
, channel
, dsi_completion_handler
,
2925 &completion
, DSI_VC_IRQ_BTA
);
2929 r
= dsi_register_isr(dsidev
, dsi_completion_handler
, &completion
,
2930 DSI_IRQ_ERROR_MASK
);
2934 r
= dsi_vc_send_bta(dsidev
, channel
);
2938 if (wait_for_completion_timeout(&completion
,
2939 msecs_to_jiffies(500)) == 0) {
2940 DSSERR("Failed to receive BTA\n");
2945 err
= dsi_get_errors(dsidev
);
2947 DSSERR("Error while sending BTA: %x\n", err
);
2952 dsi_unregister_isr(dsidev
, dsi_completion_handler
, &completion
,
2953 DSI_IRQ_ERROR_MASK
);
2955 dsi_unregister_isr_vc(dsidev
, channel
, dsi_completion_handler
,
2956 &completion
, DSI_VC_IRQ_BTA
);
2960 EXPORT_SYMBOL(dsi_vc_send_bta_sync
);
2962 static inline void dsi_vc_write_long_header(struct platform_device
*dsidev
,
2963 int channel
, u8 data_type
, u16 len
, u8 ecc
)
2965 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
2969 WARN_ON(!dsi_bus_is_locked(dsidev
));
2971 data_id
= data_type
| dsi
->vc
[channel
].vc_id
<< 6;
2973 val
= FLD_VAL(data_id
, 7, 0) | FLD_VAL(len
, 23, 8) |
2974 FLD_VAL(ecc
, 31, 24);
2976 dsi_write_reg(dsidev
, DSI_VC_LONG_PACKET_HEADER(channel
), val
);
2979 static inline void dsi_vc_write_long_payload(struct platform_device
*dsidev
,
2980 int channel
, u8 b1
, u8 b2
, u8 b3
, u8 b4
)
2984 val
= b4
<< 24 | b3
<< 16 | b2
<< 8 | b1
<< 0;
2986 /* DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n",
2987 b1, b2, b3, b4, val); */
2989 dsi_write_reg(dsidev
, DSI_VC_LONG_PACKET_PAYLOAD(channel
), val
);
2992 static int dsi_vc_send_long(struct platform_device
*dsidev
, int channel
,
2993 u8 data_type
, u8
*data
, u16 len
, u8 ecc
)
2996 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3002 if (dsi
->debug_write
)
3003 DSSDBG("dsi_vc_send_long, %d bytes\n", len
);
3006 if (dsi
->vc
[channel
].fifo_size
* 32 * 4 < len
+ 4) {
3007 DSSERR("unable to send long packet: packet too long.\n");
3011 dsi_vc_config_l4(dsidev
, channel
);
3013 dsi_vc_write_long_header(dsidev
, channel
, data_type
, len
, ecc
);
3016 for (i
= 0; i
< len
>> 2; i
++) {
3017 if (dsi
->debug_write
)
3018 DSSDBG("\tsending full packet %d\n", i
);
3025 dsi_vc_write_long_payload(dsidev
, channel
, b1
, b2
, b3
, b4
);
3030 b1
= 0; b2
= 0; b3
= 0;
3032 if (dsi
->debug_write
)
3033 DSSDBG("\tsending remainder bytes %d\n", i
);
3050 dsi_vc_write_long_payload(dsidev
, channel
, b1
, b2
, b3
, 0);
3056 static int dsi_vc_send_short(struct platform_device
*dsidev
, int channel
,
3057 u8 data_type
, u16 data
, u8 ecc
)
3059 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3063 WARN_ON(!dsi_bus_is_locked(dsidev
));
3065 if (dsi
->debug_write
)
3066 DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n",
3068 data_type
, data
& 0xff, (data
>> 8) & 0xff);
3070 dsi_vc_config_l4(dsidev
, channel
);
3072 if (FLD_GET(dsi_read_reg(dsidev
, DSI_VC_CTRL(channel
)), 16, 16)) {
3073 DSSERR("ERROR FIFO FULL, aborting transfer\n");
3077 data_id
= data_type
| dsi
->vc
[channel
].vc_id
<< 6;
3079 r
= (data_id
<< 0) | (data
<< 8) | (ecc
<< 24);
3081 dsi_write_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
), r
);
3086 int dsi_vc_send_null(struct omap_dss_device
*dssdev
, int channel
)
3088 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3089 u8 nullpkg
[] = {0, 0, 0, 0};
3091 return dsi_vc_send_long(dsidev
, channel
, DSI_DT_NULL_PACKET
, nullpkg
,
3094 EXPORT_SYMBOL(dsi_vc_send_null
);
3096 int dsi_vc_dcs_write_nosync(struct omap_dss_device
*dssdev
, int channel
,
3099 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3105 r
= dsi_vc_send_short(dsidev
, channel
, DSI_DT_DCS_SHORT_WRITE_0
,
3107 } else if (len
== 2) {
3108 r
= dsi_vc_send_short(dsidev
, channel
, DSI_DT_DCS_SHORT_WRITE_1
,
3109 data
[0] | (data
[1] << 8), 0);
3111 /* 0x39 = DCS Long Write */
3112 r
= dsi_vc_send_long(dsidev
, channel
, DSI_DT_DCS_LONG_WRITE
,
3118 EXPORT_SYMBOL(dsi_vc_dcs_write_nosync
);
3120 int dsi_vc_dcs_write(struct omap_dss_device
*dssdev
, int channel
, u8
*data
,
3123 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3126 r
= dsi_vc_dcs_write_nosync(dssdev
, channel
, data
, len
);
3130 r
= dsi_vc_send_bta_sync(dssdev
, channel
);
3134 /* RX_FIFO_NOT_EMPTY */
3135 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20)) {
3136 DSSERR("rx fifo not empty after write, dumping data:\n");
3137 dsi_vc_flush_receive_data(dsidev
, channel
);
3144 DSSERR("dsi_vc_dcs_write(ch %d, cmd 0x%02x, len %d) failed\n",
3145 channel
, data
[0], len
);
3148 EXPORT_SYMBOL(dsi_vc_dcs_write
);
3150 int dsi_vc_dcs_write_0(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
)
3152 return dsi_vc_dcs_write(dssdev
, channel
, &dcs_cmd
, 1);
3154 EXPORT_SYMBOL(dsi_vc_dcs_write_0
);
3156 int dsi_vc_dcs_write_1(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3162 return dsi_vc_dcs_write(dssdev
, channel
, buf
, 2);
3164 EXPORT_SYMBOL(dsi_vc_dcs_write_1
);
3166 int dsi_vc_dcs_read(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3167 u8
*buf
, int buflen
)
3169 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3170 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3175 if (dsi
->debug_read
)
3176 DSSDBG("dsi_vc_dcs_read(ch%d, dcs_cmd %x)\n", channel
, dcs_cmd
);
3178 r
= dsi_vc_send_short(dsidev
, channel
, DSI_DT_DCS_READ
, dcs_cmd
, 0);
3182 r
= dsi_vc_send_bta_sync(dssdev
, channel
);
3186 /* RX_FIFO_NOT_EMPTY */
3187 if (REG_GET(dsidev
, DSI_VC_CTRL(channel
), 20, 20) == 0) {
3188 DSSERR("RX fifo empty when trying to read.\n");
3193 val
= dsi_read_reg(dsidev
, DSI_VC_SHORT_PACKET_HEADER(channel
));
3194 if (dsi
->debug_read
)
3195 DSSDBG("\theader: %08x\n", val
);
3196 dt
= FLD_GET(val
, 5, 0);
3197 if (dt
== DSI_DT_RX_ACK_WITH_ERR
) {
3198 u16 err
= FLD_GET(val
, 23, 8);
3199 dsi_show_rx_ack_with_err(err
);
3203 } else if (dt
== DSI_DT_RX_SHORT_READ_1
) {
3204 u8 data
= FLD_GET(val
, 15, 8);
3205 if (dsi
->debug_read
)
3206 DSSDBG("\tDCS short response, 1 byte: %02x\n", data
);
3216 } else if (dt
== DSI_DT_RX_SHORT_READ_2
) {
3217 u16 data
= FLD_GET(val
, 23, 8);
3218 if (dsi
->debug_read
)
3219 DSSDBG("\tDCS short response, 2 byte: %04x\n", data
);
3226 buf
[0] = data
& 0xff;
3227 buf
[1] = (data
>> 8) & 0xff;
3230 } else if (dt
== DSI_DT_RX_DCS_LONG_READ
) {
3232 int len
= FLD_GET(val
, 23, 8);
3233 if (dsi
->debug_read
)
3234 DSSDBG("\tDCS long response, len %d\n", len
);
3241 /* two byte checksum ends the packet, not included in len */
3242 for (w
= 0; w
< len
+ 2;) {
3244 val
= dsi_read_reg(dsidev
,
3245 DSI_VC_SHORT_PACKET_HEADER(channel
));
3246 if (dsi
->debug_read
)
3247 DSSDBG("\t\t%02x %02x %02x %02x\n",
3251 (val
>> 24) & 0xff);
3253 for (b
= 0; b
< 4; ++b
) {
3255 buf
[w
] = (val
>> (b
* 8)) & 0xff;
3256 /* we discard the 2 byte checksum */
3263 DSSERR("\tunknown datatype 0x%02x\n", dt
);
3270 DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n",
3275 EXPORT_SYMBOL(dsi_vc_dcs_read
);
3277 int dsi_vc_dcs_read_1(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3282 r
= dsi_vc_dcs_read(dssdev
, channel
, dcs_cmd
, data
, 1);
3292 EXPORT_SYMBOL(dsi_vc_dcs_read_1
);
3294 int dsi_vc_dcs_read_2(struct omap_dss_device
*dssdev
, int channel
, u8 dcs_cmd
,
3295 u8
*data1
, u8
*data2
)
3300 r
= dsi_vc_dcs_read(dssdev
, channel
, dcs_cmd
, buf
, 2);
3313 EXPORT_SYMBOL(dsi_vc_dcs_read_2
);
3315 int dsi_vc_set_max_rx_packet_size(struct omap_dss_device
*dssdev
, int channel
,
3318 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3320 return dsi_vc_send_short(dsidev
, channel
, DSI_DT_SET_MAX_RET_PKG_SIZE
,
3323 EXPORT_SYMBOL(dsi_vc_set_max_rx_packet_size
);
3325 static int dsi_enter_ulps(struct platform_device
*dsidev
)
3327 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3328 DECLARE_COMPLETION_ONSTACK(completion
);
3333 WARN_ON(!dsi_bus_is_locked(dsidev
));
3335 WARN_ON(dsi
->ulps_enabled
);
3337 if (dsi
->ulps_enabled
)
3340 if (REG_GET(dsidev
, DSI_CLK_CTRL
, 13, 13)) {
3341 DSSERR("DDR_CLK_ALWAYS_ON enabled when entering ULPS\n");
3345 dsi_sync_vc(dsidev
, 0);
3346 dsi_sync_vc(dsidev
, 1);
3347 dsi_sync_vc(dsidev
, 2);
3348 dsi_sync_vc(dsidev
, 3);
3350 dsi_force_tx_stop_mode_io(dsidev
);
3352 dsi_vc_enable(dsidev
, 0, false);
3353 dsi_vc_enable(dsidev
, 1, false);
3354 dsi_vc_enable(dsidev
, 2, false);
3355 dsi_vc_enable(dsidev
, 3, false);
3357 if (REG_GET(dsidev
, DSI_COMPLEXIO_CFG2
, 16, 16)) { /* HS_BUSY */
3358 DSSERR("HS busy when enabling ULPS\n");
3362 if (REG_GET(dsidev
, DSI_COMPLEXIO_CFG2
, 17, 17)) { /* LP_BUSY */
3363 DSSERR("LP busy when enabling ULPS\n");
3367 r
= dsi_register_isr_cio(dsidev
, dsi_completion_handler
, &completion
,
3368 DSI_CIO_IRQ_ULPSACTIVENOT_ALL0
);
3372 /* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */
3373 /* LANEx_ULPS_SIG2 */
3374 REG_FLD_MOD(dsidev
, DSI_COMPLEXIO_CFG2
, (1 << 0) | (1 << 1) | (1 << 2),
3377 if (wait_for_completion_timeout(&completion
,
3378 msecs_to_jiffies(1000)) == 0) {
3379 DSSERR("ULPS enable timeout\n");
3384 dsi_unregister_isr_cio(dsidev
, dsi_completion_handler
, &completion
,
3385 DSI_CIO_IRQ_ULPSACTIVENOT_ALL0
);
3387 /* Reset LANEx_ULPS_SIG2 */
3388 REG_FLD_MOD(dsidev
, DSI_COMPLEXIO_CFG2
, (0 << 0) | (0 << 1) | (0 << 2),
3391 dsi_cio_power(dsidev
, DSI_COMPLEXIO_POWER_ULPS
);
3393 dsi_if_enable(dsidev
, false);
3395 dsi
->ulps_enabled
= true;
3400 dsi_unregister_isr_cio(dsidev
, dsi_completion_handler
, &completion
,
3401 DSI_CIO_IRQ_ULPSACTIVENOT_ALL0
);
3405 static void dsi_set_lp_rx_timeout(struct platform_device
*dsidev
,
3406 unsigned ticks
, bool x4
, bool x16
)
3409 unsigned long total_ticks
;
3412 BUG_ON(ticks
> 0x1fff);
3414 /* ticks in DSI_FCK */
3415 fck
= dsi_fclk_rate(dsidev
);
3417 r
= dsi_read_reg(dsidev
, DSI_TIMING2
);
3418 r
= FLD_MOD(r
, 1, 15, 15); /* LP_RX_TO */
3419 r
= FLD_MOD(r
, x16
? 1 : 0, 14, 14); /* LP_RX_TO_X16 */
3420 r
= FLD_MOD(r
, x4
? 1 : 0, 13, 13); /* LP_RX_TO_X4 */
3421 r
= FLD_MOD(r
, ticks
, 12, 0); /* LP_RX_COUNTER */
3422 dsi_write_reg(dsidev
, DSI_TIMING2
, r
);
3424 total_ticks
= ticks
* (x16
? 16 : 1) * (x4
? 4 : 1);
3426 DSSDBG("LP_RX_TO %lu ticks (%#x%s%s) = %lu ns\n",
3428 ticks
, x4
? " x4" : "", x16
? " x16" : "",
3429 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3432 static void dsi_set_ta_timeout(struct platform_device
*dsidev
, unsigned ticks
,
3436 unsigned long total_ticks
;
3439 BUG_ON(ticks
> 0x1fff);
3441 /* ticks in DSI_FCK */
3442 fck
= dsi_fclk_rate(dsidev
);
3444 r
= dsi_read_reg(dsidev
, DSI_TIMING1
);
3445 r
= FLD_MOD(r
, 1, 31, 31); /* TA_TO */
3446 r
= FLD_MOD(r
, x16
? 1 : 0, 30, 30); /* TA_TO_X16 */
3447 r
= FLD_MOD(r
, x8
? 1 : 0, 29, 29); /* TA_TO_X8 */
3448 r
= FLD_MOD(r
, ticks
, 28, 16); /* TA_TO_COUNTER */
3449 dsi_write_reg(dsidev
, DSI_TIMING1
, r
);
3451 total_ticks
= ticks
* (x16
? 16 : 1) * (x8
? 8 : 1);
3453 DSSDBG("TA_TO %lu ticks (%#x%s%s) = %lu ns\n",
3455 ticks
, x8
? " x8" : "", x16
? " x16" : "",
3456 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3459 static void dsi_set_stop_state_counter(struct platform_device
*dsidev
,
3460 unsigned ticks
, bool x4
, bool x16
)
3463 unsigned long total_ticks
;
3466 BUG_ON(ticks
> 0x1fff);
3468 /* ticks in DSI_FCK */
3469 fck
= dsi_fclk_rate(dsidev
);
3471 r
= dsi_read_reg(dsidev
, DSI_TIMING1
);
3472 r
= FLD_MOD(r
, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
3473 r
= FLD_MOD(r
, x16
? 1 : 0, 14, 14); /* STOP_STATE_X16_IO */
3474 r
= FLD_MOD(r
, x4
? 1 : 0, 13, 13); /* STOP_STATE_X4_IO */
3475 r
= FLD_MOD(r
, ticks
, 12, 0); /* STOP_STATE_COUNTER_IO */
3476 dsi_write_reg(dsidev
, DSI_TIMING1
, r
);
3478 total_ticks
= ticks
* (x16
? 16 : 1) * (x4
? 4 : 1);
3480 DSSDBG("STOP_STATE_COUNTER %lu ticks (%#x%s%s) = %lu ns\n",
3482 ticks
, x4
? " x4" : "", x16
? " x16" : "",
3483 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3486 static void dsi_set_hs_tx_timeout(struct platform_device
*dsidev
,
3487 unsigned ticks
, bool x4
, bool x16
)
3490 unsigned long total_ticks
;
3493 BUG_ON(ticks
> 0x1fff);
3495 /* ticks in TxByteClkHS */
3496 fck
= dsi_get_txbyteclkhs(dsidev
);
3498 r
= dsi_read_reg(dsidev
, DSI_TIMING2
);
3499 r
= FLD_MOD(r
, 1, 31, 31); /* HS_TX_TO */
3500 r
= FLD_MOD(r
, x16
? 1 : 0, 30, 30); /* HS_TX_TO_X16 */
3501 r
= FLD_MOD(r
, x4
? 1 : 0, 29, 29); /* HS_TX_TO_X8 (4 really) */
3502 r
= FLD_MOD(r
, ticks
, 28, 16); /* HS_TX_TO_COUNTER */
3503 dsi_write_reg(dsidev
, DSI_TIMING2
, r
);
3505 total_ticks
= ticks
* (x16
? 16 : 1) * (x4
? 4 : 1);
3507 DSSDBG("HS_TX_TO %lu ticks (%#x%s%s) = %lu ns\n",
3509 ticks
, x4
? " x4" : "", x16
? " x16" : "",
3510 (total_ticks
* 1000) / (fck
/ 1000 / 1000));
3512 static int dsi_proto_config(struct omap_dss_device
*dssdev
)
3514 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3518 dsi_config_tx_fifo(dsidev
, DSI_FIFO_SIZE_32
,
3523 dsi_config_rx_fifo(dsidev
, DSI_FIFO_SIZE_32
,
3528 /* XXX what values for the timeouts? */
3529 dsi_set_stop_state_counter(dsidev
, 0x1000, false, false);
3530 dsi_set_ta_timeout(dsidev
, 0x1fff, true, true);
3531 dsi_set_lp_rx_timeout(dsidev
, 0x1fff, true, true);
3532 dsi_set_hs_tx_timeout(dsidev
, 0x1fff, true, true);
3534 switch (dssdev
->ctrl
.pixel_size
) {
3548 r
= dsi_read_reg(dsidev
, DSI_CTRL
);
3549 r
= FLD_MOD(r
, 1, 1, 1); /* CS_RX_EN */
3550 r
= FLD_MOD(r
, 1, 2, 2); /* ECC_RX_EN */
3551 r
= FLD_MOD(r
, 1, 3, 3); /* TX_FIFO_ARBITRATION */
3552 r
= FLD_MOD(r
, 1, 4, 4); /* VP_CLK_RATIO, always 1, see errata*/
3553 r
= FLD_MOD(r
, buswidth
, 7, 6); /* VP_DATA_BUS_WIDTH */
3554 r
= FLD_MOD(r
, 0, 8, 8); /* VP_CLK_POL */
3555 r
= FLD_MOD(r
, 2, 13, 12); /* LINE_BUFFER, 2 lines */
3556 r
= FLD_MOD(r
, 1, 14, 14); /* TRIGGER_RESET_MODE */
3557 r
= FLD_MOD(r
, 1, 19, 19); /* EOT_ENABLE */
3558 if (!dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC
)) {
3559 r
= FLD_MOD(r
, 1, 24, 24); /* DCS_CMD_ENABLE */
3560 /* DCS_CMD_CODE, 1=start, 0=continue */
3561 r
= FLD_MOD(r
, 0, 25, 25);
3564 dsi_write_reg(dsidev
, DSI_CTRL
, r
);
3566 dsi_vc_initial_config(dsidev
, 0);
3567 dsi_vc_initial_config(dsidev
, 1);
3568 dsi_vc_initial_config(dsidev
, 2);
3569 dsi_vc_initial_config(dsidev
, 3);
3574 static void dsi_proto_timings(struct omap_dss_device
*dssdev
)
3576 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3577 unsigned tlpx
, tclk_zero
, tclk_prepare
, tclk_trail
;
3578 unsigned tclk_pre
, tclk_post
;
3579 unsigned ths_prepare
, ths_prepare_ths_zero
, ths_zero
;
3580 unsigned ths_trail
, ths_exit
;
3581 unsigned ddr_clk_pre
, ddr_clk_post
;
3582 unsigned enter_hs_mode_lat
, exit_hs_mode_lat
;
3586 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG0
);
3587 ths_prepare
= FLD_GET(r
, 31, 24);
3588 ths_prepare_ths_zero
= FLD_GET(r
, 23, 16);
3589 ths_zero
= ths_prepare_ths_zero
- ths_prepare
;
3590 ths_trail
= FLD_GET(r
, 15, 8);
3591 ths_exit
= FLD_GET(r
, 7, 0);
3593 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG1
);
3594 tlpx
= FLD_GET(r
, 22, 16) * 2;
3595 tclk_trail
= FLD_GET(r
, 15, 8);
3596 tclk_zero
= FLD_GET(r
, 7, 0);
3598 r
= dsi_read_reg(dsidev
, DSI_DSIPHY_CFG2
);
3599 tclk_prepare
= FLD_GET(r
, 7, 0);
3603 /* min 60ns + 52*UI */
3604 tclk_post
= ns2ddr(dsidev
, 60) + 26;
3606 ths_eot
= DIV_ROUND_UP(4, dsi_get_num_data_lanes_dssdev(dssdev
));
3608 ddr_clk_pre
= DIV_ROUND_UP(tclk_pre
+ tlpx
+ tclk_zero
+ tclk_prepare
,
3610 ddr_clk_post
= DIV_ROUND_UP(tclk_post
+ ths_trail
, 4) + ths_eot
;
3612 BUG_ON(ddr_clk_pre
== 0 || ddr_clk_pre
> 255);
3613 BUG_ON(ddr_clk_post
== 0 || ddr_clk_post
> 255);
3615 r
= dsi_read_reg(dsidev
, DSI_CLK_TIMING
);
3616 r
= FLD_MOD(r
, ddr_clk_pre
, 15, 8);
3617 r
= FLD_MOD(r
, ddr_clk_post
, 7, 0);
3618 dsi_write_reg(dsidev
, DSI_CLK_TIMING
, r
);
3620 DSSDBG("ddr_clk_pre %u, ddr_clk_post %u\n",
3624 enter_hs_mode_lat
= 1 + DIV_ROUND_UP(tlpx
, 4) +
3625 DIV_ROUND_UP(ths_prepare
, 4) +
3626 DIV_ROUND_UP(ths_zero
+ 3, 4);
3628 exit_hs_mode_lat
= DIV_ROUND_UP(ths_trail
+ ths_exit
, 4) + 1 + ths_eot
;
3630 r
= FLD_VAL(enter_hs_mode_lat
, 31, 16) |
3631 FLD_VAL(exit_hs_mode_lat
, 15, 0);
3632 dsi_write_reg(dsidev
, DSI_VM_TIMING7
, r
);
3634 DSSDBG("enter_hs_mode_lat %u, exit_hs_mode_lat %u\n",
3635 enter_hs_mode_lat
, exit_hs_mode_lat
);
3639 #define DSI_DECL_VARS \
3640 int __dsi_cb = 0; u32 __dsi_cv = 0;
3642 #define DSI_FLUSH(dsidev, ch) \
3643 if (__dsi_cb > 0) { \
3644 /*DSSDBG("sending long packet %#010x\n", __dsi_cv);*/ \
3645 dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_PAYLOAD(ch), __dsi_cv); \
3646 __dsi_cb = __dsi_cv = 0; \
3649 #define DSI_PUSH(dsidev, ch, data) \
3651 __dsi_cv |= (data) << (__dsi_cb * 8); \
3652 /*DSSDBG("cv = %#010x, cb = %d\n", __dsi_cv, __dsi_cb);*/ \
3653 if (++__dsi_cb > 3) \
3654 DSI_FLUSH(dsidev, ch); \
3657 static int dsi_update_screen_l4(struct omap_dss_device
*dssdev
,
3658 int x
, int y
, int w
, int h
)
3660 /* Note: supports only 24bit colors in 32bit container */
3661 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3662 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3664 int fifo_stalls
= 0;
3665 int max_dsi_packet_size
;
3666 int max_data_per_packet
;
3667 int max_pixels_per_packet
;
3669 int bytespp
= dssdev
->ctrl
.pixel_size
/ 8;
3675 struct omap_overlay
*ovl
;
3679 DSSDBG("dsi_update_screen_l4 (%d,%d %dx%d)\n",
3682 ovl
= dssdev
->manager
->overlays
[0];
3684 if (ovl
->info
.color_mode
!= OMAP_DSS_COLOR_RGB24U
)
3687 if (dssdev
->ctrl
.pixel_size
!= 24)
3690 scr_width
= ovl
->info
.screen_width
;
3691 data
= ovl
->info
.vaddr
;
3693 start_offset
= scr_width
* y
+ x
;
3694 horiz_inc
= scr_width
- w
;
3697 /* We need header(4) + DCSCMD(1) + pixels(numpix*bytespp) bytes
3700 /* When using CPU, max long packet size is TX buffer size */
3701 max_dsi_packet_size
= dsi
->vc
[0].fifo_size
* 32 * 4;
3703 /* we seem to get better perf if we divide the tx fifo to half,
3704 and while the other half is being sent, we fill the other half
3705 max_dsi_packet_size /= 2; */
3707 max_data_per_packet
= max_dsi_packet_size
- 4 - 1;
3709 max_pixels_per_packet
= max_data_per_packet
/ bytespp
;
3711 DSSDBG("max_pixels_per_packet %d\n", max_pixels_per_packet
);
3713 pixels_left
= w
* h
;
3715 DSSDBG("total pixels %d\n", pixels_left
);
3717 data
+= start_offset
;
3719 while (pixels_left
> 0) {
3720 /* 0x2c = write_memory_start */
3721 /* 0x3c = write_memory_continue */
3722 u8 dcs_cmd
= first
? 0x2c : 0x3c;
3728 /* using fifo not empty */
3729 /* TX_FIFO_NOT_EMPTY */
3730 while (FLD_GET(dsi_read_reg(dsidev
, DSI_VC_CTRL(0)), 5, 5)) {
3732 if (fifo_stalls
> 0xfffff) {
3733 DSSERR("fifo stalls overflow, pixels left %d\n",
3735 dsi_if_enable(dsidev
, 0);
3741 /* using fifo emptiness */
3742 while ((REG_GET(dsidev
, DSI_TX_FIFO_VC_EMPTINESS
, 7, 0)+1)*4 <
3743 max_dsi_packet_size
) {
3745 if (fifo_stalls
> 0xfffff) {
3746 DSSERR("fifo stalls overflow, pixels left %d\n",
3748 dsi_if_enable(dsidev
, 0);
3753 while ((REG_GET(dsidev
, DSI_TX_FIFO_VC_EMPTINESS
,
3754 7, 0) + 1) * 4 == 0) {
3756 if (fifo_stalls
> 0xfffff) {
3757 DSSERR("fifo stalls overflow, pixels left %d\n",
3759 dsi_if_enable(dsidev
, 0);
3764 pixels
= min(max_pixels_per_packet
, pixels_left
);
3766 pixels_left
-= pixels
;
3768 dsi_vc_write_long_header(dsidev
, 0, DSI_DT_DCS_LONG_WRITE
,
3769 1 + pixels
* bytespp
, 0);
3771 DSI_PUSH(dsidev
, 0, dcs_cmd
);
3773 while (pixels
-- > 0) {
3774 u32 pix
= __raw_readl(data
++);
3776 DSI_PUSH(dsidev
, 0, (pix
>> 16) & 0xff);
3777 DSI_PUSH(dsidev
, 0, (pix
>> 8) & 0xff);
3778 DSI_PUSH(dsidev
, 0, (pix
>> 0) & 0xff);
3781 if (current_x
== x
+w
) {
3787 DSI_FLUSH(dsidev
, 0);
3793 static void dsi_update_screen_dispc(struct omap_dss_device
*dssdev
,
3794 u16 x
, u16 y
, u16 w
, u16 h
)
3796 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3797 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3802 unsigned packet_payload
;
3803 unsigned packet_len
;
3806 const unsigned channel
= dsi
->update_channel
;
3807 const unsigned line_buf_size
= dsi_get_line_buf_size(dsidev
);
3809 DSSDBG("dsi_update_screen_dispc(%d,%d %dx%d)\n",
3812 dsi_vc_config_vp(dsidev
, channel
);
3814 bytespp
= dssdev
->ctrl
.pixel_size
/ 8;
3815 bytespl
= w
* bytespp
;
3816 bytespf
= bytespl
* h
;
3818 /* NOTE: packet_payload has to be equal to N * bytespl, where N is
3819 * number of lines in a packet. See errata about VP_CLK_RATIO */
3821 if (bytespf
< line_buf_size
)
3822 packet_payload
= bytespf
;
3824 packet_payload
= (line_buf_size
) / bytespl
* bytespl
;
3826 packet_len
= packet_payload
+ 1; /* 1 byte for DCS cmd */
3827 total_len
= (bytespf
/ packet_payload
) * packet_len
;
3829 if (bytespf
% packet_payload
)
3830 total_len
+= (bytespf
% packet_payload
) + 1;
3832 l
= FLD_VAL(total_len
, 23, 0); /* TE_SIZE */
3833 dsi_write_reg(dsidev
, DSI_VC_TE(channel
), l
);
3835 dsi_vc_write_long_header(dsidev
, channel
, DSI_DT_DCS_LONG_WRITE
,
3838 if (dsi
->te_enabled
)
3839 l
= FLD_MOD(l
, 1, 30, 30); /* TE_EN */
3841 l
= FLD_MOD(l
, 1, 31, 31); /* TE_START */
3842 dsi_write_reg(dsidev
, DSI_VC_TE(channel
), l
);
3844 /* We put SIDLEMODE to no-idle for the duration of the transfer,
3845 * because DSS interrupts are not capable of waking up the CPU and the
3846 * framedone interrupt could be delayed for quite a long time. I think
3847 * the same goes for any DSS interrupts, but for some reason I have not
3848 * seen the problem anywhere else than here.
3850 dispc_disable_sidle();
3852 dsi_perf_mark_start(dsidev
);
3854 r
= schedule_delayed_work(&dsi
->framedone_timeout_work
,
3855 msecs_to_jiffies(250));
3858 dss_start_update(dssdev
);
3860 if (dsi
->te_enabled
) {
3861 /* disable LP_RX_TO, so that we can receive TE. Time to wait
3862 * for TE is longer than the timer allows */
3863 REG_FLD_MOD(dsidev
, DSI_TIMING2
, 0, 15, 15); /* LP_RX_TO */
3865 dsi_vc_send_bta(dsidev
, channel
);
3867 #ifdef DSI_CATCH_MISSING_TE
3868 mod_timer(&dsi
->te_timer
, jiffies
+ msecs_to_jiffies(250));
3873 #ifdef DSI_CATCH_MISSING_TE
3874 static void dsi_te_timeout(unsigned long arg
)
3876 DSSERR("TE not received for 250ms!\n");
3880 static void dsi_handle_framedone(struct platform_device
*dsidev
, int error
)
3882 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3884 /* SIDLEMODE back to smart-idle */
3885 dispc_enable_sidle();
3887 if (dsi
->te_enabled
) {
3888 /* enable LP_RX_TO again after the TE */
3889 REG_FLD_MOD(dsidev
, DSI_TIMING2
, 1, 15, 15); /* LP_RX_TO */
3892 dsi
->framedone_callback(error
, dsi
->framedone_data
);
3895 dsi_perf_show(dsidev
, "DISPC");
3898 static void dsi_framedone_timeout_work_callback(struct work_struct
*work
)
3900 struct dsi_data
*dsi
= container_of(work
, struct dsi_data
,
3901 framedone_timeout_work
.work
);
3902 /* XXX While extremely unlikely, we could get FRAMEDONE interrupt after
3903 * 250ms which would conflict with this timeout work. What should be
3904 * done is first cancel the transfer on the HW, and then cancel the
3905 * possibly scheduled framedone work. However, cancelling the transfer
3906 * on the HW is buggy, and would probably require resetting the whole
3909 DSSERR("Framedone not received for 250ms!\n");
3911 dsi_handle_framedone(dsi
->pdev
, -ETIMEDOUT
);
3914 static void dsi_framedone_irq_callback(void *data
, u32 mask
)
3916 struct omap_dss_device
*dssdev
= (struct omap_dss_device
*) data
;
3917 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3918 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3920 /* Note: We get FRAMEDONE when DISPC has finished sending pixels and
3921 * turns itself off. However, DSI still has the pixels in its buffers,
3922 * and is sending the data.
3925 __cancel_delayed_work(&dsi
->framedone_timeout_work
);
3927 dsi_handle_framedone(dsidev
, 0);
3929 #ifdef CONFIG_OMAP2_DSS_FAKE_VSYNC
3930 dispc_fake_vsync_irq();
3934 int omap_dsi_prepare_update(struct omap_dss_device
*dssdev
,
3935 u16
*x
, u16
*y
, u16
*w
, u16
*h
,
3936 bool enlarge_update_area
)
3938 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3941 dssdev
->driver
->get_resolution(dssdev
, &dw
, &dh
);
3943 if (*x
> dw
|| *y
> dh
)
3955 if (*w
== 0 || *h
== 0)
3958 dsi_perf_mark_setup(dsidev
);
3960 if (dssdev
->manager
->caps
& OMAP_DSS_OVL_MGR_CAP_DISPC
) {
3961 dss_setup_partial_planes(dssdev
, x
, y
, w
, h
,
3962 enlarge_update_area
);
3963 dispc_set_lcd_size(dssdev
->manager
->id
, *w
, *h
);
3968 EXPORT_SYMBOL(omap_dsi_prepare_update
);
3970 int omap_dsi_update(struct omap_dss_device
*dssdev
,
3972 u16 x
, u16 y
, u16 w
, u16 h
,
3973 void (*callback
)(int, void *), void *data
)
3975 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
3976 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
3978 dsi
->update_channel
= channel
;
3980 /* OMAP DSS cannot send updates of odd widths.
3981 * omap_dsi_prepare_update() makes the widths even, but add a BUG_ON
3982 * here to make sure we catch erroneous updates. Otherwise we'll only
3983 * see rather obscure HW error happening, as DSS halts. */
3986 if (dssdev
->manager
->caps
& OMAP_DSS_OVL_MGR_CAP_DISPC
) {
3987 dsi
->framedone_callback
= callback
;
3988 dsi
->framedone_data
= data
;
3990 dsi
->update_region
.x
= x
;
3991 dsi
->update_region
.y
= y
;
3992 dsi
->update_region
.w
= w
;
3993 dsi
->update_region
.h
= h
;
3994 dsi
->update_region
.device
= dssdev
;
3996 dsi_update_screen_dispc(dssdev
, x
, y
, w
, h
);
4000 r
= dsi_update_screen_l4(dssdev
, x
, y
, w
, h
);
4004 dsi_perf_show(dsidev
, "L4");
4010 EXPORT_SYMBOL(omap_dsi_update
);
4014 static int dsi_display_init_dispc(struct omap_dss_device
*dssdev
)
4019 irq
= dssdev
->manager
->id
== OMAP_DSS_CHANNEL_LCD
?
4020 DISPC_IRQ_FRAMEDONE
: DISPC_IRQ_FRAMEDONE2
;
4022 r
= omap_dispc_register_isr(dsi_framedone_irq_callback
, (void *) dssdev
,
4025 DSSERR("can't get FRAMEDONE irq\n");
4029 dispc_set_lcd_display_type(dssdev
->manager
->id
,
4030 OMAP_DSS_LCD_DISPLAY_TFT
);
4032 dispc_set_parallel_interface_mode(dssdev
->manager
->id
,
4033 OMAP_DSS_PARALLELMODE_DSI
);
4034 dispc_enable_fifohandcheck(dssdev
->manager
->id
, 1);
4036 dispc_set_tft_data_lines(dssdev
->manager
->id
, dssdev
->ctrl
.pixel_size
);
4039 struct omap_video_timings timings
= {
4048 dispc_set_lcd_timings(dssdev
->manager
->id
, &timings
);
4054 static void dsi_display_uninit_dispc(struct omap_dss_device
*dssdev
)
4058 irq
= dssdev
->manager
->id
== OMAP_DSS_CHANNEL_LCD
?
4059 DISPC_IRQ_FRAMEDONE
: DISPC_IRQ_FRAMEDONE2
;
4061 omap_dispc_unregister_isr(dsi_framedone_irq_callback
, (void *) dssdev
,
4065 static int dsi_configure_dsi_clocks(struct omap_dss_device
*dssdev
)
4067 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4068 struct dsi_clock_info cinfo
;
4071 /* we always use DSS_CLK_SYSCK as input clock */
4072 cinfo
.use_sys_clk
= true;
4073 cinfo
.regn
= dssdev
->clocks
.dsi
.regn
;
4074 cinfo
.regm
= dssdev
->clocks
.dsi
.regm
;
4075 cinfo
.regm_dispc
= dssdev
->clocks
.dsi
.regm_dispc
;
4076 cinfo
.regm_dsi
= dssdev
->clocks
.dsi
.regm_dsi
;
4077 r
= dsi_calc_clock_rates(dssdev
, &cinfo
);
4079 DSSERR("Failed to calc dsi clocks\n");
4083 r
= dsi_pll_set_clock_div(dsidev
, &cinfo
);
4085 DSSERR("Failed to set dsi clocks\n");
4092 static int dsi_configure_dispc_clocks(struct omap_dss_device
*dssdev
)
4094 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4095 struct dispc_clock_info dispc_cinfo
;
4097 unsigned long long fck
;
4099 fck
= dsi_get_pll_hsdiv_dispc_rate(dsidev
);
4101 dispc_cinfo
.lck_div
= dssdev
->clocks
.dispc
.channel
.lck_div
;
4102 dispc_cinfo
.pck_div
= dssdev
->clocks
.dispc
.channel
.pck_div
;
4104 r
= dispc_calc_clock_rates(fck
, &dispc_cinfo
);
4106 DSSERR("Failed to calc dispc clocks\n");
4110 r
= dispc_set_clock_div(dssdev
->manager
->id
, &dispc_cinfo
);
4112 DSSERR("Failed to set dispc clocks\n");
4119 static int dsi_display_init_dsi(struct omap_dss_device
*dssdev
)
4121 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4122 int dsi_module
= dsi_get_dsidev_id(dsidev
);
4125 r
= dsi_pll_init(dsidev
, true, true);
4129 r
= dsi_configure_dsi_clocks(dssdev
);
4133 dss_select_dispc_clk_source(dssdev
->clocks
.dispc
.dispc_fclk_src
);
4134 dss_select_dsi_clk_source(dsi_module
, dssdev
->clocks
.dsi
.dsi_fclk_src
);
4135 dss_select_lcd_clk_source(dssdev
->manager
->id
,
4136 dssdev
->clocks
.dispc
.channel
.lcd_clk_src
);
4140 r
= dsi_configure_dispc_clocks(dssdev
);
4144 r
= dsi_cio_init(dssdev
);
4148 _dsi_print_reset_status(dsidev
);
4150 dsi_proto_timings(dssdev
);
4151 dsi_set_lp_clk_divisor(dssdev
);
4154 _dsi_print_reset_status(dsidev
);
4156 r
= dsi_proto_config(dssdev
);
4160 /* enable interface */
4161 dsi_vc_enable(dsidev
, 0, 1);
4162 dsi_vc_enable(dsidev
, 1, 1);
4163 dsi_vc_enable(dsidev
, 2, 1);
4164 dsi_vc_enable(dsidev
, 3, 1);
4165 dsi_if_enable(dsidev
, 1);
4166 dsi_force_tx_stop_mode_io(dsidev
);
4170 dsi_cio_uninit(dsidev
);
4172 dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK
);
4173 dss_select_dsi_clk_source(dsi_module
, OMAP_DSS_CLK_SRC_FCK
);
4175 dsi_pll_uninit(dsidev
, true);
4180 static void dsi_display_uninit_dsi(struct omap_dss_device
*dssdev
,
4181 bool disconnect_lanes
, bool enter_ulps
)
4183 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4184 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4185 int dsi_module
= dsi_get_dsidev_id(dsidev
);
4187 if (enter_ulps
&& !dsi
->ulps_enabled
)
4188 dsi_enter_ulps(dsidev
);
4190 /* disable interface */
4191 dsi_if_enable(dsidev
, 0);
4192 dsi_vc_enable(dsidev
, 0, 0);
4193 dsi_vc_enable(dsidev
, 1, 0);
4194 dsi_vc_enable(dsidev
, 2, 0);
4195 dsi_vc_enable(dsidev
, 3, 0);
4197 dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK
);
4198 dss_select_dsi_clk_source(dsi_module
, OMAP_DSS_CLK_SRC_FCK
);
4199 dsi_cio_uninit(dsidev
);
4200 dsi_pll_uninit(dsidev
, disconnect_lanes
);
4203 int omapdss_dsi_display_enable(struct omap_dss_device
*dssdev
)
4205 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4206 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4209 DSSDBG("dsi_display_enable\n");
4211 WARN_ON(!dsi_bus_is_locked(dsidev
));
4213 mutex_lock(&dsi
->lock
);
4215 r
= omap_dss_start_device(dssdev
);
4217 DSSERR("failed to start device\n");
4221 r
= dsi_runtime_get(dsidev
);
4225 dsi_enable_pll_clock(dsidev
, 1);
4227 _dsi_initialize_irq(dsidev
);
4229 r
= dsi_display_init_dispc(dssdev
);
4231 goto err_init_dispc
;
4233 r
= dsi_display_init_dsi(dssdev
);
4237 mutex_unlock(&dsi
->lock
);
4242 dsi_display_uninit_dispc(dssdev
);
4244 dsi_enable_pll_clock(dsidev
, 0);
4245 dsi_runtime_put(dsidev
);
4247 omap_dss_stop_device(dssdev
);
4249 mutex_unlock(&dsi
->lock
);
4250 DSSDBG("dsi_display_enable FAILED\n");
4253 EXPORT_SYMBOL(omapdss_dsi_display_enable
);
4255 void omapdss_dsi_display_disable(struct omap_dss_device
*dssdev
,
4256 bool disconnect_lanes
, bool enter_ulps
)
4258 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4259 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4261 DSSDBG("dsi_display_disable\n");
4263 WARN_ON(!dsi_bus_is_locked(dsidev
));
4265 mutex_lock(&dsi
->lock
);
4267 dsi_sync_vc(dsidev
, 0);
4268 dsi_sync_vc(dsidev
, 1);
4269 dsi_sync_vc(dsidev
, 2);
4270 dsi_sync_vc(dsidev
, 3);
4272 dsi_display_uninit_dispc(dssdev
);
4274 dsi_display_uninit_dsi(dssdev
, disconnect_lanes
, enter_ulps
);
4276 dsi_runtime_put(dsidev
);
4277 dsi_enable_pll_clock(dsidev
, 0);
4279 omap_dss_stop_device(dssdev
);
4281 mutex_unlock(&dsi
->lock
);
4283 EXPORT_SYMBOL(omapdss_dsi_display_disable
);
4285 int omapdss_dsi_enable_te(struct omap_dss_device
*dssdev
, bool enable
)
4287 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4288 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4290 dsi
->te_enabled
= enable
;
4293 EXPORT_SYMBOL(omapdss_dsi_enable_te
);
4295 void dsi_get_overlay_fifo_thresholds(enum omap_plane plane
,
4296 u32 fifo_size
, u32 burst_size
,
4297 u32
*fifo_low
, u32
*fifo_high
)
4299 *fifo_high
= fifo_size
- burst_size
;
4300 *fifo_low
= fifo_size
- burst_size
* 2;
4303 int dsi_init_display(struct omap_dss_device
*dssdev
)
4305 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4306 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4307 int dsi_module
= dsi_get_dsidev_id(dsidev
);
4309 DSSDBG("DSI init\n");
4311 /* XXX these should be figured out dynamically */
4312 dssdev
->caps
= OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE
|
4313 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM
;
4315 if (dsi
->vdds_dsi_reg
== NULL
) {
4316 struct regulator
*vdds_dsi
;
4318 vdds_dsi
= regulator_get(&dsi
->pdev
->dev
, "vdds_dsi");
4320 if (IS_ERR(vdds_dsi
)) {
4321 DSSERR("can't get VDDS_DSI regulator\n");
4322 return PTR_ERR(vdds_dsi
);
4325 dsi
->vdds_dsi_reg
= vdds_dsi
;
4328 if (dsi_get_num_data_lanes_dssdev(dssdev
) > dsi
->num_data_lanes
) {
4329 DSSERR("DSI%d can't support more than %d data lanes\n",
4330 dsi_module
+ 1, dsi
->num_data_lanes
);
4337 int omap_dsi_request_vc(struct omap_dss_device
*dssdev
, int *channel
)
4339 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4340 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4343 for (i
= 0; i
< ARRAY_SIZE(dsi
->vc
); i
++) {
4344 if (!dsi
->vc
[i
].dssdev
) {
4345 dsi
->vc
[i
].dssdev
= dssdev
;
4351 DSSERR("cannot get VC for display %s", dssdev
->name
);
4354 EXPORT_SYMBOL(omap_dsi_request_vc
);
4356 int omap_dsi_set_vc_id(struct omap_dss_device
*dssdev
, int channel
, int vc_id
)
4358 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4359 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4361 if (vc_id
< 0 || vc_id
> 3) {
4362 DSSERR("VC ID out of range\n");
4366 if (channel
< 0 || channel
> 3) {
4367 DSSERR("Virtual Channel out of range\n");
4371 if (dsi
->vc
[channel
].dssdev
!= dssdev
) {
4372 DSSERR("Virtual Channel not allocated to display %s\n",
4377 dsi
->vc
[channel
].vc_id
= vc_id
;
4381 EXPORT_SYMBOL(omap_dsi_set_vc_id
);
4383 void omap_dsi_release_vc(struct omap_dss_device
*dssdev
, int channel
)
4385 struct platform_device
*dsidev
= dsi_get_dsidev_from_dssdev(dssdev
);
4386 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4388 if ((channel
>= 0 && channel
<= 3) &&
4389 dsi
->vc
[channel
].dssdev
== dssdev
) {
4390 dsi
->vc
[channel
].dssdev
= NULL
;
4391 dsi
->vc
[channel
].vc_id
= 0;
4394 EXPORT_SYMBOL(omap_dsi_release_vc
);
4396 void dsi_wait_pll_hsdiv_dispc_active(struct platform_device
*dsidev
)
4398 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 7, 1) != 1)
4399 DSSERR("%s (%s) not active\n",
4400 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
),
4401 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
));
4404 void dsi_wait_pll_hsdiv_dsi_active(struct platform_device
*dsidev
)
4406 if (wait_for_bit_change(dsidev
, DSI_PLL_STATUS
, 8, 1) != 1)
4407 DSSERR("%s (%s) not active\n",
4408 dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
),
4409 dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
));
4412 static void dsi_calc_clock_param_ranges(struct platform_device
*dsidev
)
4414 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4416 dsi
->regn_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGN
);
4417 dsi
->regm_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM
);
4418 dsi
->regm_dispc_max
=
4419 dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DISPC
);
4420 dsi
->regm_dsi_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DSI
);
4421 dsi
->fint_min
= dss_feat_get_param_min(FEAT_PARAM_DSIPLL_FINT
);
4422 dsi
->fint_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_FINT
);
4423 dsi
->lpdiv_max
= dss_feat_get_param_max(FEAT_PARAM_DSIPLL_LPDIV
);
4426 static int dsi_get_clocks(struct platform_device
*dsidev
)
4428 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4431 clk
= clk_get(&dsidev
->dev
, "fck");
4433 DSSERR("can't get fck\n");
4434 return PTR_ERR(clk
);
4439 if (cpu_is_omap34xx() || cpu_is_omap3630())
4440 clk
= clk_get(&dsidev
->dev
, "dss2_alwon_fck");
4442 clk
= clk_get(&dsidev
->dev
, "sys_clk");
4444 DSSERR("can't get sys_clk\n");
4445 clk_put(dsi
->dss_clk
);
4446 dsi
->dss_clk
= NULL
;
4447 return PTR_ERR(clk
);
4455 static void dsi_put_clocks(struct platform_device
*dsidev
)
4457 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4460 clk_put(dsi
->dss_clk
);
4462 clk_put(dsi
->sys_clk
);
4465 /* DSI1 HW IP initialisation */
4466 static int omap_dsi1hw_probe(struct platform_device
*dsidev
)
4468 struct omap_display_platform_data
*dss_plat_data
;
4469 struct omap_dss_board_info
*board_info
;
4471 int r
, i
, dsi_module
= dsi_get_dsidev_id(dsidev
);
4472 struct resource
*dsi_mem
;
4473 struct dsi_data
*dsi
;
4475 dsi
= kzalloc(sizeof(*dsi
), GFP_KERNEL
);
4482 dsi_pdev_map
[dsi_module
] = dsidev
;
4483 dev_set_drvdata(&dsidev
->dev
, dsi
);
4485 dss_plat_data
= dsidev
->dev
.platform_data
;
4486 board_info
= dss_plat_data
->board_data
;
4487 dsi
->dsi_mux_pads
= board_info
->dsi_mux_pads
;
4489 spin_lock_init(&dsi
->irq_lock
);
4490 spin_lock_init(&dsi
->errors_lock
);
4493 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
4494 spin_lock_init(&dsi
->irq_stats_lock
);
4495 dsi
->irq_stats
.last_reset
= jiffies
;
4498 mutex_init(&dsi
->lock
);
4499 sema_init(&dsi
->bus_lock
, 1);
4501 r
= dsi_get_clocks(dsidev
);
4505 pm_runtime_enable(&dsidev
->dev
);
4507 INIT_DELAYED_WORK_DEFERRABLE(&dsi
->framedone_timeout_work
,
4508 dsi_framedone_timeout_work_callback
);
4510 #ifdef DSI_CATCH_MISSING_TE
4511 init_timer(&dsi
->te_timer
);
4512 dsi
->te_timer
.function
= dsi_te_timeout
;
4513 dsi
->te_timer
.data
= 0;
4515 dsi_mem
= platform_get_resource(dsi
->pdev
, IORESOURCE_MEM
, 0);
4517 DSSERR("can't get IORESOURCE_MEM DSI\n");
4521 dsi
->base
= ioremap(dsi_mem
->start
, resource_size(dsi_mem
));
4523 DSSERR("can't ioremap DSI\n");
4527 dsi
->irq
= platform_get_irq(dsi
->pdev
, 0);
4529 DSSERR("platform_get_irq failed\n");
4534 r
= request_irq(dsi
->irq
, omap_dsi_irq_handler
, IRQF_SHARED
,
4535 dev_name(&dsidev
->dev
), dsi
->pdev
);
4537 DSSERR("request_irq failed\n");
4541 /* DSI VCs initialization */
4542 for (i
= 0; i
< ARRAY_SIZE(dsi
->vc
); i
++) {
4543 dsi
->vc
[i
].mode
= DSI_VC_MODE_L4
;
4544 dsi
->vc
[i
].dssdev
= NULL
;
4545 dsi
->vc
[i
].vc_id
= 0;
4548 dsi_calc_clock_param_ranges(dsidev
);
4550 r
= dsi_runtime_get(dsidev
);
4554 rev
= dsi_read_reg(dsidev
, DSI_REVISION
);
4555 dev_dbg(&dsidev
->dev
, "OMAP DSI rev %d.%d\n",
4556 FLD_GET(rev
, 7, 4), FLD_GET(rev
, 3, 0));
4558 dsi
->num_data_lanes
= dsi_get_num_data_lanes(dsidev
);
4560 dsi_runtime_put(dsidev
);
4565 free_irq(dsi
->irq
, dsi
->pdev
);
4569 pm_runtime_disable(&dsidev
->dev
);
4576 static int omap_dsi1hw_remove(struct platform_device
*dsidev
)
4578 struct dsi_data
*dsi
= dsi_get_dsidrv_data(dsidev
);
4580 WARN_ON(dsi
->scp_clk_refcount
> 0);
4582 pm_runtime_disable(&dsidev
->dev
);
4584 dsi_put_clocks(dsidev
);
4586 if (dsi
->vdds_dsi_reg
!= NULL
) {
4587 if (dsi
->vdds_dsi_enabled
) {
4588 regulator_disable(dsi
->vdds_dsi_reg
);
4589 dsi
->vdds_dsi_enabled
= false;
4592 regulator_put(dsi
->vdds_dsi_reg
);
4593 dsi
->vdds_dsi_reg
= NULL
;
4596 free_irq(dsi
->irq
, dsi
->pdev
);
4604 static int dsi_runtime_suspend(struct device
*dev
)
4606 struct dsi_data
*dsi
= dsi_get_dsidrv_data(to_platform_device(dev
));
4608 clk_disable(dsi
->dss_clk
);
4610 dispc_runtime_put();
4616 static int dsi_runtime_resume(struct device
*dev
)
4618 struct dsi_data
*dsi
= dsi_get_dsidrv_data(to_platform_device(dev
));
4621 r
= dss_runtime_get();
4625 r
= dispc_runtime_get();
4629 clk_enable(dsi
->dss_clk
);
4639 static const struct dev_pm_ops dsi_pm_ops
= {
4640 .runtime_suspend
= dsi_runtime_suspend
,
4641 .runtime_resume
= dsi_runtime_resume
,
4644 static struct platform_driver omap_dsi1hw_driver
= {
4645 .probe
= omap_dsi1hw_probe
,
4646 .remove
= omap_dsi1hw_remove
,
4648 .name
= "omapdss_dsi1",
4649 .owner
= THIS_MODULE
,
4654 int dsi_init_platform_driver(void)
4656 return platform_driver_register(&omap_dsi1hw_driver
);
4659 void dsi_uninit_platform_driver(void)
4661 return platform_driver_unregister(&omap_dsi1hw_driver
);