22 #include <linux/kernel.h>
23 #include <linux/module.h>
37 #define TMIOFB_ACC_CSADR(x) (0x00000000 | ((x) & 0x001ffffe))
38 #define TMIOFB_ACC_CHPIX(x) (0x01000000 | ((x) & 0x000003ff))
39 #define TMIOFB_ACC_CVPIX(x) (0x02000000 | ((x) & 0x000003ff))
40 #define TMIOFB_ACC_PSADR(x) (0x03000000 | ((x) & 0x00fffffe))
41 #define TMIOFB_ACC_PHPIX(x) (0x04000000 | ((x) & 0x000003ff))
42 #define TMIOFB_ACC_PVPIX(x) (0x05000000 | ((x) & 0x000003ff))
43 #define TMIOFB_ACC_PHOFS(x) (0x06000000 | ((x) & 0x000003ff))
44 #define TMIOFB_ACC_PVOFS(x) (0x07000000 | ((x) & 0x000003ff))
45 #define TMIOFB_ACC_POADR(x) (0x08000000 | ((x) & 0x00fffffe))
46 #define TMIOFB_ACC_RSTR(x) (0x09000000 | ((x) & 0x000000ff))
47 #define TMIOFB_ACC_TCLOR(x) (0x0A000000 | ((x) & 0x0000ffff))
48 #define TMIOFB_ACC_FILL(x) (0x0B000000 | ((x) & 0x0000ffff))
49 #define TMIOFB_ACC_DSADR(x) (0x0C000000 | ((x) & 0x00fffffe))
50 #define TMIOFB_ACC_SSADR(x) (0x0D000000 | ((x) & 0x00fffffe))
51 #define TMIOFB_ACC_DHPIX(x) (0x0E000000 | ((x) & 0x000003ff))
52 #define TMIOFB_ACC_DVPIX(x) (0x0F000000 | ((x) & 0x000003ff))
53 #define TMIOFB_ACC_SHPIX(x) (0x10000000 | ((x) & 0x000003ff))
54 #define TMIOFB_ACC_SVPIX(x) (0x11000000 | ((x) & 0x000003ff))
55 #define TMIOFB_ACC_LBINI(x) (0x12000000 | ((x) & 0x0000ffff))
56 #define TMIOFB_ACC_LBK2(x) (0x13000000 | ((x) & 0x0000ffff))
57 #define TMIOFB_ACC_SHBINI(x) (0x14000000 | ((x) & 0x0000ffff))
58 #define TMIOFB_ACC_SHBK2(x) (0x15000000 | ((x) & 0x0000ffff))
59 #define TMIOFB_ACC_SVBINI(x) (0x16000000 | ((x) & 0x0000ffff))
60 #define TMIOFB_ACC_SVBK2(x) (0x17000000 | ((x) & 0x0000ffff))
62 #define TMIOFB_ACC_CMGO 0x20000000
63 #define TMIOFB_ACC_CMGO_CEND 0x00000001
64 #define TMIOFB_ACC_CMGO_INT 0x00000002
65 #define TMIOFB_ACC_CMGO_CMOD 0x00000010
66 #define TMIOFB_ACC_CMGO_CDVRV 0x00000020
67 #define TMIOFB_ACC_CMGO_CDHRV 0x00000040
68 #define TMIOFB_ACC_CMGO_RUND 0x00008000
69 #define TMIOFB_ACC_SCGO 0x21000000
70 #define TMIOFB_ACC_SCGO_CEND 0x00000001
71 #define TMIOFB_ACC_SCGO_INT 0x00000002
72 #define TMIOFB_ACC_SCGO_ROP3 0x00000004
73 #define TMIOFB_ACC_SCGO_TRNS 0x00000008
74 #define TMIOFB_ACC_SCGO_DVRV 0x00000010
75 #define TMIOFB_ACC_SCGO_DHRV 0x00000020
76 #define TMIOFB_ACC_SCGO_SVRV 0x00000040
77 #define TMIOFB_ACC_SCGO_SHRV 0x00000080
78 #define TMIOFB_ACC_SCGO_DSTXY 0x00008000
79 #define TMIOFB_ACC_SBGO 0x22000000
80 #define TMIOFB_ACC_SBGO_CEND 0x00000001
81 #define TMIOFB_ACC_SBGO_INT 0x00000002
82 #define TMIOFB_ACC_SBGO_DVRV 0x00000010
83 #define TMIOFB_ACC_SBGO_DHRV 0x00000020
84 #define TMIOFB_ACC_SBGO_SVRV 0x00000040
85 #define TMIOFB_ACC_SBGO_SHRV 0x00000080
86 #define TMIOFB_ACC_SBGO_SBMD 0x00000100
87 #define TMIOFB_ACC_FLGO 0x23000000
88 #define TMIOFB_ACC_FLGO_CEND 0x00000001
89 #define TMIOFB_ACC_FLGO_INT 0x00000002
90 #define TMIOFB_ACC_FLGO_ROP3 0x00000004
91 #define TMIOFB_ACC_LDGO 0x24000000
92 #define TMIOFB_ACC_LDGO_CEND 0x00000001
93 #define TMIOFB_ACC_LDGO_INT 0x00000002
94 #define TMIOFB_ACC_LDGO_ROP3 0x00000004
95 #define TMIOFB_ACC_LDGO_ENDPX 0x00000008
96 #define TMIOFB_ACC_LDGO_LVRV 0x00000010
97 #define TMIOFB_ACC_LDGO_LHRV 0x00000020
98 #define TMIOFB_ACC_LDGO_LDMOD 0x00000040
101 #define TMIOFB_FIFO_SIZE 512
109 #define CCR_REVID 0x08
110 #define CCR_BASEL 0x10
111 #define CCR_BASEH 0x12
112 #define CCR_UGCC 0x40
115 #define CCR_VRAMRTC 0x60
117 #define CCR_VRAMSAC 0x62
119 #define CCR_VRAMBC 0x64
126 #define LCR_UIS 0x000
127 #define LCR_VHPN 0x008
128 #define LCR_CFSAL 0x00a
129 #define LCR_CFSAH 0x00c
130 #define LCR_CFS 0x00e
131 #define LCR_CFWS 0x010
132 #define LCR_BBIE 0x012
133 #define LCR_BBISC 0x014
134 #define LCR_CCS 0x016
135 #define LCR_BBES 0x018
136 #define LCR_CMDL 0x01c
137 #define LCR_CMDH 0x01e
138 #define LCR_CFC 0x022
139 #define LCR_CCIFC 0x024
140 #define LCR_HWT 0x026
141 #define LCR_LCDCCRC 0x100
142 #define LCR_LCDCC 0x102
143 #define LCR_LCDCOPC 0x104
144 #define LCR_LCDIS 0x108
145 #define LCR_LCDIM 0x10a
146 #define LCR_LCDIE 0x10c
147 #define LCR_GDSAL 0x122
148 #define LCR_GDSAH 0x124
149 #define LCR_VHPCL 0x12a
150 #define LCR_VHPCH 0x12c
153 #define LCR_HDS 0x142
154 #define LCR_HSS 0x144
155 #define LCR_HSE 0x146
156 #define LCR_HNP 0x14c
158 #define LCR_VDS 0x152
159 #define LCR_VSS 0x154
160 #define LCR_VSE 0x156
161 #define LCR_CDLN 0x160
162 #define LCR_ILN 0x162
164 #define LCR_MISC 0x166
165 #define LCR_VIHSS 0x16a
166 #define LCR_VIVS 0x16c
167 #define LCR_VIVE 0x16e
168 #define LCR_VIVSS 0x170
169 #define LCR_VCCIS 0x17e
170 #define LCR_VIDWSAL 0x180
171 #define LCR_VIDWSAH 0x182
172 #define LCR_VIDRSAL 0x184
173 #define LCR_VIDRSAH 0x186
174 #define LCR_VIPDDST 0x188
175 #define LCR_VIPDDET 0x186
176 #define LCR_VIE 0x18c
177 #define LCR_VCS 0x18e
178 #define LCR_VPHWC 0x194
179 #define LCR_VPHS 0x196
180 #define LCR_VPVWC 0x198
181 #define LCR_VPVS 0x19a
182 #define LCR_PLHPIX 0x1a0
184 #define LCR_XCKHW 0x1a4
185 #define LCR_STHS 0x1a8
186 #define LCR_VT2 0x1aa
187 #define LCR_YCKSW 0x1ac
188 #define LCR_YSTS 0x1ae
189 #define LCR_PPOLS 0x1b0
190 #define LCR_PRECW 0x1b2
191 #define LCR_VCLKHW 0x1b4
199 #ifdef CONFIG_FB_TMIO_ACCELL
218 static irqreturn_t tmiofb_irq(
int irq,
void *__info)
227 #ifdef CONFIG_FB_TMIO_ACCELL
232 if (
unlikely(par->use_polling && irq != -1)) {
234 par->use_polling =
false;
254 struct fb_info *info = platform_get_drvdata(dev);
270 const struct mfd_cell *cell = mfd_get_cell(dev);
271 struct fb_info *info = platform_get_drvdata(dev);
315 struct fb_info *info = platform_get_drvdata(dev);
356 #ifdef CONFIG_FB_TMIO_ACCELL
358 tmiofb_acc_wait(
struct fb_info *info,
unsigned int ccs)
372 pr_err(
"tmiofb: timeout waiting for %d\n",
376 tmiofb_irq(-1, info);
382 pr_err(
"tmiofb: timeout waiting for %d\n", ccs);
403 for (;
count; count--, cmd++) {
415 static int tmiofb_sync(
struct fb_info *fbi)
422 ret = tmiofb_acc_wait(fbi, 0);
477 static void tmiofb_clearscreen(
struct fb_info *info)
482 .width = info->
mode->xres,
483 .height = info->
mode->yres,
488 info->
fbops->fb_fillrect(info, &rect);
505 if (vcount < vds || vcount > vds + mode->
yres)
512 static int tmiofb_ioctl(
struct fb_info *fbi,
513 unsigned int cmd,
unsigned long arg)
520 tmiofb_vblank(fbi, &vblank);
526 #ifdef CONFIG_FB_TMIO_ACCELL
543 return tmiofb_acc_write(fbi, acc, len);
568 && (!best || (mode->
xres < best->
xres
582 mode = tmiofb_find_mode(info, var);
598 var->
red.offset = 11;
600 var->
green.offset = 5;
601 var->
green.length = 6;
602 var->
blue.offset = 0;
603 var->
blue.length = 5;
613 static int tmiofb_set_par(
struct fb_info *info)
618 mode = tmiofb_find_mode(info, var);
623 info->
fix.line_length = info->
mode->xres *
627 tmiofb_clearscreen(info);
631 static int tmiofb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
640 ((green & 0xfc00) >> 5) |
641 ((blue & 0xf800) >> 11);
648 static int tmiofb_blank(
int blank,
struct fb_info *info)
657 static struct fb_ops tmiofb_ops = {
660 .fb_ioctl = tmiofb_ioctl,
661 .fb_check_var = tmiofb_check_var,
662 .fb_set_par = tmiofb_set_par,
663 .fb_setcolreg = tmiofb_setcolreg,
664 .fb_blank = tmiofb_blank,
666 #ifdef CONFIG_FB_TMIO_ACCELL
667 .fb_sync = tmiofb_sync,
668 .fb_fillrect = tmiofb_fillrect,
669 .fb_copyarea = tmiofb_copyarea,
680 const struct mfd_cell *cell = mfd_get_cell(dev);
697 if (ccr ==
NULL || lcr ==
NULL || vram ==
NULL || irq < 0) {
709 #ifdef CONFIG_FB_TMIO_ACCELL
712 par->use_polling =
true;
720 info->
fbops = &tmiofb_ops;
724 info->
fix.smem_len = resource_size(vram);
728 info->
fix.mmio_len = resource_size(lcr);
736 goto err_ioremap_ccr;
742 goto err_ioremap_lcr;
748 goto err_ioremap_vram;
752 dev_name(&dev->
dev), info);
755 goto err_request_irq;
757 platform_set_drvdata(dev, info);
768 retval = cell->
enable(dev);
773 retval = tmiofb_hw_init(dev);
782 goto err_register_framebuffer;
789 err_register_framebuffer:
797 platform_set_drvdata(dev,
NULL);
812 const struct mfd_cell *cell = mfd_get_cell(dev);
813 struct fb_info *info = platform_get_drvdata(dev);
826 platform_set_drvdata(dev,
NULL);
843 struct fb_info *info = platform_get_drvdata(dev);
847 #define CCR_PR(n) printk(KERN_DEBUG "\t" #n " = \t%04x\n",\
848 tmio_ioread16(par->ccr + CCR_ ## n));
862 #define LCR_PR(n) printk(KERN_DEBUG "\t" #n " = \t%04x\n",\
863 tmio_ioread16(par->lcr + LCR_ ## n));
938 struct fb_info *info = platform_get_drvdata(dev);
939 #ifdef CONFIG_FB_TMIO_ACCELL
942 const struct mfd_cell *cell = mfd_get_cell(dev);
949 if (info->
fbops->fb_sync)
950 info->
fbops->fb_sync(info);
953 #ifdef CONFIG_FB_TMIO_ACCELL
959 par->use_polling =
true;
973 struct fb_info *info = platform_get_drvdata(dev);
974 const struct mfd_cell *cell = mfd_get_cell(dev);
980 retval = cell->
resume(dev);
985 tmiofb_irq(-1, info);
997 #define tmiofb_suspend NULL
998 #define tmiofb_resume NULL
1002 .driver.name =
"tmio-fb",
1004 .probe = tmiofb_probe,
1017 if (!options || !*options)
1020 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
1030 static int __init tmiofb_init(
void)
1037 tmiofb_setup(option);
1042 static void __exit tmiofb_cleanup(
void)
1051 MODULE_AUTHOR(
"Chris Humbert, Dirk Opfer, Dmitry Baryshkov");