2 * linux/drivers/video/omap2/dss/dss.c
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
7 * Some code and ideas taken from drivers/video/omap/ driver
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
23 #define DSS_SUBSYS_NAME "DSS"
25 #include <linux/kernel.h>
27 #include <linux/export.h>
28 #include <linux/err.h>
29 #include <linux/delay.h>
30 #include <linux/seq_file.h>
31 #include <linux/clk.h>
32 #include <linux/platform_device.h>
33 #include <linux/pm_runtime.h>
34 #include <linux/gfp.h>
35 #include <linux/sizes.h>
37 #include <video/omapdss.h>
40 #include "dss_features.h"
42 #define DSS_SZ_REGS SZ_512
48 #define DSS_REG(idx) ((const struct dss_reg) { idx })
50 #define DSS_REVISION DSS_REG(0x0000)
51 #define DSS_SYSCONFIG DSS_REG(0x0010)
52 #define DSS_SYSSTATUS DSS_REG(0x0014)
53 #define DSS_CONTROL DSS_REG(0x0040)
54 #define DSS_SDI_CONTROL DSS_REG(0x0044)
55 #define DSS_PLL_CONTROL DSS_REG(0x0048)
56 #define DSS_SDI_STATUS DSS_REG(0x005C)
58 #define REG_GET(idx, start, end) \
59 FLD_GET(dss_read_reg(idx), start, end)
61 #define REG_FLD_MOD(idx, val, start, end) \
62 dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
64 static int dss_runtime_get(void);
65 static void dss_runtime_put(void);
69 u8 dss_fck_multiplier
;
71 int (*dpi_select_source
)(enum omap_channel channel
);
75 struct platform_device
*pdev
;
78 struct clk
*dpll4_m4_ck
;
80 unsigned long dss_clk_rate
;
82 unsigned long cache_req_pck
;
83 unsigned long cache_prate
;
84 struct dss_clock_info cache_dss_cinfo
;
85 struct dispc_clock_info cache_dispc_cinfo
;
87 enum omap_dss_clk_source dsi_clk_source
[MAX_NUM_DSI
];
88 enum omap_dss_clk_source dispc_clk_source
;
89 enum omap_dss_clk_source lcd_clk_source
[MAX_DSS_LCD_MANAGERS
];
92 u32 ctx
[DSS_SZ_REGS
/ sizeof(u32
)];
94 const struct dss_features
*feat
;
97 static const char * const dss_generic_clk_source_names
[] = {
98 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
] = "DSI_PLL_HSDIV_DISPC",
99 [OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
] = "DSI_PLL_HSDIV_DSI",
100 [OMAP_DSS_CLK_SRC_FCK
] = "DSS_FCK",
101 [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC
] = "DSI_PLL2_HSDIV_DISPC",
102 [OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI
] = "DSI_PLL2_HSDIV_DSI",
105 static inline void dss_write_reg(const struct dss_reg idx
, u32 val
)
107 __raw_writel(val
, dss
.base
+ idx
.idx
);
110 static inline u32
dss_read_reg(const struct dss_reg idx
)
112 return __raw_readl(dss
.base
+ idx
.idx
);
116 dss.ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(DSS_##reg)
118 dss_write_reg(DSS_##reg, dss.ctx[(DSS_##reg).idx / sizeof(u32)])
120 static void dss_save_context(void)
122 DSSDBG("dss_save_context\n");
126 if (dss_feat_get_supported_displays(OMAP_DSS_CHANNEL_LCD
) &
127 OMAP_DISPLAY_TYPE_SDI
) {
132 dss
.ctx_valid
= true;
134 DSSDBG("context saved\n");
137 static void dss_restore_context(void)
139 DSSDBG("dss_restore_context\n");
146 if (dss_feat_get_supported_displays(OMAP_DSS_CHANNEL_LCD
) &
147 OMAP_DISPLAY_TYPE_SDI
) {
152 DSSDBG("context restored\n");
158 int dss_get_ctx_loss_count(void)
160 struct platform_device
*core_pdev
= dss_get_core_pdev();
161 struct omap_dss_board_info
*board_data
= core_pdev
->dev
.platform_data
;
164 if (!board_data
->get_context_loss_count
)
167 cnt
= board_data
->get_context_loss_count(&dss
.pdev
->dev
);
169 WARN_ONCE(cnt
< 0, "get_context_loss_count failed: %d\n", cnt
);
174 void dss_sdi_init(int datapairs
)
178 BUG_ON(datapairs
> 3 || datapairs
< 1);
180 l
= dss_read_reg(DSS_SDI_CONTROL
);
181 l
= FLD_MOD(l
, 0xf, 19, 15); /* SDI_PDIV */
182 l
= FLD_MOD(l
, datapairs
-1, 3, 2); /* SDI_PRSEL */
183 l
= FLD_MOD(l
, 2, 1, 0); /* SDI_BWSEL */
184 dss_write_reg(DSS_SDI_CONTROL
, l
);
186 l
= dss_read_reg(DSS_PLL_CONTROL
);
187 l
= FLD_MOD(l
, 0x7, 25, 22); /* SDI_PLL_FREQSEL */
188 l
= FLD_MOD(l
, 0xb, 16, 11); /* SDI_PLL_REGN */
189 l
= FLD_MOD(l
, 0xb4, 10, 1); /* SDI_PLL_REGM */
190 dss_write_reg(DSS_PLL_CONTROL
, l
);
193 int dss_sdi_enable(void)
195 unsigned long timeout
;
197 dispc_pck_free_enable(1);
200 REG_FLD_MOD(DSS_PLL_CONTROL
, 1, 18, 18); /* SDI_PLL_SYSRESET */
201 udelay(1); /* wait 2x PCLK */
204 REG_FLD_MOD(DSS_PLL_CONTROL
, 1, 28, 28); /* SDI_PLL_GOBIT */
206 /* Waiting for PLL lock request to complete */
207 timeout
= jiffies
+ msecs_to_jiffies(500);
208 while (dss_read_reg(DSS_SDI_STATUS
) & (1 << 6)) {
209 if (time_after_eq(jiffies
, timeout
)) {
210 DSSERR("PLL lock request timed out\n");
215 /* Clearing PLL_GO bit */
216 REG_FLD_MOD(DSS_PLL_CONTROL
, 0, 28, 28);
218 /* Waiting for PLL to lock */
219 timeout
= jiffies
+ msecs_to_jiffies(500);
220 while (!(dss_read_reg(DSS_SDI_STATUS
) & (1 << 5))) {
221 if (time_after_eq(jiffies
, timeout
)) {
222 DSSERR("PLL lock timed out\n");
227 dispc_lcd_enable_signal(1);
229 /* Waiting for SDI reset to complete */
230 timeout
= jiffies
+ msecs_to_jiffies(500);
231 while (!(dss_read_reg(DSS_SDI_STATUS
) & (1 << 2))) {
232 if (time_after_eq(jiffies
, timeout
)) {
233 DSSERR("SDI reset timed out\n");
241 dispc_lcd_enable_signal(0);
244 REG_FLD_MOD(DSS_PLL_CONTROL
, 0, 18, 18); /* SDI_PLL_SYSRESET */
246 dispc_pck_free_enable(0);
251 void dss_sdi_disable(void)
253 dispc_lcd_enable_signal(0);
255 dispc_pck_free_enable(0);
258 REG_FLD_MOD(DSS_PLL_CONTROL
, 0, 18, 18); /* SDI_PLL_SYSRESET */
261 const char *dss_get_generic_clk_source_name(enum omap_dss_clk_source clk_src
)
263 return dss_generic_clk_source_names
[clk_src
];
266 void dss_dump_clocks(struct seq_file
*s
)
268 unsigned long dpll4_ck_rate
;
269 unsigned long dpll4_m4_ck_rate
;
270 const char *fclk_name
, *fclk_real_name
;
271 unsigned long fclk_rate
;
273 if (dss_runtime_get())
276 seq_printf(s
, "- DSS -\n");
278 fclk_name
= dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_FCK
);
279 fclk_real_name
= dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_FCK
);
280 fclk_rate
= clk_get_rate(dss
.dss_clk
);
282 if (dss
.dpll4_m4_ck
) {
283 dpll4_ck_rate
= clk_get_rate(clk_get_parent(dss
.dpll4_m4_ck
));
284 dpll4_m4_ck_rate
= clk_get_rate(dss
.dpll4_m4_ck
);
286 seq_printf(s
, "dpll4_ck %lu\n", dpll4_ck_rate
);
288 seq_printf(s
, "%s (%s) = %lu / %lu * %d = %lu\n",
289 fclk_name
, fclk_real_name
, dpll4_ck_rate
,
290 dpll4_ck_rate
/ dpll4_m4_ck_rate
,
291 dss
.feat
->dss_fck_multiplier
, fclk_rate
);
293 seq_printf(s
, "%s (%s) = %lu\n",
294 fclk_name
, fclk_real_name
,
301 static void dss_dump_regs(struct seq_file
*s
)
303 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
305 if (dss_runtime_get())
308 DUMPREG(DSS_REVISION
);
309 DUMPREG(DSS_SYSCONFIG
);
310 DUMPREG(DSS_SYSSTATUS
);
311 DUMPREG(DSS_CONTROL
);
313 if (dss_feat_get_supported_displays(OMAP_DSS_CHANNEL_LCD
) &
314 OMAP_DISPLAY_TYPE_SDI
) {
315 DUMPREG(DSS_SDI_CONTROL
);
316 DUMPREG(DSS_PLL_CONTROL
);
317 DUMPREG(DSS_SDI_STATUS
);
324 static void dss_select_dispc_clk_source(enum omap_dss_clk_source clk_src
)
326 struct platform_device
*dsidev
;
331 case OMAP_DSS_CLK_SRC_FCK
:
334 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
:
336 dsidev
= dsi_get_dsidev_from_id(0);
337 dsi_wait_pll_hsdiv_dispc_active(dsidev
);
339 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC
:
341 dsidev
= dsi_get_dsidev_from_id(1);
342 dsi_wait_pll_hsdiv_dispc_active(dsidev
);
349 dss_feat_get_reg_field(FEAT_REG_DISPC_CLK_SWITCH
, &start
, &end
);
351 REG_FLD_MOD(DSS_CONTROL
, b
, start
, end
); /* DISPC_CLK_SWITCH */
353 dss
.dispc_clk_source
= clk_src
;
356 void dss_select_dsi_clk_source(int dsi_module
,
357 enum omap_dss_clk_source clk_src
)
359 struct platform_device
*dsidev
;
363 case OMAP_DSS_CLK_SRC_FCK
:
366 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI
:
367 BUG_ON(dsi_module
!= 0);
369 dsidev
= dsi_get_dsidev_from_id(0);
370 dsi_wait_pll_hsdiv_dsi_active(dsidev
);
372 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI
:
373 BUG_ON(dsi_module
!= 1);
375 dsidev
= dsi_get_dsidev_from_id(1);
376 dsi_wait_pll_hsdiv_dsi_active(dsidev
);
383 pos
= dsi_module
== 0 ? 1 : 10;
384 REG_FLD_MOD(DSS_CONTROL
, b
, pos
, pos
); /* DSIx_CLK_SWITCH */
386 dss
.dsi_clk_source
[dsi_module
] = clk_src
;
389 void dss_select_lcd_clk_source(enum omap_channel channel
,
390 enum omap_dss_clk_source clk_src
)
392 struct platform_device
*dsidev
;
395 if (!dss_has_feature(FEAT_LCD_CLK_SRC
)) {
396 dss_select_dispc_clk_source(clk_src
);
401 case OMAP_DSS_CLK_SRC_FCK
:
404 case OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC
:
405 BUG_ON(channel
!= OMAP_DSS_CHANNEL_LCD
);
407 dsidev
= dsi_get_dsidev_from_id(0);
408 dsi_wait_pll_hsdiv_dispc_active(dsidev
);
410 case OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC
:
411 BUG_ON(channel
!= OMAP_DSS_CHANNEL_LCD2
&&
412 channel
!= OMAP_DSS_CHANNEL_LCD3
);
414 dsidev
= dsi_get_dsidev_from_id(1);
415 dsi_wait_pll_hsdiv_dispc_active(dsidev
);
422 pos
= channel
== OMAP_DSS_CHANNEL_LCD
? 0 :
423 (channel
== OMAP_DSS_CHANNEL_LCD2
? 12 : 19);
424 REG_FLD_MOD(DSS_CONTROL
, b
, pos
, pos
); /* LCDx_CLK_SWITCH */
426 ix
= channel
== OMAP_DSS_CHANNEL_LCD
? 0 :
427 (channel
== OMAP_DSS_CHANNEL_LCD2
? 1 : 2);
428 dss
.lcd_clk_source
[ix
] = clk_src
;
431 enum omap_dss_clk_source
dss_get_dispc_clk_source(void)
433 return dss
.dispc_clk_source
;
436 enum omap_dss_clk_source
dss_get_dsi_clk_source(int dsi_module
)
438 return dss
.dsi_clk_source
[dsi_module
];
441 enum omap_dss_clk_source
dss_get_lcd_clk_source(enum omap_channel channel
)
443 if (dss_has_feature(FEAT_LCD_CLK_SRC
)) {
444 int ix
= channel
== OMAP_DSS_CHANNEL_LCD
? 0 :
445 (channel
== OMAP_DSS_CHANNEL_LCD2
? 1 : 2);
446 return dss
.lcd_clk_source
[ix
];
448 /* LCD_CLK source is the same as DISPC_FCLK source for
450 return dss
.dispc_clk_source
;
454 /* calculate clock rates using dividers in cinfo */
455 int dss_calc_clock_rates(struct dss_clock_info
*cinfo
)
457 if (dss
.dpll4_m4_ck
) {
460 if (cinfo
->fck_div
> dss
.feat
->fck_div_max
||
464 prate
= clk_get_rate(clk_get_parent(dss
.dpll4_m4_ck
));
466 cinfo
->fck
= prate
/ cinfo
->fck_div
*
467 dss
.feat
->dss_fck_multiplier
;
469 if (cinfo
->fck_div
!= 0)
471 cinfo
->fck
= clk_get_rate(dss
.dss_clk
);
477 bool dss_div_calc(unsigned long fck_min
, dss_div_calc_func func
, void *data
)
479 int fckd
, fckd_start
, fckd_stop
;
481 unsigned long fck_hw_max
;
482 unsigned long fckd_hw_max
;
486 if (dss
.dpll4_m4_ck
== NULL
) {
488 * TODO: dss1_fclk can be changed on OMAP2, but the available
489 * dividers are not continuous. We just use the pre-set rate for
492 fck
= clk_get_rate(dss
.dss_clk
);
494 return func(fckd
, fck
, data
);
497 fck_hw_max
= dss_feat_get_param_max(FEAT_PARAM_DSS_FCK
);
498 fckd_hw_max
= dss
.feat
->fck_div_max
;
500 m
= dss
.feat
->dss_fck_multiplier
;
501 prate
= dss_get_dpll4_rate();
503 fck_min
= fck_min
? fck_min
: 1;
505 fckd_start
= min(prate
* m
/ fck_min
, fckd_hw_max
);
506 fckd_stop
= max(DIV_ROUND_UP(prate
* m
, fck_hw_max
), 1ul);
508 for (fckd
= fckd_start
; fckd
>= fckd_stop
; --fckd
) {
509 fck
= prate
/ fckd
* m
;
511 if (func(fckd
, fck
, data
))
518 int dss_set_clock_div(struct dss_clock_info
*cinfo
)
520 if (dss
.dpll4_m4_ck
) {
524 prate
= clk_get_rate(clk_get_parent(dss
.dpll4_m4_ck
));
525 DSSDBG("dpll4_m4 = %ld\n", prate
);
527 r
= clk_set_rate(dss
.dpll4_m4_ck
,
528 DIV_ROUND_UP(prate
, cinfo
->fck_div
));
532 if (cinfo
->fck_div
!= 0)
536 dss
.dss_clk_rate
= clk_get_rate(dss
.dss_clk
);
538 WARN_ONCE(dss
.dss_clk_rate
!= cinfo
->fck
,
539 "clk rate mismatch: %lu != %lu", dss
.dss_clk_rate
,
542 DSSDBG("fck = %ld (%d)\n", cinfo
->fck
, cinfo
->fck_div
);
547 unsigned long dss_get_dpll4_rate(void)
550 return clk_get_rate(clk_get_parent(dss
.dpll4_m4_ck
));
555 unsigned long dss_get_dispc_clk_rate(void)
557 return dss
.dss_clk_rate
;
560 static int dss_setup_default_clock(void)
562 unsigned long max_dss_fck
, prate
;
564 struct dss_clock_info dss_cinfo
= { 0 };
567 if (dss
.dpll4_m4_ck
== NULL
)
570 max_dss_fck
= dss_feat_get_param_max(FEAT_PARAM_DSS_FCK
);
572 prate
= dss_get_dpll4_rate();
574 fck_div
= DIV_ROUND_UP(prate
* dss
.feat
->dss_fck_multiplier
,
577 dss_cinfo
.fck_div
= fck_div
;
579 r
= dss_calc_clock_rates(&dss_cinfo
);
583 r
= dss_set_clock_div(&dss_cinfo
);
590 void dss_set_venc_output(enum omap_dss_venc_type type
)
594 if (type
== OMAP_DSS_VENC_TYPE_COMPOSITE
)
596 else if (type
== OMAP_DSS_VENC_TYPE_SVIDEO
)
601 /* venc out selection. 0 = comp, 1 = svideo */
602 REG_FLD_MOD(DSS_CONTROL
, l
, 6, 6);
605 void dss_set_dac_pwrdn_bgz(bool enable
)
607 REG_FLD_MOD(DSS_CONTROL
, enable
, 5, 5); /* DAC Power-Down Control */
610 void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select src
)
612 enum omap_display_type dp
;
613 dp
= dss_feat_get_supported_displays(OMAP_DSS_CHANNEL_DIGIT
);
615 /* Complain about invalid selections */
616 WARN_ON((src
== DSS_VENC_TV_CLK
) && !(dp
& OMAP_DISPLAY_TYPE_VENC
));
617 WARN_ON((src
== DSS_HDMI_M_PCLK
) && !(dp
& OMAP_DISPLAY_TYPE_HDMI
));
619 /* Select only if we have options */
620 if ((dp
& OMAP_DISPLAY_TYPE_VENC
) && (dp
& OMAP_DISPLAY_TYPE_HDMI
))
621 REG_FLD_MOD(DSS_CONTROL
, src
, 15, 15); /* VENC_HDMI_SWITCH */
624 enum dss_hdmi_venc_clk_source_select
dss_get_hdmi_venc_clk_source(void)
626 enum omap_display_type displays
;
628 displays
= dss_feat_get_supported_displays(OMAP_DSS_CHANNEL_DIGIT
);
629 if ((displays
& OMAP_DISPLAY_TYPE_HDMI
) == 0)
630 return DSS_VENC_TV_CLK
;
632 if ((displays
& OMAP_DISPLAY_TYPE_VENC
) == 0)
633 return DSS_HDMI_M_PCLK
;
635 return REG_GET(DSS_CONTROL
, 15, 15);
638 static int dss_dpi_select_source_omap2_omap3(enum omap_channel channel
)
640 if (channel
!= OMAP_DSS_CHANNEL_LCD
)
646 static int dss_dpi_select_source_omap4(enum omap_channel channel
)
651 case OMAP_DSS_CHANNEL_LCD2
:
654 case OMAP_DSS_CHANNEL_DIGIT
:
661 REG_FLD_MOD(DSS_CONTROL
, val
, 17, 17);
666 static int dss_dpi_select_source_omap5(enum omap_channel channel
)
671 case OMAP_DSS_CHANNEL_LCD
:
674 case OMAP_DSS_CHANNEL_LCD2
:
677 case OMAP_DSS_CHANNEL_LCD3
:
680 case OMAP_DSS_CHANNEL_DIGIT
:
687 REG_FLD_MOD(DSS_CONTROL
, val
, 17, 16);
692 int dss_dpi_select_source(enum omap_channel channel
)
694 return dss
.feat
->dpi_select_source(channel
);
697 static int dss_get_clocks(void)
701 clk
= devm_clk_get(&dss
.pdev
->dev
, "fck");
703 DSSERR("can't get clock fck\n");
709 if (dss
.feat
->clk_name
) {
710 clk
= clk_get(NULL
, dss
.feat
->clk_name
);
712 DSSERR("Failed to get %s\n", dss
.feat
->clk_name
);
719 dss
.dpll4_m4_ck
= clk
;
724 static void dss_put_clocks(void)
727 clk_put(dss
.dpll4_m4_ck
);
730 static int dss_runtime_get(void)
734 DSSDBG("dss_runtime_get\n");
736 r
= pm_runtime_get_sync(&dss
.pdev
->dev
);
738 return r
< 0 ? r
: 0;
741 static void dss_runtime_put(void)
745 DSSDBG("dss_runtime_put\n");
747 r
= pm_runtime_put_sync(&dss
.pdev
->dev
);
748 WARN_ON(r
< 0 && r
!= -ENOSYS
&& r
!= -EBUSY
);
752 #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
753 void dss_debug_dump_clocks(struct seq_file
*s
)
756 dispc_dump_clocks(s
);
757 #ifdef CONFIG_OMAP2_DSS_DSI
763 static const struct dss_features omap24xx_dss_feats __initconst
= {
765 .dss_fck_multiplier
= 2,
767 .dpi_select_source
= &dss_dpi_select_source_omap2_omap3
,
770 static const struct dss_features omap34xx_dss_feats __initconst
= {
772 .dss_fck_multiplier
= 2,
773 .clk_name
= "dpll4_m4_ck",
774 .dpi_select_source
= &dss_dpi_select_source_omap2_omap3
,
777 static const struct dss_features omap3630_dss_feats __initconst
= {
779 .dss_fck_multiplier
= 1,
780 .clk_name
= "dpll4_m4_ck",
781 .dpi_select_source
= &dss_dpi_select_source_omap2_omap3
,
784 static const struct dss_features omap44xx_dss_feats __initconst
= {
786 .dss_fck_multiplier
= 1,
787 .clk_name
= "dpll_per_m5x2_ck",
788 .dpi_select_source
= &dss_dpi_select_source_omap4
,
791 static const struct dss_features omap54xx_dss_feats __initconst
= {
793 .dss_fck_multiplier
= 1,
794 .clk_name
= "dpll_per_h12x2_ck",
795 .dpi_select_source
= &dss_dpi_select_source_omap5
,
798 static int __init
dss_init_features(struct platform_device
*pdev
)
800 const struct dss_features
*src
;
801 struct dss_features
*dst
;
803 dst
= devm_kzalloc(&pdev
->dev
, sizeof(*dst
), GFP_KERNEL
);
805 dev_err(&pdev
->dev
, "Failed to allocate local DSS Features\n");
809 switch (omapdss_get_version()) {
810 case OMAPDSS_VER_OMAP24xx
:
811 src
= &omap24xx_dss_feats
;
814 case OMAPDSS_VER_OMAP34xx_ES1
:
815 case OMAPDSS_VER_OMAP34xx_ES3
:
816 case OMAPDSS_VER_AM35xx
:
817 src
= &omap34xx_dss_feats
;
820 case OMAPDSS_VER_OMAP3630
:
821 src
= &omap3630_dss_feats
;
824 case OMAPDSS_VER_OMAP4430_ES1
:
825 case OMAPDSS_VER_OMAP4430_ES2
:
826 case OMAPDSS_VER_OMAP4
:
827 src
= &omap44xx_dss_feats
;
830 case OMAPDSS_VER_OMAP5
:
831 src
= &omap54xx_dss_feats
;
838 memcpy(dst
, src
, sizeof(*dst
));
844 /* DSS HW IP initialisation */
845 static int __init
omap_dsshw_probe(struct platform_device
*pdev
)
847 struct resource
*dss_mem
;
853 r
= dss_init_features(dss
.pdev
);
857 dss_mem
= platform_get_resource(dss
.pdev
, IORESOURCE_MEM
, 0);
859 DSSERR("can't get IORESOURCE_MEM DSS\n");
863 dss
.base
= devm_ioremap(&pdev
->dev
, dss_mem
->start
,
864 resource_size(dss_mem
));
866 DSSERR("can't ioremap DSS\n");
870 r
= dss_get_clocks();
874 r
= dss_setup_default_clock();
876 goto err_setup_clocks
;
878 pm_runtime_enable(&pdev
->dev
);
880 r
= dss_runtime_get();
882 goto err_runtime_get
;
884 dss
.dss_clk_rate
= clk_get_rate(dss
.dss_clk
);
887 REG_FLD_MOD(DSS_CONTROL
, 0, 0, 0);
889 dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK
);
891 #ifdef CONFIG_OMAP2_DSS_VENC
892 REG_FLD_MOD(DSS_CONTROL
, 1, 4, 4); /* venc dac demen */
893 REG_FLD_MOD(DSS_CONTROL
, 1, 3, 3); /* venc clock 4x enable */
894 REG_FLD_MOD(DSS_CONTROL
, 0, 2, 2); /* venc clock mode = normal */
896 dss
.dsi_clk_source
[0] = OMAP_DSS_CLK_SRC_FCK
;
897 dss
.dsi_clk_source
[1] = OMAP_DSS_CLK_SRC_FCK
;
898 dss
.dispc_clk_source
= OMAP_DSS_CLK_SRC_FCK
;
899 dss
.lcd_clk_source
[0] = OMAP_DSS_CLK_SRC_FCK
;
900 dss
.lcd_clk_source
[1] = OMAP_DSS_CLK_SRC_FCK
;
902 rev
= dss_read_reg(DSS_REVISION
);
903 printk(KERN_INFO
"OMAP DSS rev %d.%d\n",
904 FLD_GET(rev
, 7, 4), FLD_GET(rev
, 3, 0));
908 dss_debugfs_create_file("dss", dss_dump_regs
);
913 pm_runtime_disable(&pdev
->dev
);
919 static int __exit
omap_dsshw_remove(struct platform_device
*pdev
)
921 pm_runtime_disable(&pdev
->dev
);
928 static int dss_runtime_suspend(struct device
*dev
)
931 dss_set_min_bus_tput(dev
, 0);
935 static int dss_runtime_resume(struct device
*dev
)
939 * Set an arbitrarily high tput request to ensure OPP100.
940 * What we should really do is to make a request to stay in OPP100,
941 * without any tput requirements, but that is not currently possible
945 r
= dss_set_min_bus_tput(dev
, 1000000000);
949 dss_restore_context();
953 static const struct dev_pm_ops dss_pm_ops
= {
954 .runtime_suspend
= dss_runtime_suspend
,
955 .runtime_resume
= dss_runtime_resume
,
958 static struct platform_driver omap_dsshw_driver
= {
959 .remove
= __exit_p(omap_dsshw_remove
),
961 .name
= "omapdss_dss",
962 .owner
= THIS_MODULE
,
967 int __init
dss_init_platform_driver(void)
969 return platform_driver_probe(&omap_dsshw_driver
, omap_dsshw_probe
);
972 void dss_uninit_platform_driver(void)
974 platform_driver_unregister(&omap_dsshw_driver
);