1 /* ffb.c: Creator/Elite3D frame buffer driver
6 * Driver layout based loosely on tgafb.c, see that file for credits.
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/string.h>
13 #include <linux/delay.h>
14 #include <linux/init.h>
17 #include <linux/timer.h>
18 #include <linux/of_device.h>
30 static int ffb_setcolreg(unsigned, unsigned, unsigned, unsigned,
31 unsigned, struct fb_info *);
32 static int ffb_blank(int, struct fb_info *);
34 static void ffb_imageblit(struct fb_info *, const struct fb_image *);
35 static void ffb_fillrect(struct fb_info *, const struct fb_fillrect *);
36 static void ffb_copyarea(struct fb_info *, const struct fb_copyarea *);
37 static int ffb_sync(struct fb_info *);
38 static int ffb_mmap(struct fb_info *, struct vm_area_struct *);
39 static int ffb_ioctl(struct fb_info *, unsigned int, unsigned long);
40 static int ffb_pan_display(struct fb_var_screeninfo *, struct fb_info *);
43 * Frame buffer operations
46 static struct fb_ops ffb_ops = {
48 .fb_setcolreg = ffb_setcolreg,
49 .fb_blank = ffb_blank,
50 .fb_pan_display = ffb_pan_display,
51 .fb_fillrect = ffb_fillrect,
52 .fb_copyarea = ffb_copyarea,
53 .fb_imageblit = ffb_imageblit,
56 .fb_ioctl = ffb_ioctl,
58 .fb_compat_ioctl = sbusfb_compat_ioctl,
62 /* Register layout and definitions */
63 #define FFB_SFB8R_VOFF 0x00000000
64 #define FFB_SFB8G_VOFF 0x00400000
65 #define FFB_SFB8B_VOFF 0x00800000
66 #define FFB_SFB8X_VOFF 0x00c00000
67 #define FFB_SFB32_VOFF 0x01000000
68 #define FFB_SFB64_VOFF 0x02000000
69 #define FFB_FBC_REGS_VOFF 0x04000000
70 #define FFB_BM_FBC_REGS_VOFF 0x04002000
71 #define FFB_DFB8R_VOFF 0x04004000
72 #define FFB_DFB8G_VOFF 0x04404000
73 #define FFB_DFB8B_VOFF 0x04804000
74 #define FFB_DFB8X_VOFF 0x04c04000
75 #define FFB_DFB24_VOFF 0x05004000
76 #define FFB_DFB32_VOFF 0x06004000
77 #define FFB_DFB422A_VOFF 0x07004000 /* DFB 422 mode write to A */
78 #define FFB_DFB422AD_VOFF 0x07804000 /* DFB 422 mode with line doubling */
79 #define FFB_DFB24B_VOFF 0x08004000 /* DFB 24bit mode write to B */
80 #define FFB_DFB422B_VOFF 0x09004000 /* DFB 422 mode write to B */
81 #define FFB_DFB422BD_VOFF 0x09804000 /* DFB 422 mode with line doubling */
82 #define FFB_SFB16Z_VOFF 0x0a004000 /* 16bit mode Z planes */
83 #define FFB_SFB8Z_VOFF 0x0a404000 /* 8bit mode Z planes */
84 #define FFB_SFB422_VOFF 0x0ac04000 /* SFB 422 mode write to A/B */
85 #define FFB_SFB422D_VOFF 0x0b404000 /* SFB 422 mode with line doubling */
86 #define FFB_FBC_KREGS_VOFF 0x0bc04000
87 #define FFB_DAC_VOFF 0x0bc06000
88 #define FFB_PROM_VOFF 0x0bc08000
89 #define FFB_EXP_VOFF 0x0bc18000
91 #define FFB_SFB8R_POFF 0x04000000UL
92 #define FFB_SFB8G_POFF 0x04400000UL
93 #define FFB_SFB8B_POFF 0x04800000UL
94 #define FFB_SFB8X_POFF 0x04c00000UL
95 #define FFB_SFB32_POFF 0x05000000UL
96 #define FFB_SFB64_POFF 0x06000000UL
97 #define FFB_FBC_REGS_POFF 0x00600000UL
98 #define FFB_BM_FBC_REGS_POFF 0x00600000UL
99 #define FFB_DFB8R_POFF 0x01000000UL
100 #define FFB_DFB8G_POFF 0x01400000UL
101 #define FFB_DFB8B_POFF 0x01800000UL
102 #define FFB_DFB8X_POFF 0x01c00000UL
103 #define FFB_DFB24_POFF 0x02000000UL
104 #define FFB_DFB32_POFF 0x03000000UL
105 #define FFB_FBC_KREGS_POFF 0x00610000UL
106 #define FFB_DAC_POFF 0x00400000UL
107 #define FFB_PROM_POFF 0x00000000UL
108 #define FFB_EXP_POFF 0x00200000UL
109 #define FFB_DFB422A_POFF 0x09000000UL
110 #define FFB_DFB422AD_POFF 0x09800000UL
111 #define FFB_DFB24B_POFF 0x0a000000UL
112 #define FFB_DFB422B_POFF 0x0b000000UL
113 #define FFB_DFB422BD_POFF 0x0b800000UL
114 #define FFB_SFB16Z_POFF 0x0c800000UL
115 #define FFB_SFB8Z_POFF 0x0c000000UL
116 #define FFB_SFB422_POFF 0x0d000000UL
117 #define FFB_SFB422D_POFF 0x0d800000UL
119 /* Draw operations */
120 #define FFB_DRAWOP_DOT 0x00
121 #define FFB_DRAWOP_AADOT 0x01
122 #define FFB_DRAWOP_BRLINECAP 0x02
123 #define FFB_DRAWOP_BRLINEOPEN 0x03
124 #define FFB_DRAWOP_DDLINE 0x04
125 #define FFB_DRAWOP_AALINE 0x05
126 #define FFB_DRAWOP_TRIANGLE 0x06
127 #define FFB_DRAWOP_POLYGON 0x07
128 #define FFB_DRAWOP_RECTANGLE 0x08
129 #define FFB_DRAWOP_FASTFILL 0x09
130 #define FFB_DRAWOP_BCOPY 0x0a
131 #define FFB_DRAWOP_VSCROLL 0x0b
133 /* Pixel processor control */
135 #define FFB_PPC_FW_DISABLE 0x800000
136 #define FFB_PPC_FW_ENABLE 0xc00000
138 #define FFB_PPC_ACE_DISABLE 0x040000
139 #define FFB_PPC_ACE_AUX_SUB 0x080000
140 #define FFB_PPC_ACE_AUX_ADD 0x0c0000
142 #define FFB_PPC_DCE_DISABLE 0x020000
143 #define FFB_PPC_DCE_ENABLE 0x030000
145 #define FFB_PPC_ABE_DISABLE 0x008000
146 #define FFB_PPC_ABE_ENABLE 0x00c000
148 #define FFB_PPC_VCE_DISABLE 0x001000
149 #define FFB_PPC_VCE_2D 0x002000
150 #define FFB_PPC_VCE_3D 0x003000
152 #define FFB_PPC_APE_DISABLE 0x000800
153 #define FFB_PPC_APE_ENABLE 0x000c00
154 /* Transparent background */
155 #define FFB_PPC_TBE_OPAQUE 0x000200
156 #define FFB_PPC_TBE_TRANSPARENT 0x000300
158 #define FFB_PPC_ZS_VAR 0x000080
159 #define FFB_PPC_ZS_CONST 0x0000c0
161 #define FFB_PPC_YS_VAR 0x000020
162 #define FFB_PPC_YS_CONST 0x000030
164 #define FFB_PPC_XS_WID 0x000004
165 #define FFB_PPC_XS_VAR 0x000008
166 #define FFB_PPC_XS_CONST 0x00000c
167 /* Color (BGR) source */
168 #define FFB_PPC_CS_VAR 0x000002
169 #define FFB_PPC_CS_CONST 0x000003
171 #define FFB_ROP_NEW 0x83
172 #define FFB_ROP_OLD 0x85
173 #define FFB_ROP_NEW_XOR_OLD 0x86
175 #define FFB_UCSR_FIFO_MASK 0x00000fff
176 #define FFB_UCSR_FB_BUSY 0x01000000
177 #define FFB_UCSR_RP_BUSY 0x02000000
178 #define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY)
179 #define FFB_UCSR_READ_ERR 0x40000000
180 #define FFB_UCSR_FIFO_OVFL 0x80000000
181 #define FFB_UCSR_ALL_ERRORS (FFB_UCSR_READ_ERR|FFB_UCSR_FIFO_OVFL)
184 /* Next vertex registers */
214 /* Setup unit vertex state register */
218 /* Control registers */
270 /* New 3dRAM III support regs */
336 #define FFB_DAC_UCTRL 0x1001 /* User Control */
337 #define FFB_DAC_UCTRL_MANREV 0x00000f00 /* 4-bit Manufacturing Revision */
338 #define FFB_DAC_UCTRL_MANREV_SHIFT 8
339 #define FFB_DAC_TGEN 0x6000 /* Timing Generator */
340 #define FFB_DAC_TGEN_VIDE 0x00000001 /* Video Enable */
341 #define FFB_DAC_DID 0x8000 /* Device Identification */
342 #define FFB_DAC_DID_PNUM 0x0ffff000 /* Device Part Number */
343 #define FFB_DAC_DID_PNUM_SHIFT 12
344 #define FFB_DAC_DID_REV 0xf0000000 /* Device Revision */
345 #define FFB_DAC_DID_REV_SHIFT 28
347 #define FFB_DAC_CUR_CTRL 0x100
348 #define FFB_DAC_CUR_CTRL_P0 0x00000001
349 #define FFB_DAC_CUR_CTRL_P1 0x00000002
353 struct ffb_fbc __iomem *fbc;
354 struct ffb_dac __iomem *dac;
357 #define FFB_FLAG_AFB 0x00000001 /* AFB m3 or m6 */
358 #define FFB_FLAG_BLANKED 0x00000002 /* screen is blanked */
359 #define FFB_FLAG_INVCURSOR 0x00000004 /* DAC has inverted cursor logic */
361 u32 fg_cache __attribute__((aligned (8)));
367 unsigned long physbase;
368 unsigned long fbsize;
372 u32 pseudo_palette[16];
375 static void FFBFifo(struct ffb_par *par, int n)
377 struct ffb_fbc __iomem *fbc;
378 int cache = par->fifo_cache;
383 cache = (upa_readl(&fbc->ucsr) & FFB_UCSR_FIFO_MASK);
385 } while (cache - n < 0);
387 par->fifo_cache = cache - n;
390 static void FFBWait(struct ffb_par *par)
392 struct ffb_fbc __iomem *fbc;
397 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_BUSY) == 0)
399 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_ERRORS) != 0) {
400 upa_writel(FFB_UCSR_ALL_ERRORS, &fbc->ucsr);
403 } while (--limit > 0);
406 static int ffb_sync(struct fb_info *p)
408 struct ffb_par *par = (struct ffb_par *)p->par;
414 static __inline__ void ffb_rop(struct ffb_par *par, u32 rop)
416 if (par->rop_cache != rop) {
418 upa_writel(rop, &par->fbc->rop);
419 par->rop_cache = rop;
423 static void ffb_switch_from_graph(struct ffb_par *par)
425 struct ffb_fbc __iomem *fbc = par->fbc;
426 struct ffb_dac __iomem *dac = par->dac;
429 spin_lock_irqsave(&par->lock, flags);
433 upa_writel(FFB_PPC_VCE_DISABLE | FFB_PPC_TBE_OPAQUE |
434 FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
436 upa_writel(0x2000707f, &fbc->fbc);
437 upa_writel(par->rop_cache, &fbc->rop);
438 upa_writel(0xffffffff, &fbc->pmask);
439 upa_writel((1 << 16) | (0 << 0), &fbc->fontinc);
440 upa_writel(par->fg_cache, &fbc->fg);
441 upa_writel(par->bg_cache, &fbc->bg);
444 /* Disable cursor. */
445 upa_writel(FFB_DAC_CUR_CTRL, &dac->type2);
446 if (par->flags & FFB_FLAG_INVCURSOR)
447 upa_writel(0, &dac->value2);
449 upa_writel((FFB_DAC_CUR_CTRL_P0 |
450 FFB_DAC_CUR_CTRL_P1), &dac->value2);
452 spin_unlock_irqrestore(&par->lock, flags);
455 static int ffb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
457 struct ffb_par *par = (struct ffb_par *)info->par;
459 /* We just use this to catch switches out of
462 ffb_switch_from_graph(par);
464 if (var->xoffset || var->yoffset || var->vmode)
470 * ffb_fillrect - Draws a rectangle on the screen.
472 * @info: frame buffer structure that represents a single frame buffer
473 * @rect: structure defining the rectagle and operation.
475 static void ffb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
477 struct ffb_par *par = (struct ffb_par *)info->par;
478 struct ffb_fbc __iomem *fbc = par->fbc;
482 BUG_ON(rect->rop != ROP_COPY && rect->rop != ROP_XOR);
484 fg = ((u32 *)info->pseudo_palette)[rect->color];
486 spin_lock_irqsave(&par->lock, flags);
488 if (fg != par->fg_cache) {
490 upa_writel(fg, &fbc->fg);
494 ffb_rop(par, rect->rop == ROP_COPY ?
496 FFB_ROP_NEW_XOR_OLD);
499 upa_writel(FFB_DRAWOP_RECTANGLE, &fbc->drawop);
500 upa_writel(rect->dy, &fbc->by);
501 upa_writel(rect->dx, &fbc->bx);
502 upa_writel(rect->height, &fbc->bh);
503 upa_writel(rect->width, &fbc->bw);
505 spin_unlock_irqrestore(&par->lock, flags);
509 * ffb_copyarea - Copies on area of the screen to another area.
511 * @info: frame buffer structure that represents a single frame buffer
512 * @area: structure defining the source and destination.
515 static void ffb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
517 struct ffb_par *par = (struct ffb_par *)info->par;
518 struct ffb_fbc __iomem *fbc = par->fbc;
521 if (area->dx != area->sx ||
522 area->dy == area->sy) {
523 cfb_copyarea(info, area);
527 spin_lock_irqsave(&par->lock, flags);
529 ffb_rop(par, FFB_ROP_OLD);
532 upa_writel(FFB_DRAWOP_VSCROLL, &fbc->drawop);
533 upa_writel(area->sy, &fbc->by);
534 upa_writel(area->sx, &fbc->bx);
535 upa_writel(area->dy, &fbc->dy);
536 upa_writel(area->dx, &fbc->dx);
537 upa_writel(area->height, &fbc->bh);
538 upa_writel(area->width, &fbc->bw);
540 spin_unlock_irqrestore(&par->lock, flags);
544 * ffb_imageblit - Copies a image from system memory to the screen.
546 * @info: frame buffer structure that represents a single frame buffer
547 * @image: structure defining the image.
549 static void ffb_imageblit(struct fb_info *info, const struct fb_image *image)
551 struct ffb_par *par = (struct ffb_par *)info->par;
552 struct ffb_fbc __iomem *fbc = par->fbc;
553 const u8 *data = image->data;
557 int i, width, stride;
559 if (image->depth > 1) {
560 cfb_imageblit(info, image);
564 fg = ((u32 *)info->pseudo_palette)[image->fg_color];
565 bg = ((u32 *)info->pseudo_palette)[image->bg_color];
566 fgbg = ((u64) fg << 32) | (u64) bg;
567 xy = (image->dy << 16) | image->dx;
568 width = image->width;
569 stride = ((width + 7) >> 3);
571 spin_lock_irqsave(&par->lock, flags);
573 if (fgbg != *(u64 *)&par->fg_cache) {
575 upa_writeq(fgbg, &fbc->fg);
576 *(u64 *)&par->fg_cache = fgbg;
581 upa_writel(32, &fbc->fontw);
584 while (width >= 32) {
585 const u8 *next_data = data + 4;
588 upa_writel(xy, &fbc->fontxy);
591 for (i = 0; i < image->height; i++) {
592 u32 val = (((u32)data[0] << 24) |
593 ((u32)data[1] << 16) |
594 ((u32)data[2] << 8) |
595 ((u32)data[3] << 0));
597 upa_writel(val, &fbc->font);
608 upa_writel(width, &fbc->fontw);
609 upa_writel(xy, &fbc->fontxy);
611 for (i = 0; i < image->height; i++) {
612 u32 val = (((u32)data[0] << 24) |
613 ((u32)data[1] << 16) |
614 ((u32)data[2] << 8) |
615 ((u32)data[3] << 0));
617 upa_writel(val, &fbc->font);
623 spin_unlock_irqrestore(&par->lock, flags);
626 static void ffb_fixup_var_rgb(struct fb_var_screeninfo *var)
630 var->green.offset = 8;
631 var->green.length = 8;
632 var->blue.offset = 16;
633 var->blue.length = 8;
634 var->transp.offset = 0;
635 var->transp.length = 0;
639 * ffb_setcolreg - Sets a color register.
641 * @regno: boolean, 0 copy local, 1 get_user() function
642 * @red: frame buffer colormap structure
643 * @green: The green value which can be up to 16 bits wide
644 * @blue: The blue value which can be up to 16 bits wide.
645 * @transp: If supported the alpha value which can be up to 16 bits wide.
646 * @info: frame buffer info structure
648 static int ffb_setcolreg(unsigned regno,
649 unsigned red, unsigned green, unsigned blue,
650 unsigned transp, struct fb_info *info)
661 value = (blue << 16) | (green << 8) | red;
662 ((u32 *)info->pseudo_palette)[regno] = value;
668 * ffb_blank - Optional function. Blanks the display.
669 * @blank_mode: the blank mode we want.
670 * @info: frame buffer structure that represents a single frame buffer
672 static int ffb_blank(int blank, struct fb_info *info)
674 struct ffb_par *par = (struct ffb_par *)info->par;
675 struct ffb_dac __iomem *dac = par->dac;
680 spin_lock_irqsave(&par->lock, flags);
684 upa_writel(FFB_DAC_TGEN, &dac->type);
685 val = upa_readl(&dac->value);
687 case FB_BLANK_UNBLANK: /* Unblanking */
688 val |= FFB_DAC_TGEN_VIDE;
689 par->flags &= ~FFB_FLAG_BLANKED;
692 case FB_BLANK_NORMAL: /* Normal blanking */
693 case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
694 case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
695 case FB_BLANK_POWERDOWN: /* Poweroff */
696 val &= ~FFB_DAC_TGEN_VIDE;
697 par->flags |= FFB_FLAG_BLANKED;
700 upa_writel(FFB_DAC_TGEN, &dac->type);
701 upa_writel(val, &dac->value);
702 for (i = 0; i < 10; i++) {
703 upa_writel(FFB_DAC_TGEN, &dac->type);
704 upa_readl(&dac->value);
707 spin_unlock_irqrestore(&par->lock, flags);
712 static struct sbus_mmap_map ffb_mmap_map[] = {
714 .voff = FFB_SFB8R_VOFF,
715 .poff = FFB_SFB8R_POFF,
719 .voff = FFB_SFB8G_VOFF,
720 .poff = FFB_SFB8G_POFF,
724 .voff = FFB_SFB8B_VOFF,
725 .poff = FFB_SFB8B_POFF,
729 .voff = FFB_SFB8X_VOFF,
730 .poff = FFB_SFB8X_POFF,
734 .voff = FFB_SFB32_VOFF,
735 .poff = FFB_SFB32_POFF,
739 .voff = FFB_SFB64_VOFF,
740 .poff = FFB_SFB64_POFF,
744 .voff = FFB_FBC_REGS_VOFF,
745 .poff = FFB_FBC_REGS_POFF,
749 .voff = FFB_BM_FBC_REGS_VOFF,
750 .poff = FFB_BM_FBC_REGS_POFF,
754 .voff = FFB_DFB8R_VOFF,
755 .poff = FFB_DFB8R_POFF,
759 .voff = FFB_DFB8G_VOFF,
760 .poff = FFB_DFB8G_POFF,
764 .voff = FFB_DFB8B_VOFF,
765 .poff = FFB_DFB8B_POFF,
769 .voff = FFB_DFB8X_VOFF,
770 .poff = FFB_DFB8X_POFF,
774 .voff = FFB_DFB24_VOFF,
775 .poff = FFB_DFB24_POFF,
779 .voff = FFB_DFB32_VOFF,
780 .poff = FFB_DFB32_POFF,
784 .voff = FFB_FBC_KREGS_VOFF,
785 .poff = FFB_FBC_KREGS_POFF,
789 .voff = FFB_DAC_VOFF,
790 .poff = FFB_DAC_POFF,
794 .voff = FFB_PROM_VOFF,
795 .poff = FFB_PROM_POFF,
799 .voff = FFB_EXP_VOFF,
800 .poff = FFB_EXP_POFF,
804 .voff = FFB_DFB422A_VOFF,
805 .poff = FFB_DFB422A_POFF,
809 .voff = FFB_DFB422AD_VOFF,
810 .poff = FFB_DFB422AD_POFF,
814 .voff = FFB_DFB24B_VOFF,
815 .poff = FFB_DFB24B_POFF,
819 .voff = FFB_DFB422B_VOFF,
820 .poff = FFB_DFB422B_POFF,
824 .voff = FFB_DFB422BD_VOFF,
825 .poff = FFB_DFB422BD_POFF,
829 .voff = FFB_SFB16Z_VOFF,
830 .poff = FFB_SFB16Z_POFF,
834 .voff = FFB_SFB8Z_VOFF,
835 .poff = FFB_SFB8Z_POFF,
839 .voff = FFB_SFB422_VOFF,
840 .poff = FFB_SFB422_POFF,
844 .voff = FFB_SFB422D_VOFF,
845 .poff = FFB_SFB422D_POFF,
851 static int ffb_mmap(struct fb_info *info, struct vm_area_struct *vma)
853 struct ffb_par *par = (struct ffb_par *)info->par;
855 return sbusfb_mmap_helper(ffb_mmap_map,
856 par->physbase, par->fbsize,
860 static int ffb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
862 struct ffb_par *par = (struct ffb_par *)info->par;
864 return sbusfb_ioctl_helper(cmd, arg, info,
865 FBTYPE_CREATOR, 24, par->fbsize);
872 static void ffb_init_fix(struct fb_info *info)
874 struct ffb_par *par = (struct ffb_par *)info->par;
875 const char *ffb_type_name;
877 if (!(par->flags & FFB_FLAG_AFB)) {
878 if ((par->board_type & 0x7) == 0x3)
879 ffb_type_name = "Creator 3D";
881 ffb_type_name = "Creator";
883 ffb_type_name = "Elite 3D";
885 strlcpy(info->fix.id, ffb_type_name, sizeof(info->fix.id));
887 info->fix.type = FB_TYPE_PACKED_PIXELS;
888 info->fix.visual = FB_VISUAL_TRUECOLOR;
890 /* Framebuffer length is the same regardless of resolution. */
891 info->fix.line_length = 8192;
893 info->fix.accel = FB_ACCEL_SUN_CREATOR;
896 static int __devinit ffb_probe(struct platform_device *op)
898 struct device_node *dp = op->dev.of_node;
899 struct ffb_fbc __iomem *fbc;
900 struct ffb_dac __iomem *dac;
901 struct fb_info *info;
903 u32 dac_pnum, dac_rev, dac_mrev;
906 info = framebuffer_alloc(sizeof(struct ffb_par), &op->dev);
914 spin_lock_init(&par->lock);
915 par->fbc = of_ioremap(&op->resource[2], 0,
916 sizeof(struct ffb_fbc), "ffb fbc");
920 par->dac = of_ioremap(&op->resource[1], 0,
921 sizeof(struct ffb_dac), "ffb dac");
925 par->rop_cache = FFB_ROP_NEW;
926 par->physbase = op->resource[0].start;
928 /* Don't mention copyarea, so SCROLL_REDRAW is always
929 * used. It is the fastest on this chip.
931 info->flags = (FBINFO_DEFAULT |
932 /* FBINFO_HWACCEL_COPYAREA | */
933 FBINFO_HWACCEL_FILLRECT |
934 FBINFO_HWACCEL_IMAGEBLIT);
936 info->fbops = &ffb_ops;
938 info->screen_base = (char *) par->physbase + FFB_DFB24_POFF;
939 info->pseudo_palette = par->pseudo_palette;
941 sbusfb_fill_var(&info->var, dp, 32);
942 par->fbsize = PAGE_ALIGN(info->var.xres * info->var.yres * 4);
943 ffb_fixup_var_rgb(&info->var);
945 info->var.accel_flags = FB_ACCELF_TEXT;
947 if (!strcmp(dp->name, "SUNW,afb"))
948 par->flags |= FFB_FLAG_AFB;
950 par->board_type = of_getintprop_default(dp, "board_type", 0);
953 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_ERRORS) != 0)
954 upa_writel(FFB_UCSR_ALL_ERRORS, &fbc->ucsr);
957 upa_writel(FFB_DAC_DID, &dac->type);
958 dac_pnum = upa_readl(&dac->value);
959 dac_rev = (dac_pnum & FFB_DAC_DID_REV) >> FFB_DAC_DID_REV_SHIFT;
960 dac_pnum = (dac_pnum & FFB_DAC_DID_PNUM) >> FFB_DAC_DID_PNUM_SHIFT;
962 upa_writel(FFB_DAC_UCTRL, &dac->type);
963 dac_mrev = upa_readl(&dac->value);
964 dac_mrev = (dac_mrev & FFB_DAC_UCTRL_MANREV) >>
965 FFB_DAC_UCTRL_MANREV_SHIFT;
967 /* Elite3D has different DAC revision numbering, and no DAC revisions
968 * have the reversed meaning of cursor enable. Otherwise, Pacifica 1
969 * ramdacs with manufacturing revision less than 3 have inverted
970 * cursor logic. We identify Pacifica 1 as not Pacifica 2, the
971 * latter having a part number value of 0x236e.
973 if ((par->flags & FFB_FLAG_AFB) || dac_pnum == 0x236e) {
974 par->flags &= ~FFB_FLAG_INVCURSOR;
977 par->flags |= FFB_FLAG_INVCURSOR;
980 ffb_switch_from_graph(par);
982 /* Unblank it just to be sure. When there are multiple
983 * FFB/AFB cards in the system, or it is not the OBP
984 * chosen console, it will have video outputs off in
987 ffb_blank(FB_BLANK_UNBLANK, info);
989 if (fb_alloc_cmap(&info->cmap, 256, 0))
994 err = register_framebuffer(info);
996 goto out_dealloc_cmap;
998 dev_set_drvdata(&op->dev, info);
1000 printk(KERN_INFO "%s: %s at %016lx, type %d, "
1001 "DAC pnum[%x] rev[%d] manuf_rev[%d]\n",
1003 ((par->flags & FFB_FLAG_AFB) ? "AFB" : "FFB"),
1004 par->physbase, par->board_type,
1005 dac_pnum, dac_rev, dac_mrev);
1010 fb_dealloc_cmap(&info->cmap);
1013 of_iounmap(&op->resource[1], par->dac, sizeof(struct ffb_dac));
1016 of_iounmap(&op->resource[2], par->fbc, sizeof(struct ffb_fbc));
1019 framebuffer_release(info);
1025 static int __devexit ffb_remove(struct platform_device *op)
1027 struct fb_info *info = dev_get_drvdata(&op->dev);
1028 struct ffb_par *par = info->par;
1030 unregister_framebuffer(info);
1031 fb_dealloc_cmap(&info->cmap);
1033 of_iounmap(&op->resource[2], par->fbc, sizeof(struct ffb_fbc));
1034 of_iounmap(&op->resource[1], par->dac, sizeof(struct ffb_dac));
1036 framebuffer_release(info);
1038 dev_set_drvdata(&op->dev, NULL);
1043 static const struct of_device_id ffb_match[] = {
1052 MODULE_DEVICE_TABLE(of, ffb_match);
1054 static struct platform_driver ffb_driver = {
1057 .owner = THIS_MODULE,
1058 .of_match_table = ffb_match,
1061 .remove = __devexit_p(ffb_remove),
1064 static int __init ffb_init(void)
1066 if (fb_get_options("ffb", NULL))
1069 return platform_driver_register(&ffb_driver);
1072 static void __exit ffb_exit(void)
1074 platform_driver_unregister(&ffb_driver);
1077 module_init(ffb_init);
1078 module_exit(ffb_exit);
1080 MODULE_DESCRIPTION("framebuffer driver for Creator/Elite3D chipsets");
1082 MODULE_VERSION("2.0");
1083 MODULE_LICENSE("GPL");