1 /* cg6.c: CGSIX (GX, GXplus, TGX) frame buffer driver
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
4 * Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
5 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
6 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
8 * Driver layout based loosely on tgafb.c, see that file for credits.
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/string.h>
15 #include <linux/slab.h>
16 #include <linux/delay.h>
17 #include <linux/init.h>
23 #include <asm/oplib.h>
32 static int cg6_setcolreg(unsigned, unsigned, unsigned, unsigned,
33 unsigned, struct fb_info
*);
34 static int cg6_blank(int, struct fb_info
*);
36 static void cg6_imageblit(struct fb_info
*, const struct fb_image
*);
37 static void cg6_fillrect(struct fb_info
*, const struct fb_fillrect
*);
38 static int cg6_sync(struct fb_info
*);
39 static int cg6_mmap(struct fb_info
*, struct file
*, struct vm_area_struct
*);
40 static int cg6_ioctl(struct inode
*, struct file
*, unsigned int,
41 unsigned long, struct fb_info
*);
44 * Frame buffer operations
47 static struct fb_ops cg6_ops
= {
49 .fb_setcolreg
= cg6_setcolreg
,
50 .fb_blank
= cg6_blank
,
51 .fb_fillrect
= cg6_fillrect
,
52 .fb_copyarea
= cfb_copyarea
,
53 .fb_imageblit
= cg6_imageblit
,
56 .fb_ioctl
= cg6_ioctl
,
58 .fb_compat_ioctl
= sbusfb_compat_ioctl
,
62 /* Offset of interesting structures in the OBIO space */
64 * Brooktree is the video dac and is funny to program on the cg6.
65 * (it's even funnier on the cg3)
66 * The FBC could be the frame buffer control
67 * The FHC could is the frame buffer hardware control.
69 #define CG6_ROM_OFFSET 0x0UL
70 #define CG6_BROOKTREE_OFFSET 0x200000UL
71 #define CG6_DHC_OFFSET 0x240000UL
72 #define CG6_ALT_OFFSET 0x280000UL
73 #define CG6_FHC_OFFSET 0x300000UL
74 #define CG6_THC_OFFSET 0x301000UL
75 #define CG6_FBC_OFFSET 0x700000UL
76 #define CG6_TEC_OFFSET 0x701000UL
77 #define CG6_RAM_OFFSET 0x800000UL
80 #define CG6_FHC_FBID_SHIFT 24
81 #define CG6_FHC_FBID_MASK 255
82 #define CG6_FHC_REV_SHIFT 20
83 #define CG6_FHC_REV_MASK 15
84 #define CG6_FHC_FROP_DISABLE (1 << 19)
85 #define CG6_FHC_ROW_DISABLE (1 << 18)
86 #define CG6_FHC_SRC_DISABLE (1 << 17)
87 #define CG6_FHC_DST_DISABLE (1 << 16)
88 #define CG6_FHC_RESET (1 << 15)
89 #define CG6_FHC_LITTLE_ENDIAN (1 << 13)
90 #define CG6_FHC_RES_MASK (3 << 11)
91 #define CG6_FHC_1024 (0 << 11)
92 #define CG6_FHC_1152 (1 << 11)
93 #define CG6_FHC_1280 (2 << 11)
94 #define CG6_FHC_1600 (3 << 11)
95 #define CG6_FHC_CPU_MASK (3 << 9)
96 #define CG6_FHC_CPU_SPARC (0 << 9)
97 #define CG6_FHC_CPU_68020 (1 << 9)
98 #define CG6_FHC_CPU_386 (2 << 9)
99 #define CG6_FHC_TEST (1 << 8)
100 #define CG6_FHC_TEST_X_SHIFT 4
101 #define CG6_FHC_TEST_X_MASK 15
102 #define CG6_FHC_TEST_Y_SHIFT 0
103 #define CG6_FHC_TEST_Y_MASK 15
105 /* FBC mode definitions */
106 #define CG6_FBC_BLIT_IGNORE 0x00000000
107 #define CG6_FBC_BLIT_NOSRC 0x00100000
108 #define CG6_FBC_BLIT_SRC 0x00200000
109 #define CG6_FBC_BLIT_ILLEGAL 0x00300000
110 #define CG6_FBC_BLIT_MASK 0x00300000
112 #define CG6_FBC_VBLANK 0x00080000
114 #define CG6_FBC_MODE_IGNORE 0x00000000
115 #define CG6_FBC_MODE_COLOR8 0x00020000
116 #define CG6_FBC_MODE_COLOR1 0x00040000
117 #define CG6_FBC_MODE_HRMONO 0x00060000
118 #define CG6_FBC_MODE_MASK 0x00060000
120 #define CG6_FBC_DRAW_IGNORE 0x00000000
121 #define CG6_FBC_DRAW_RENDER 0x00008000
122 #define CG6_FBC_DRAW_PICK 0x00010000
123 #define CG6_FBC_DRAW_ILLEGAL 0x00018000
124 #define CG6_FBC_DRAW_MASK 0x00018000
126 #define CG6_FBC_BWRITE0_IGNORE 0x00000000
127 #define CG6_FBC_BWRITE0_ENABLE 0x00002000
128 #define CG6_FBC_BWRITE0_DISABLE 0x00004000
129 #define CG6_FBC_BWRITE0_ILLEGAL 0x00006000
130 #define CG6_FBC_BWRITE0_MASK 0x00006000
132 #define CG6_FBC_BWRITE1_IGNORE 0x00000000
133 #define CG6_FBC_BWRITE1_ENABLE 0x00000800
134 #define CG6_FBC_BWRITE1_DISABLE 0x00001000
135 #define CG6_FBC_BWRITE1_ILLEGAL 0x00001800
136 #define CG6_FBC_BWRITE1_MASK 0x00001800
138 #define CG6_FBC_BREAD_IGNORE 0x00000000
139 #define CG6_FBC_BREAD_0 0x00000200
140 #define CG6_FBC_BREAD_1 0x00000400
141 #define CG6_FBC_BREAD_ILLEGAL 0x00000600
142 #define CG6_FBC_BREAD_MASK 0x00000600
144 #define CG6_FBC_BDISP_IGNORE 0x00000000
145 #define CG6_FBC_BDISP_0 0x00000080
146 #define CG6_FBC_BDISP_1 0x00000100
147 #define CG6_FBC_BDISP_ILLEGAL 0x00000180
148 #define CG6_FBC_BDISP_MASK 0x00000180
150 #define CG6_FBC_INDEX_MOD 0x00000040
151 #define CG6_FBC_INDEX_MASK 0x00000030
153 /* THC definitions */
154 #define CG6_THC_MISC_REV_SHIFT 16
155 #define CG6_THC_MISC_REV_MASK 15
156 #define CG6_THC_MISC_RESET (1 << 12)
157 #define CG6_THC_MISC_VIDEO (1 << 10)
158 #define CG6_THC_MISC_SYNC (1 << 9)
159 #define CG6_THC_MISC_VSYNC (1 << 8)
160 #define CG6_THC_MISC_SYNC_ENAB (1 << 7)
161 #define CG6_THC_MISC_CURS_RES (1 << 6)
162 #define CG6_THC_MISC_INT_ENAB (1 << 5)
163 #define CG6_THC_MISC_INT (1 << 4)
164 #define CG6_THC_MISC_INIT 0x9f
166 /* The contents are unknown */
168 volatile int tec_matrix
;
169 volatile int tec_clip
;
170 volatile int tec_vdc
;
175 volatile uint thc_hs
; /* hsync timing */
176 volatile uint thc_hsdvs
;
177 volatile uint thc_hd
;
178 volatile uint thc_vs
; /* vsync timing */
179 volatile uint thc_vd
;
180 volatile uint thc_refresh
;
181 volatile uint thc_misc
;
183 volatile uint thc_cursxy
; /* cursor x,y position (16 bits each) */
184 volatile uint thc_cursmask
[32]; /* cursor mask bits */
185 volatile uint thc_cursbits
[32]; /* what to show where mask enabled */
198 volatile u32 x0
, y0
, z0
, color0
;
199 volatile u32 x1
, y1
, z1
, color1
;
200 volatile u32 x2
, y2
, z2
, color2
;
201 volatile u32 x3
, y3
, z3
, color3
;
202 volatile u32 offx
, offy
;
204 volatile u32 incx
, incy
;
206 volatile u32 clipminx
, clipminy
;
208 volatile u32 clipmaxx
, clipmaxy
;
216 volatile u32 patalign
;
217 volatile u32 pattern
[8];
219 volatile u32 apointx
, apointy
, apointz
;
221 volatile u32 rpointx
, rpointy
, rpointz
;
223 volatile u32 pointr
, pointg
, pointb
, pointa
;
224 volatile u32 alinex
, aliney
, alinez
;
226 volatile u32 rlinex
, rliney
, rlinez
;
228 volatile u32 liner
, lineg
, lineb
, linea
;
229 volatile u32 atrix
, atriy
, atriz
;
231 volatile u32 rtrix
, rtriy
, rtriz
;
233 volatile u32 trir
, trig
, trib
, tria
;
234 volatile u32 aquadx
, aquady
, aquadz
;
236 volatile u32 rquadx
, rquady
, rquadz
;
238 volatile u32 quadr
, quadg
, quadb
, quada
;
239 volatile u32 arectx
, arecty
, arectz
;
241 volatile u32 rrectx
, rrecty
, rrectz
;
243 volatile u32 rectr
, rectg
, rectb
, recta
;
248 volatile u32 color_map
;
249 volatile u32 control
;
255 struct bt_regs __iomem
*bt
;
256 struct cg6_fbc __iomem
*fbc
;
257 struct cg6_thc __iomem
*thc
;
258 struct cg6_tec __iomem
*tec
;
259 volatile u32 __iomem
*fhc
;
262 #define CG6_FLAG_BLANKED 0x00000001
264 unsigned long physbase
;
265 unsigned long fbsize
;
267 struct sbus_dev
*sdev
;
268 struct list_head list
;
271 static int cg6_sync(struct fb_info
*info
)
273 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
274 struct cg6_fbc __iomem
*fbc
= par
->fbc
;
278 if (!(sbus_readl(&fbc
->s
) & 0x10000000))
281 } while (--limit
> 0);
287 * cg6_fillrect - REQUIRED function. Can use generic routines if
288 * non acclerated hardware and packed pixel based.
289 * Draws a rectangle on the screen.
291 * @info: frame buffer structure that represents a single frame buffer
292 * @rect: structure defining the rectagle and operation.
294 static void cg6_fillrect(struct fb_info
*info
, const struct fb_fillrect
*rect
)
296 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
297 struct cg6_fbc __iomem
*fbc
= par
->fbc
;
301 /* XXX doesn't handle ROP_XOR */
303 spin_lock_irqsave(&par
->lock
, flags
);
305 sbus_writel(rect
->color
, &fbc
->fg
);
306 sbus_writel(~(u32
)0, &fbc
->pixelm
);
307 sbus_writel(0xea80ff00, &fbc
->alu
);
308 sbus_writel(0, &fbc
->s
);
309 sbus_writel(0, &fbc
->clip
);
310 sbus_writel(~(u32
)0, &fbc
->pm
);
311 sbus_writel(rect
->dy
, &fbc
->arecty
);
312 sbus_writel(rect
->dx
, &fbc
->arectx
);
313 sbus_writel(rect
->dy
+ rect
->height
, &fbc
->arecty
);
314 sbus_writel(rect
->dx
+ rect
->width
, &fbc
->arectx
);
316 val
= sbus_readl(&fbc
->draw
);
317 } while (val
< 0 && (val
& 0x20000000));
318 spin_unlock_irqrestore(&par
->lock
, flags
);
322 * cg6_imageblit - REQUIRED function. Can use generic routines if
323 * non acclerated hardware and packed pixel based.
324 * Copies a image from system memory to the screen.
326 * @info: frame buffer structure that represents a single frame buffer
327 * @image: structure defining the image.
329 static void cg6_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
331 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
332 struct cg6_fbc __iomem
*fbc
= par
->fbc
;
333 const u8
*data
= image
->data
;
338 if (image
->depth
> 1) {
339 cfb_imageblit(info
, image
);
343 spin_lock_irqsave(&par
->lock
, flags
);
347 sbus_writel(image
->fg_color
, &fbc
->fg
);
348 sbus_writel(image
->bg_color
, &fbc
->bg
);
349 sbus_writel(0x140000, &fbc
->mode
);
350 sbus_writel(0xe880fc30, &fbc
->alu
);
351 sbus_writel(~(u32
)0, &fbc
->pixelm
);
352 sbus_writel(0, &fbc
->s
);
353 sbus_writel(0, &fbc
->clip
);
354 sbus_writel(0xff, &fbc
->pm
);
355 sbus_writel(32, &fbc
->incx
);
356 sbus_writel(0, &fbc
->incy
);
360 for (i
= 0; i
< image
->height
; i
++) {
361 width
= image
->width
;
363 while (width
>= 32) {
366 sbus_writel(y
, &fbc
->y0
);
367 sbus_writel(x
, &fbc
->x0
);
368 sbus_writel(x
+ 32 - 1, &fbc
->x1
);
370 val
= ((u32
)data
[0] << 24) |
371 ((u32
)data
[1] << 16) |
372 ((u32
)data
[2] << 8) |
374 sbus_writel(val
, &fbc
->font
);
383 sbus_writel(y
, &fbc
->y0
);
384 sbus_writel(x
, &fbc
->x0
);
385 sbus_writel(x
+ width
- 1, &fbc
->x1
);
387 val
= (u32
) data
[0] << 24;
389 } else if (width
<= 16) {
390 val
= ((u32
) data
[0] << 24) |
391 ((u32
) data
[1] << 16);
394 val
= ((u32
) data
[0] << 24) |
395 ((u32
) data
[1] << 16) |
396 ((u32
) data
[2] << 8);
399 sbus_writel(val
, &fbc
->font
);
406 spin_unlock_irqrestore(&par
->lock
, flags
);
410 * cg6_setcolreg - Optional function. Sets a color register.
411 * @regno: boolean, 0 copy local, 1 get_user() function
412 * @red: frame buffer colormap structure
413 * @green: The green value which can be up to 16 bits wide
414 * @blue: The blue value which can be up to 16 bits wide.
415 * @transp: If supported the alpha value which can be up to 16 bits wide.
416 * @info: frame buffer info structure
418 static int cg6_setcolreg(unsigned regno
,
419 unsigned red
, unsigned green
, unsigned blue
,
420 unsigned transp
, struct fb_info
*info
)
422 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
423 struct bt_regs __iomem
*bt
= par
->bt
;
433 spin_lock_irqsave(&par
->lock
, flags
);
435 sbus_writel((u32
)regno
<< 24, &bt
->addr
);
436 sbus_writel((u32
)red
<< 24, &bt
->color_map
);
437 sbus_writel((u32
)green
<< 24, &bt
->color_map
);
438 sbus_writel((u32
)blue
<< 24, &bt
->color_map
);
440 spin_unlock_irqrestore(&par
->lock
, flags
);
446 * cg6_blank - Optional function. Blanks the display.
447 * @blank_mode: the blank mode we want.
448 * @info: frame buffer structure that represents a single frame buffer
451 cg6_blank(int blank
, struct fb_info
*info
)
453 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
454 struct cg6_thc __iomem
*thc
= par
->thc
;
458 spin_lock_irqsave(&par
->lock
, flags
);
461 case FB_BLANK_UNBLANK
: /* Unblanking */
462 val
= sbus_readl(&thc
->thc_misc
);
463 val
|= CG6_THC_MISC_VIDEO
;
464 sbus_writel(val
, &thc
->thc_misc
);
465 par
->flags
&= ~CG6_FLAG_BLANKED
;
468 case FB_BLANK_NORMAL
: /* Normal blanking */
469 case FB_BLANK_VSYNC_SUSPEND
: /* VESA blank (vsync off) */
470 case FB_BLANK_HSYNC_SUSPEND
: /* VESA blank (hsync off) */
471 case FB_BLANK_POWERDOWN
: /* Poweroff */
472 val
= sbus_readl(&thc
->thc_misc
);
473 val
&= ~CG6_THC_MISC_VIDEO
;
474 sbus_writel(val
, &thc
->thc_misc
);
475 par
->flags
|= CG6_FLAG_BLANKED
;
479 spin_unlock_irqrestore(&par
->lock
, flags
);
484 static struct sbus_mmap_map cg6_mmap_map
[] = {
487 .poff
= CG6_FBC_OFFSET
,
492 .poff
= CG6_TEC_OFFSET
,
497 .poff
= CG6_BROOKTREE_OFFSET
,
502 .poff
= CG6_FHC_OFFSET
,
507 .poff
= CG6_THC_OFFSET
,
512 .poff
= CG6_ROM_OFFSET
,
517 .poff
= CG6_RAM_OFFSET
,
518 .size
= SBUS_MMAP_FBSIZE(1)
522 .poff
= CG6_DHC_OFFSET
,
528 static int cg6_mmap(struct fb_info
*info
, struct file
*file
, struct vm_area_struct
*vma
)
530 struct cg6_par
*par
= (struct cg6_par
*)info
->par
;
532 return sbusfb_mmap_helper(cg6_mmap_map
,
533 par
->physbase
, par
->fbsize
,
534 par
->sdev
->reg_addrs
[0].which_io
,
538 static int cg6_ioctl(struct inode
*inode
, struct file
*file
, unsigned int cmd
,
539 unsigned long arg
, struct fb_info
*info
)
541 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
543 return sbusfb_ioctl_helper(cmd
, arg
, info
,
544 FBTYPE_SUNFAST_COLOR
, 8, par
->fbsize
);
552 cg6_init_fix(struct fb_info
*info
, int linebytes
)
554 struct cg6_par
*par
= (struct cg6_par
*)info
->par
;
555 const char *cg6_cpu_name
, *cg6_card_name
;
558 conf
= sbus_readl(par
->fhc
);
559 switch(conf
& CG6_FHC_CPU_MASK
) {
560 case CG6_FHC_CPU_SPARC
:
561 cg6_cpu_name
= "sparc";
563 case CG6_FHC_CPU_68020
:
564 cg6_cpu_name
= "68020";
567 cg6_cpu_name
= "i386";
570 if (((conf
>> CG6_FHC_REV_SHIFT
) & CG6_FHC_REV_MASK
) >= 11) {
571 if (par
->fbsize
<= 0x100000) {
572 cg6_card_name
= "TGX";
574 cg6_card_name
= "TGX+";
577 if (par
->fbsize
<= 0x100000) {
578 cg6_card_name
= "GX";
580 cg6_card_name
= "GX+";
584 sprintf(info
->fix
.id
, "%s %s", cg6_card_name
, cg6_cpu_name
);
585 info
->fix
.id
[sizeof(info
->fix
.id
)-1] = 0;
587 info
->fix
.type
= FB_TYPE_PACKED_PIXELS
;
588 info
->fix
.visual
= FB_VISUAL_PSEUDOCOLOR
;
590 info
->fix
.line_length
= linebytes
;
592 info
->fix
.accel
= FB_ACCEL_SUN_CGSIX
;
595 /* Initialize Brooktree DAC */
596 static void cg6_bt_init(struct cg6_par
*par
)
598 struct bt_regs __iomem
*bt
= par
->bt
;
600 sbus_writel(0x04 << 24, &bt
->addr
); /* color planes */
601 sbus_writel(0xff << 24, &bt
->control
);
602 sbus_writel(0x05 << 24, &bt
->addr
);
603 sbus_writel(0x00 << 24, &bt
->control
);
604 sbus_writel(0x06 << 24, &bt
->addr
); /* overlay plane */
605 sbus_writel(0x73 << 24, &bt
->control
);
606 sbus_writel(0x07 << 24, &bt
->addr
);
607 sbus_writel(0x00 << 24, &bt
->control
);
610 static void cg6_chip_init(struct fb_info
*info
)
612 struct cg6_par
*par
= (struct cg6_par
*) info
->par
;
613 struct cg6_tec __iomem
*tec
= par
->tec
;
614 struct cg6_fbc __iomem
*fbc
= par
->fbc
;
615 u32 rev
, conf
, mode
, tmp
;
618 /* Turn off stuff in the Transform Engine. */
619 sbus_writel(0, &tec
->tec_matrix
);
620 sbus_writel(0, &tec
->tec_clip
);
621 sbus_writel(0, &tec
->tec_vdc
);
623 /* Take care of bugs in old revisions. */
624 rev
= (sbus_readl(par
->fhc
) >> CG6_FHC_REV_SHIFT
) & CG6_FHC_REV_MASK
;
626 conf
= (sbus_readl(par
->fhc
) & CG6_FHC_RES_MASK
) |
627 CG6_FHC_CPU_68020
| CG6_FHC_TEST
|
628 (11 << CG6_FHC_TEST_X_SHIFT
) |
629 (11 << CG6_FHC_TEST_Y_SHIFT
);
631 conf
|= CG6_FHC_DST_DISABLE
;
632 sbus_writel(conf
, par
->fhc
);
635 /* Set things in the FBC. Bad things appear to happen if we do
636 * back to back store/loads on the mode register, so copy it
638 mode
= sbus_readl(&fbc
->mode
);
640 i
= sbus_readl(&fbc
->s
);
641 } while (i
& 0x10000000);
642 mode
&= ~(CG6_FBC_BLIT_MASK
| CG6_FBC_MODE_MASK
|
643 CG6_FBC_DRAW_MASK
| CG6_FBC_BWRITE0_MASK
|
644 CG6_FBC_BWRITE1_MASK
| CG6_FBC_BREAD_MASK
|
646 mode
|= (CG6_FBC_BLIT_SRC
| CG6_FBC_MODE_COLOR8
|
647 CG6_FBC_DRAW_RENDER
| CG6_FBC_BWRITE0_ENABLE
|
648 CG6_FBC_BWRITE1_DISABLE
| CG6_FBC_BREAD_0
|
650 sbus_writel(mode
, &fbc
->mode
);
652 sbus_writel(0, &fbc
->clip
);
653 sbus_writel(0, &fbc
->offx
);
654 sbus_writel(0, &fbc
->offy
);
655 sbus_writel(0, &fbc
->clipminx
);
656 sbus_writel(0, &fbc
->clipminy
);
657 sbus_writel(info
->var
.xres
- 1, &fbc
->clipmaxx
);
658 sbus_writel(info
->var
.yres
- 1, &fbc
->clipmaxy
);
664 struct list_head list
;
666 static LIST_HEAD(cg6_list
);
668 static void cg6_init_one(struct sbus_dev
*sdev
)
670 struct all_info
*all
;
673 all
= kmalloc(sizeof(*all
), GFP_KERNEL
);
675 printk(KERN_ERR
"cg6: Cannot allocate memory.\n");
678 memset(all
, 0, sizeof(*all
));
680 INIT_LIST_HEAD(&all
->list
);
682 spin_lock_init(&all
->par
.lock
);
683 all
->par
.sdev
= sdev
;
685 all
->par
.physbase
= sdev
->reg_addrs
[0].phys_addr
;
687 sbusfb_fill_var(&all
->info
.var
, sdev
->prom_node
, 8);
688 all
->info
.var
.red
.length
= 8;
689 all
->info
.var
.green
.length
= 8;
690 all
->info
.var
.blue
.length
= 8;
692 linebytes
= prom_getintdefault(sdev
->prom_node
, "linebytes",
694 all
->par
.fbsize
= PAGE_ALIGN(linebytes
* all
->info
.var
.yres
);
695 if (prom_getbool(sdev
->prom_node
, "dblbuf"))
696 all
->par
.fbsize
*= 4;
698 all
->par
.fbc
= sbus_ioremap(&sdev
->resource
[0], CG6_FBC_OFFSET
,
700 all
->par
.tec
= sbus_ioremap(&sdev
->resource
[0], CG6_TEC_OFFSET
,
701 sizeof(struct cg6_tec
), "cgsix tec");
702 all
->par
.thc
= sbus_ioremap(&sdev
->resource
[0], CG6_THC_OFFSET
,
703 sizeof(struct cg6_thc
), "cgsix thc");
704 all
->par
.bt
= sbus_ioremap(&sdev
->resource
[0], CG6_BROOKTREE_OFFSET
,
705 sizeof(struct bt_regs
), "cgsix dac");
706 all
->par
.fhc
= sbus_ioremap(&sdev
->resource
[0], CG6_FHC_OFFSET
,
707 sizeof(u32
), "cgsix fhc");
709 all
->info
.flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_IMAGEBLIT
|
710 FBINFO_HWACCEL_COPYAREA
| FBINFO_HWACCEL_FILLRECT
;
711 all
->info
.fbops
= &cg6_ops
;
712 #ifdef CONFIG_SPARC32
713 all
->info
.screen_base
= (char __iomem
*)
714 prom_getintdefault(sdev
->prom_node
, "address", 0);
716 if (!all
->info
.screen_base
)
717 all
->info
.screen_base
=
718 sbus_ioremap(&sdev
->resource
[0], CG6_RAM_OFFSET
,
719 all
->par
.fbsize
, "cgsix ram");
720 all
->info
.par
= &all
->par
;
722 all
->info
.var
.accel_flags
= FB_ACCELF_TEXT
;
724 cg6_bt_init(&all
->par
);
725 cg6_chip_init(&all
->info
);
726 cg6_blank(0, &all
->info
);
728 if (fb_alloc_cmap(&all
->info
.cmap
, 256, 0)) {
729 printk(KERN_ERR
"cg6: Could not allocate color map.\n");
734 fb_set_cmap(&all
->info
.cmap
, &all
->info
);
735 cg6_init_fix(&all
->info
, linebytes
);
737 if (register_framebuffer(&all
->info
) < 0) {
738 printk(KERN_ERR
"cg6: Could not register framebuffer.\n");
739 fb_dealloc_cmap(&all
->info
.cmap
);
744 list_add(&all
->list
, &cg6_list
);
746 printk("cg6: CGsix [%s] at %lx:%lx\n",
748 (long) sdev
->reg_addrs
[0].which_io
,
749 (long) sdev
->reg_addrs
[0].phys_addr
);
752 int __init
cg6_init(void)
754 struct sbus_bus
*sbus
;
755 struct sbus_dev
*sdev
;
757 if (fb_get_options("cg6fb", NULL
))
760 for_all_sbusdev(sdev
, sbus
) {
761 if (!strcmp(sdev
->prom_name
, "cgsix") ||
762 !strcmp(sdev
->prom_name
, "cgthree+"))
769 void __exit
cg6_exit(void)
771 struct list_head
*pos
, *tmp
;
773 list_for_each_safe(pos
, tmp
, &cg6_list
) {
774 struct all_info
*all
= list_entry(pos
, typeof(*all
), list
);
776 unregister_framebuffer(&all
->info
);
777 fb_dealloc_cmap(&all
->info
.cmap
);
785 /* No cmdline options yet... */
789 module_init(cg6_init
);
792 module_exit(cg6_exit
);
795 MODULE_DESCRIPTION("framebuffer driver for CGsix chipsets");
796 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
797 MODULE_LICENSE("GPL");