2 * linux/drivers/video/omap2/dss/rfbi.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 "RFBI"
25 #include <linux/kernel.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/export.h>
28 #include <linux/vmalloc.h>
29 #include <linux/clk.h>
31 #include <linux/delay.h>
32 #include <linux/kfifo.h>
33 #include <linux/ktime.h>
34 #include <linux/hrtimer.h>
35 #include <linux/seq_file.h>
36 #include <linux/semaphore.h>
37 #include <linux/platform_device.h>
38 #include <linux/pm_runtime.h>
40 #include <video/omapdss.h>
43 struct rfbi_reg { u16 idx; };
45 #define RFBI_REG(idx) ((const struct rfbi_reg) { idx })
47 #define RFBI_REVISION RFBI_REG(0x0000)
48 #define RFBI_SYSCONFIG RFBI_REG(0x0010)
49 #define RFBI_SYSSTATUS RFBI_REG(0x0014)
50 #define RFBI_CONTROL RFBI_REG(0x0040)
51 #define RFBI_PIXEL_CNT RFBI_REG(0x0044)
52 #define RFBI_LINE_NUMBER RFBI_REG(0x0048)
53 #define RFBI_CMD RFBI_REG(0x004c)
54 #define RFBI_PARAM RFBI_REG(0x0050)
55 #define RFBI_DATA RFBI_REG(0x0054)
56 #define RFBI_READ RFBI_REG(0x0058)
57 #define RFBI_STATUS RFBI_REG(0x005c)
59 #define RFBI_CONFIG(n) RFBI_REG(0x0060 + (n)*0x18)
60 #define RFBI_ONOFF_TIME(n) RFBI_REG(0x0064 + (n)*0x18)
61 #define RFBI_CYCLE_TIME(n) RFBI_REG(0x0068 + (n)*0x18)
62 #define RFBI_DATA_CYCLE1(n) RFBI_REG(0x006c + (n)*0x18)
63 #define RFBI_DATA_CYCLE2(n) RFBI_REG(0x0070 + (n)*0x18)
64 #define RFBI_DATA_CYCLE3(n) RFBI_REG(0x0074 + (n)*0x18)
66 #define RFBI_VSYNC_WIDTH RFBI_REG(0x0090)
67 #define RFBI_HSYNC_WIDTH RFBI_REG(0x0094)
69 #define REG_FLD_MOD(idx, val, start, end) \
70 rfbi_write_reg(idx, FLD_MOD(rfbi_read_reg(idx), val, start, end))
72 enum omap_rfbi_cycleformat {
73 OMAP_DSS_RFBI_CYCLEFORMAT_1_1 = 0,
74 OMAP_DSS_RFBI_CYCLEFORMAT_2_1 = 1,
75 OMAP_DSS_RFBI_CYCLEFORMAT_3_1 = 2,
76 OMAP_DSS_RFBI_CYCLEFORMAT_3_2 = 3,
79 enum omap_rfbi_datatype {
80 OMAP_DSS_RFBI_DATATYPE_12 = 0,
81 OMAP_DSS_RFBI_DATATYPE_16 = 1,
82 OMAP_DSS_RFBI_DATATYPE_18 = 2,
83 OMAP_DSS_RFBI_DATATYPE_24 = 3,
86 enum omap_rfbi_parallelmode {
87 OMAP_DSS_RFBI_PARALLELMODE_8 = 0,
88 OMAP_DSS_RFBI_PARALLELMODE_9 = 1,
89 OMAP_DSS_RFBI_PARALLELMODE_12 = 2,
90 OMAP_DSS_RFBI_PARALLELMODE_16 = 3,
93 static int rfbi_convert_timings(struct rfbi_timings *t);
94 static void rfbi_get_clk_info(u32 *clk_period, u32 *max_clk_div);
97 struct platform_device *pdev;
100 unsigned long l4_khz;
102 enum omap_rfbi_datatype datatype;
103 enum omap_rfbi_parallelmode parallelmode;
105 enum omap_rfbi_te_mode te_mode;
108 void (*framedone_callback)(void *data);
109 void *framedone_callback_data;
111 struct omap_dss_device *dssdev[2];
113 struct semaphore bus_lock;
115 struct omap_video_timings timings;
118 struct rfbi_timings intf_timings;
120 struct omap_dss_device output;
123 static inline void rfbi_write_reg(const struct rfbi_reg idx, u32 val)
125 __raw_writel(val, rfbi.base + idx.idx);
128 static inline u32 rfbi_read_reg(const struct rfbi_reg idx)
130 return __raw_readl(rfbi.base + idx.idx);
133 static int rfbi_runtime_get(void)
137 DSSDBG("rfbi_runtime_get\n");
139 r = pm_runtime_get_sync(&rfbi.pdev->dev);
141 return r < 0 ? r : 0;
144 static void rfbi_runtime_put(void)
148 DSSDBG("rfbi_runtime_put\n");
150 r = pm_runtime_put_sync(&rfbi.pdev->dev);
151 WARN_ON(r < 0 && r != -ENOSYS);
154 static void rfbi_bus_lock(void)
156 down(&rfbi.bus_lock);
159 static void rfbi_bus_unlock(void)
164 static void rfbi_write_command(const void *buf, u32 len)
166 switch (rfbi.parallelmode) {
167 case OMAP_DSS_RFBI_PARALLELMODE_8:
171 rfbi_write_reg(RFBI_CMD, *b++);
175 case OMAP_DSS_RFBI_PARALLELMODE_16:
179 for (; len; len -= 2)
180 rfbi_write_reg(RFBI_CMD, *w++);
184 case OMAP_DSS_RFBI_PARALLELMODE_9:
185 case OMAP_DSS_RFBI_PARALLELMODE_12:
191 static void rfbi_read_data(void *buf, u32 len)
193 switch (rfbi.parallelmode) {
194 case OMAP_DSS_RFBI_PARALLELMODE_8:
198 rfbi_write_reg(RFBI_READ, 0);
199 *b++ = rfbi_read_reg(RFBI_READ);
204 case OMAP_DSS_RFBI_PARALLELMODE_16:
208 for (; len; len -= 2) {
209 rfbi_write_reg(RFBI_READ, 0);
210 *w++ = rfbi_read_reg(RFBI_READ);
215 case OMAP_DSS_RFBI_PARALLELMODE_9:
216 case OMAP_DSS_RFBI_PARALLELMODE_12:
222 static void rfbi_write_data(const void *buf, u32 len)
224 switch (rfbi.parallelmode) {
225 case OMAP_DSS_RFBI_PARALLELMODE_8:
229 rfbi_write_reg(RFBI_PARAM, *b++);
233 case OMAP_DSS_RFBI_PARALLELMODE_16:
237 for (; len; len -= 2)
238 rfbi_write_reg(RFBI_PARAM, *w++);
242 case OMAP_DSS_RFBI_PARALLELMODE_9:
243 case OMAP_DSS_RFBI_PARALLELMODE_12:
250 static void rfbi_write_pixels(const void __iomem *buf, int scr_width,
254 int start_offset = scr_width * y + x;
255 int horiz_offset = scr_width - w;
258 if (rfbi.datatype == OMAP_DSS_RFBI_DATATYPE_16 &&
259 rfbi.parallelmode == OMAP_DSS_RFBI_PARALLELMODE_8) {
260 const u16 __iomem *pd = buf;
264 for (i = 0; i < w; ++i) {
265 const u8 __iomem *b = (const u8 __iomem *)pd;
266 rfbi_write_reg(RFBI_PARAM, __raw_readb(b+1));
267 rfbi_write_reg(RFBI_PARAM, __raw_readb(b+0));
272 } else if (rfbi.datatype == OMAP_DSS_RFBI_DATATYPE_24 &&
273 rfbi.parallelmode == OMAP_DSS_RFBI_PARALLELMODE_8) {
274 const u32 __iomem *pd = buf;
278 for (i = 0; i < w; ++i) {
279 const u8 __iomem *b = (const u8 __iomem *)pd;
280 rfbi_write_reg(RFBI_PARAM, __raw_readb(b+2));
281 rfbi_write_reg(RFBI_PARAM, __raw_readb(b+1));
282 rfbi_write_reg(RFBI_PARAM, __raw_readb(b+0));
287 } else if (rfbi.datatype == OMAP_DSS_RFBI_DATATYPE_16 &&
288 rfbi.parallelmode == OMAP_DSS_RFBI_PARALLELMODE_16) {
289 const u16 __iomem *pd = buf;
293 for (i = 0; i < w; ++i) {
294 rfbi_write_reg(RFBI_PARAM, __raw_readw(pd));
304 static int rfbi_transfer_area(struct omap_dss_device *dssdev,
305 void (*callback)(void *data), void *data)
309 struct omap_overlay_manager *mgr = rfbi.output.manager;
310 u16 width = rfbi.timings.x_res;
311 u16 height = rfbi.timings.y_res;
313 /*BUG_ON(callback == 0);*/
314 BUG_ON(rfbi.framedone_callback != NULL);
316 DSSDBG("rfbi_transfer_area %dx%d\n", width, height);
318 dss_mgr_set_timings(mgr, &rfbi.timings);
320 r = dss_mgr_enable(mgr);
324 rfbi.framedone_callback = callback;
325 rfbi.framedone_callback_data = data;
327 rfbi_write_reg(RFBI_PIXEL_CNT, width * height);
329 l = rfbi_read_reg(RFBI_CONTROL);
330 l = FLD_MOD(l, 1, 0, 0); /* enable */
331 if (!rfbi.te_enabled)
332 l = FLD_MOD(l, 1, 4, 4); /* ITE */
334 rfbi_write_reg(RFBI_CONTROL, l);
339 static void framedone_callback(void *data)
341 void (*callback)(void *data);
343 DSSDBG("FRAMEDONE\n");
345 REG_FLD_MOD(RFBI_CONTROL, 0, 0, 0);
347 callback = rfbi.framedone_callback;
348 rfbi.framedone_callback = NULL;
350 if (callback != NULL)
351 callback(rfbi.framedone_callback_data);
355 static void rfbi_print_timings(void)
360 l = rfbi_read_reg(RFBI_CONFIG(0));
361 time = 1000000000 / rfbi.l4_khz;
365 DSSDBG("Tick time %u ps\n", time);
366 l = rfbi_read_reg(RFBI_ONOFF_TIME(0));
367 DSSDBG("CSONTIME %d, CSOFFTIME %d, WEONTIME %d, WEOFFTIME %d, "
368 "REONTIME %d, REOFFTIME %d\n",
369 l & 0x0f, (l >> 4) & 0x3f, (l >> 10) & 0x0f, (l >> 14) & 0x3f,
370 (l >> 20) & 0x0f, (l >> 24) & 0x3f);
372 l = rfbi_read_reg(RFBI_CYCLE_TIME(0));
373 DSSDBG("WECYCLETIME %d, RECYCLETIME %d, CSPULSEWIDTH %d, "
375 (l & 0x3f), (l >> 6) & 0x3f, (l >> 12) & 0x3f,
379 static void rfbi_print_timings(void) {}
385 static u32 extif_clk_period;
387 static inline unsigned long round_to_extif_ticks(unsigned long ps, int div)
389 int bus_tick = extif_clk_period * div;
390 return (ps + bus_tick - 1) / bus_tick * bus_tick;
393 static int calc_reg_timing(struct rfbi_timings *t, int div)
397 t->cs_on_time = round_to_extif_ticks(t->cs_on_time, div);
399 t->we_on_time = round_to_extif_ticks(t->we_on_time, div);
400 t->we_off_time = round_to_extif_ticks(t->we_off_time, div);
401 t->we_cycle_time = round_to_extif_ticks(t->we_cycle_time, div);
403 t->re_on_time = round_to_extif_ticks(t->re_on_time, div);
404 t->re_off_time = round_to_extif_ticks(t->re_off_time, div);
405 t->re_cycle_time = round_to_extif_ticks(t->re_cycle_time, div);
407 t->access_time = round_to_extif_ticks(t->access_time, div);
408 t->cs_off_time = round_to_extif_ticks(t->cs_off_time, div);
409 t->cs_pulse_width = round_to_extif_ticks(t->cs_pulse_width, div);
411 DSSDBG("[reg]cson %d csoff %d reon %d reoff %d\n",
412 t->cs_on_time, t->cs_off_time, t->re_on_time, t->re_off_time);
413 DSSDBG("[reg]weon %d weoff %d recyc %d wecyc %d\n",
414 t->we_on_time, t->we_off_time, t->re_cycle_time,
416 DSSDBG("[reg]rdaccess %d cspulse %d\n",
417 t->access_time, t->cs_pulse_width);
419 return rfbi_convert_timings(t);
422 static int calc_extif_timings(struct rfbi_timings *t)
427 rfbi_get_clk_info(&extif_clk_period, &max_clk_div);
428 for (div = 1; div <= max_clk_div; div++) {
429 if (calc_reg_timing(t, div) == 0)
433 if (div <= max_clk_div)
436 DSSERR("can't setup timings\n");
441 static void rfbi_set_timings(int rfbi_module, struct rfbi_timings *t)
446 r = calc_extif_timings(t);
448 DSSERR("Failed to calc timings\n");
451 BUG_ON(!t->converted);
453 rfbi_write_reg(RFBI_ONOFF_TIME(rfbi_module), t->tim[0]);
454 rfbi_write_reg(RFBI_CYCLE_TIME(rfbi_module), t->tim[1]);
456 /* TIMEGRANULARITY */
457 REG_FLD_MOD(RFBI_CONFIG(rfbi_module),
458 (t->tim[2] ? 1 : 0), 4, 4);
460 rfbi_print_timings();
463 static int ps_to_rfbi_ticks(int time, int div)
465 unsigned long tick_ps;
468 /* Calculate in picosecs to yield more exact results */
469 tick_ps = 1000000000 / (rfbi.l4_khz) * div;
471 ret = (time + tick_ps - 1) / tick_ps;
476 static void rfbi_get_clk_info(u32 *clk_period, u32 *max_clk_div)
478 *clk_period = 1000000000 / rfbi.l4_khz;
482 static int rfbi_convert_timings(struct rfbi_timings *t)
485 int reon, reoff, weon, weoff, cson, csoff, cs_pulse;
486 int actim, recyc, wecyc;
487 int div = t->clk_div;
489 if (div <= 0 || div > 2)
492 /* Make sure that after conversion it still holds that:
493 * weoff > weon, reoff > reon, recyc >= reoff, wecyc >= weoff,
494 * csoff > cson, csoff >= max(weoff, reoff), actim > reon
496 weon = ps_to_rfbi_ticks(t->we_on_time, div);
497 weoff = ps_to_rfbi_ticks(t->we_off_time, div);
505 reon = ps_to_rfbi_ticks(t->re_on_time, div);
506 reoff = ps_to_rfbi_ticks(t->re_off_time, div);
514 cson = ps_to_rfbi_ticks(t->cs_on_time, div);
515 csoff = ps_to_rfbi_ticks(t->cs_off_time, div);
518 if (csoff < max(weoff, reoff))
519 csoff = max(weoff, reoff);
534 actim = ps_to_rfbi_ticks(t->access_time, div);
540 wecyc = ps_to_rfbi_ticks(t->we_cycle_time, div);
546 recyc = ps_to_rfbi_ticks(t->re_cycle_time, div);
552 cs_pulse = ps_to_rfbi_ticks(t->cs_pulse_width, div);
570 /* xxx FIX module selection missing */
571 static int rfbi_setup_te(enum omap_rfbi_te_mode mode,
572 unsigned hs_pulse_time, unsigned vs_pulse_time,
573 int hs_pol_inv, int vs_pol_inv, int extif_div)
579 hs = ps_to_rfbi_ticks(hs_pulse_time, 1);
580 vs = ps_to_rfbi_ticks(vs_pulse_time, 1);
583 if (mode == OMAP_DSS_RFBI_TE_MODE_2)
585 else /* OMAP_DSS_RFBI_TE_MODE_1 */
592 DSSDBG("setup_te: mode %d hs %d vs %d hs_inv %d vs_inv %d\n",
593 mode, hs, vs, hs_pol_inv, vs_pol_inv);
595 rfbi_write_reg(RFBI_HSYNC_WIDTH, hs);
596 rfbi_write_reg(RFBI_VSYNC_WIDTH, vs);
598 l = rfbi_read_reg(RFBI_CONFIG(0));
611 /* xxx FIX module selection missing */
612 static int rfbi_enable_te(bool enable, unsigned line)
616 DSSDBG("te %d line %d mode %d\n", enable, line, rfbi.te_mode);
617 if (line > (1 << 11) - 1)
620 l = rfbi_read_reg(RFBI_CONFIG(0));
624 l |= rfbi.te_mode << 2;
627 rfbi_write_reg(RFBI_CONFIG(0), l);
628 rfbi_write_reg(RFBI_LINE_NUMBER, line);
633 static int rfbi_configure_bus(int rfbi_module, int bpp, int lines)
636 int cycle1 = 0, cycle2 = 0, cycle3 = 0;
637 enum omap_rfbi_cycleformat cycleformat;
638 enum omap_rfbi_datatype datatype;
639 enum omap_rfbi_parallelmode parallelmode;
643 datatype = OMAP_DSS_RFBI_DATATYPE_12;
646 datatype = OMAP_DSS_RFBI_DATATYPE_16;
649 datatype = OMAP_DSS_RFBI_DATATYPE_18;
652 datatype = OMAP_DSS_RFBI_DATATYPE_24;
658 rfbi.datatype = datatype;
662 parallelmode = OMAP_DSS_RFBI_PARALLELMODE_8;
665 parallelmode = OMAP_DSS_RFBI_PARALLELMODE_9;
668 parallelmode = OMAP_DSS_RFBI_PARALLELMODE_12;
671 parallelmode = OMAP_DSS_RFBI_PARALLELMODE_16;
677 rfbi.parallelmode = parallelmode;
679 if ((bpp % lines) == 0) {
680 switch (bpp / lines) {
682 cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_1_1;
685 cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_2_1;
688 cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_3_1;
694 } else if ((2 * bpp % lines) == 0) {
695 if ((2 * bpp / lines) == 3)
696 cycleformat = OMAP_DSS_RFBI_CYCLEFORMAT_3_2;
706 switch (cycleformat) {
707 case OMAP_DSS_RFBI_CYCLEFORMAT_1_1:
711 case OMAP_DSS_RFBI_CYCLEFORMAT_2_1:
716 case OMAP_DSS_RFBI_CYCLEFORMAT_3_1:
722 case OMAP_DSS_RFBI_CYCLEFORMAT_3_2:
724 cycle2 = (lines / 2) | ((lines / 2) << 16);
725 cycle3 = (lines << 16);
729 REG_FLD_MOD(RFBI_CONTROL, 0, 3, 2); /* clear CS */
732 l |= FLD_VAL(parallelmode, 1, 0);
733 l |= FLD_VAL(0, 3, 2); /* TRIGGERMODE: ITE */
734 l |= FLD_VAL(0, 4, 4); /* TIMEGRANULARITY */
735 l |= FLD_VAL(datatype, 6, 5);
736 /* l |= FLD_VAL(2, 8, 7); */ /* L4FORMAT, 2pix/L4 */
737 l |= FLD_VAL(0, 8, 7); /* L4FORMAT, 1pix/L4 */
738 l |= FLD_VAL(cycleformat, 10, 9);
739 l |= FLD_VAL(0, 12, 11); /* UNUSEDBITS */
740 l |= FLD_VAL(0, 16, 16); /* A0POLARITY */
741 l |= FLD_VAL(0, 17, 17); /* REPOLARITY */
742 l |= FLD_VAL(0, 18, 18); /* WEPOLARITY */
743 l |= FLD_VAL(0, 19, 19); /* CSPOLARITY */
744 l |= FLD_VAL(1, 20, 20); /* TE_VSYNC_POLARITY */
745 l |= FLD_VAL(1, 21, 21); /* HSYNCPOLARITY */
746 rfbi_write_reg(RFBI_CONFIG(rfbi_module), l);
748 rfbi_write_reg(RFBI_DATA_CYCLE1(rfbi_module), cycle1);
749 rfbi_write_reg(RFBI_DATA_CYCLE2(rfbi_module), cycle2);
750 rfbi_write_reg(RFBI_DATA_CYCLE3(rfbi_module), cycle3);
753 l = rfbi_read_reg(RFBI_CONTROL);
754 l = FLD_MOD(l, rfbi_module+1, 3, 2); /* Select CSx */
755 l = FLD_MOD(l, 0, 1, 1); /* clear bypass */
756 rfbi_write_reg(RFBI_CONTROL, l);
759 DSSDBG("RFBI config: bpp %d, lines %d, cycles: 0x%x 0x%x 0x%x\n",
760 bpp, lines, cycle1, cycle2, cycle3);
765 static int rfbi_configure(struct omap_dss_device *dssdev)
767 return rfbi_configure_bus(dssdev->phy.rfbi.channel, rfbi.pixel_size,
771 static int rfbi_update(struct omap_dss_device *dssdev, void (*callback)(void *),
774 return rfbi_transfer_area(dssdev, callback, data);
777 static void rfbi_set_size(struct omap_dss_device *dssdev, u16 w, u16 h)
779 rfbi.timings.x_res = w;
780 rfbi.timings.y_res = h;
783 static void rfbi_set_pixel_size(struct omap_dss_device *dssdev, int pixel_size)
785 rfbi.pixel_size = pixel_size;
788 static void rfbi_set_data_lines(struct omap_dss_device *dssdev, int data_lines)
790 rfbi.data_lines = data_lines;
793 static void rfbi_set_interface_timings(struct omap_dss_device *dssdev,
794 struct rfbi_timings *timings)
796 rfbi.intf_timings = *timings;
799 static void rfbi_dump_regs(struct seq_file *s)
801 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, rfbi_read_reg(r))
803 if (rfbi_runtime_get())
806 DUMPREG(RFBI_REVISION);
807 DUMPREG(RFBI_SYSCONFIG);
808 DUMPREG(RFBI_SYSSTATUS);
809 DUMPREG(RFBI_CONTROL);
810 DUMPREG(RFBI_PIXEL_CNT);
811 DUMPREG(RFBI_LINE_NUMBER);
816 DUMPREG(RFBI_STATUS);
818 DUMPREG(RFBI_CONFIG(0));
819 DUMPREG(RFBI_ONOFF_TIME(0));
820 DUMPREG(RFBI_CYCLE_TIME(0));
821 DUMPREG(RFBI_DATA_CYCLE1(0));
822 DUMPREG(RFBI_DATA_CYCLE2(0));
823 DUMPREG(RFBI_DATA_CYCLE3(0));
825 DUMPREG(RFBI_CONFIG(1));
826 DUMPREG(RFBI_ONOFF_TIME(1));
827 DUMPREG(RFBI_CYCLE_TIME(1));
828 DUMPREG(RFBI_DATA_CYCLE1(1));
829 DUMPREG(RFBI_DATA_CYCLE2(1));
830 DUMPREG(RFBI_DATA_CYCLE3(1));
832 DUMPREG(RFBI_VSYNC_WIDTH);
833 DUMPREG(RFBI_HSYNC_WIDTH);
839 static void rfbi_config_lcd_manager(struct omap_dss_device *dssdev)
841 struct omap_overlay_manager *mgr = rfbi.output.manager;
842 struct dss_lcd_mgr_config mgr_config;
844 mgr_config.io_pad_mode = DSS_IO_PAD_MODE_RFBI;
846 mgr_config.stallmode = true;
847 /* Do we need fifohandcheck for RFBI? */
848 mgr_config.fifohandcheck = false;
850 mgr_config.video_port_width = rfbi.pixel_size;
851 mgr_config.lcden_sig_polarity = 0;
853 dss_mgr_set_lcd_config(mgr, &mgr_config);
856 * Set rfbi.timings with default values, the x_res and y_res fields
857 * are expected to be already configured by the panel driver via
858 * omapdss_rfbi_set_size()
860 rfbi.timings.hsw = 1;
861 rfbi.timings.hfp = 1;
862 rfbi.timings.hbp = 1;
863 rfbi.timings.vsw = 1;
864 rfbi.timings.vfp = 0;
865 rfbi.timings.vbp = 0;
867 rfbi.timings.interlace = false;
868 rfbi.timings.hsync_level = OMAPDSS_SIG_ACTIVE_HIGH;
869 rfbi.timings.vsync_level = OMAPDSS_SIG_ACTIVE_HIGH;
870 rfbi.timings.data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE;
871 rfbi.timings.de_level = OMAPDSS_SIG_ACTIVE_HIGH;
872 rfbi.timings.sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES;
874 dss_mgr_set_timings(mgr, &rfbi.timings);
877 static int rfbi_display_enable(struct omap_dss_device *dssdev)
879 struct omap_dss_device *out = &rfbi.output;
882 if (out == NULL || out->manager == NULL) {
883 DSSERR("failed to enable display: no output/manager\n");
887 r = rfbi_runtime_get();
891 r = dss_mgr_register_framedone_handler(out->manager,
892 framedone_callback, NULL);
894 DSSERR("can't get FRAMEDONE irq\n");
898 rfbi_config_lcd_manager(dssdev);
900 rfbi_configure_bus(dssdev->phy.rfbi.channel, rfbi.pixel_size,
903 rfbi_set_timings(dssdev->phy.rfbi.channel, &rfbi.intf_timings);
911 static void rfbi_display_disable(struct omap_dss_device *dssdev)
913 struct omap_dss_device *out = &rfbi.output;
915 dss_mgr_unregister_framedone_handler(out->manager,
916 framedone_callback, NULL);
921 static int rfbi_init_display(struct omap_dss_device *dssdev)
923 rfbi.dssdev[dssdev->phy.rfbi.channel] = dssdev;
927 static void rfbi_init_output(struct platform_device *pdev)
929 struct omap_dss_device *out = &rfbi.output;
931 out->dev = &pdev->dev;
932 out->id = OMAP_DSS_OUTPUT_DBI;
933 out->output_type = OMAP_DISPLAY_TYPE_DBI;
934 out->name = "rfbi.0";
935 out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
936 out->owner = THIS_MODULE;
938 omapdss_register_output(out);
941 static void __exit rfbi_uninit_output(struct platform_device *pdev)
943 struct omap_dss_device *out = &rfbi.output;
945 omapdss_unregister_output(out);
948 /* RFBI HW IP initialisation */
949 static int omap_rfbihw_probe(struct platform_device *pdev)
952 struct resource *rfbi_mem;
958 sema_init(&rfbi.bus_lock, 1);
960 rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0);
962 DSSERR("can't get IORESOURCE_MEM RFBI\n");
966 rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start,
967 resource_size(rfbi_mem));
969 DSSERR("can't ioremap RFBI\n");
973 clk = clk_get(&pdev->dev, "ick");
975 DSSERR("can't get ick\n");
979 rfbi.l4_khz = clk_get_rate(clk) / 1000;
983 pm_runtime_enable(&pdev->dev);
985 r = rfbi_runtime_get();
987 goto err_runtime_get;
991 rev = rfbi_read_reg(RFBI_REVISION);
992 dev_dbg(&pdev->dev, "OMAP RFBI rev %d.%d\n",
993 FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
997 dss_debugfs_create_file("rfbi", rfbi_dump_regs);
999 rfbi_init_output(pdev);
1004 pm_runtime_disable(&pdev->dev);
1008 static int __exit omap_rfbihw_remove(struct platform_device *pdev)
1010 rfbi_uninit_output(pdev);
1012 pm_runtime_disable(&pdev->dev);
1017 static int rfbi_runtime_suspend(struct device *dev)
1019 dispc_runtime_put();
1024 static int rfbi_runtime_resume(struct device *dev)
1028 r = dispc_runtime_get();
1035 static const struct dev_pm_ops rfbi_pm_ops = {
1036 .runtime_suspend = rfbi_runtime_suspend,
1037 .runtime_resume = rfbi_runtime_resume,
1040 static struct platform_driver omap_rfbihw_driver = {
1041 .probe = omap_rfbihw_probe,
1042 .remove = __exit_p(omap_rfbihw_remove),
1044 .name = "omapdss_rfbi",
1045 .owner = THIS_MODULE,
1047 .suppress_bind_attrs = true,
1051 int __init rfbi_init_platform_driver(void)
1053 return platform_driver_register(&omap_rfbihw_driver);
1056 void __exit rfbi_uninit_platform_driver(void)
1058 platform_driver_unregister(&omap_rfbihw_driver);