2 * linux/drivers/video/cyber2000fb.c
4 * Copyright (C) 1998-2002 Russell King
6 * MIPS and 50xx clock support
7 * Copyright (C) 2001 Bradley D. LaRonde <brad@ltc.com>
9 * 32 bit support, text color and panning fixes for modes != 8 bit
10 * Copyright (C) 2002 Denis Oliver Kropp <dok@directfb.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * Integraphics CyberPro 2000, 2010 and 5000 frame buffer device
20 * Note that we now use the new fbcon fix, var and cmap scheme. We do
21 * still have to check which console is the currently displayed one
22 * however, especially for the colourmap stuff.
24 * We also use the new hotplug PCI subsystem. I'm not sure if there
25 * are any such cards, but I'm erring on the side of caution. We don't
26 * want to go pop just because someone does have one.
28 * Note that this doesn't work fully in the case of multiple CyberPro
29 * cards with grabbers. We currently can only attach to the first
30 * CyberPro card found.
32 * When we're in truecolour mode, we power down the LUT RAM as a power
33 * saving feature. Also, when we enter any of the powersaving modes
34 * (except soft blanking) we power down the RAMDACs. This saves about
35 * 1W, which is roughly 8% of the power consumption of a NetWinder
36 * (which, incidentally, is about the same saving as a 2.5in hard disk
37 * entering standby mode.)
39 #include <linux/module.h>
40 #include <linux/kernel.h>
41 #include <linux/errno.h>
42 #include <linux/string.h>
44 #include <linux/slab.h>
45 #include <linux/delay.h>
47 #include <linux/pci.h>
48 #include <linux/init.h>
51 #include <asm/pgtable.h>
52 #include <asm/system.h>
53 #include <asm/uaccess.h>
56 #include <asm/mach-types.h>
59 #include "cyber2000fb.h"
63 struct display_switch
*dispsw
;
64 struct display
*display
;
66 unsigned char __iomem
*region
;
67 unsigned char __iomem
*regs
;
79 } palette
[NR_PALETTE
];
86 * RAMDAC control register is both of these or'ed together
89 u_char ramdac_powerdown
;
91 u32 pseudo_palette
[16];
94 static char *default_font
= "Acorn8x8";
95 module_param(default_font
, charp
, 0);
96 MODULE_PARM_DESC(default_font
, "Default font name");
101 #define cyber2000fb_writel(val,reg,cfb) writel(val, (cfb)->regs + (reg))
102 #define cyber2000fb_writew(val,reg,cfb) writew(val, (cfb)->regs + (reg))
103 #define cyber2000fb_writeb(val,reg,cfb) writeb(val, (cfb)->regs + (reg))
105 #define cyber2000fb_readb(reg,cfb) readb((cfb)->regs + (reg))
108 cyber2000_crtcw(unsigned int reg
, unsigned int val
, struct cfb_info
*cfb
)
110 cyber2000fb_writew((reg
& 255) | val
<< 8, 0x3d4, cfb
);
114 cyber2000_grphw(unsigned int reg
, unsigned int val
, struct cfb_info
*cfb
)
116 cyber2000fb_writew((reg
& 255) | val
<< 8, 0x3ce, cfb
);
119 static inline unsigned int
120 cyber2000_grphr(unsigned int reg
, struct cfb_info
*cfb
)
122 cyber2000fb_writeb(reg
, 0x3ce, cfb
);
123 return cyber2000fb_readb(0x3cf, cfb
);
127 cyber2000_attrw(unsigned int reg
, unsigned int val
, struct cfb_info
*cfb
)
129 cyber2000fb_readb(0x3da, cfb
);
130 cyber2000fb_writeb(reg
, 0x3c0, cfb
);
131 cyber2000fb_readb(0x3c1, cfb
);
132 cyber2000fb_writeb(val
, 0x3c0, cfb
);
136 cyber2000_seqw(unsigned int reg
, unsigned int val
, struct cfb_info
*cfb
)
138 cyber2000fb_writew((reg
& 255) | val
<< 8, 0x3c4, cfb
);
141 /* -------------------- Hardware specific routines ------------------------- */
144 * Hardware Cyber2000 Acceleration
147 cyber2000fb_fillrect(struct fb_info
*info
, const struct fb_fillrect
*rect
)
149 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
150 unsigned long dst
, col
;
152 if (!(cfb
->fb
.var
.accel_flags
& FB_ACCELF_TEXT
)) {
153 cfb_fillrect(info
, rect
);
157 cyber2000fb_writeb(0, CO_REG_CONTROL
, cfb
);
158 cyber2000fb_writew(rect
->width
- 1, CO_REG_PIXWIDTH
, cfb
);
159 cyber2000fb_writew(rect
->height
- 1, CO_REG_PIXHEIGHT
, cfb
);
162 if (cfb
->fb
.var
.bits_per_pixel
> 8)
163 col
= ((u32
*)cfb
->fb
.pseudo_palette
)[col
];
164 cyber2000fb_writel(col
, CO_REG_FGCOLOUR
, cfb
);
166 dst
= rect
->dx
+ rect
->dy
* cfb
->fb
.var
.xres_virtual
;
167 if (cfb
->fb
.var
.bits_per_pixel
== 24) {
168 cyber2000fb_writeb(dst
, CO_REG_X_PHASE
, cfb
);
172 cyber2000fb_writel(dst
, CO_REG_DEST_PTR
, cfb
);
173 cyber2000fb_writeb(CO_FG_MIX_SRC
, CO_REG_FGMIX
, cfb
);
174 cyber2000fb_writew(CO_CMD_L_PATTERN_FGCOL
, CO_REG_CMD_L
, cfb
);
175 cyber2000fb_writew(CO_CMD_H_BLITTER
, CO_REG_CMD_H
, cfb
);
179 cyber2000fb_copyarea(struct fb_info
*info
, const struct fb_copyarea
*region
)
181 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
182 unsigned int cmd
= CO_CMD_L_PATTERN_FGCOL
;
183 unsigned long src
, dst
;
185 if (!(cfb
->fb
.var
.accel_flags
& FB_ACCELF_TEXT
)) {
186 cfb_copyarea(info
, region
);
190 cyber2000fb_writeb(0, CO_REG_CONTROL
, cfb
);
191 cyber2000fb_writew(region
->width
- 1, CO_REG_PIXWIDTH
, cfb
);
192 cyber2000fb_writew(region
->height
- 1, CO_REG_PIXHEIGHT
, cfb
);
194 src
= region
->sx
+ region
->sy
* cfb
->fb
.var
.xres_virtual
;
195 dst
= region
->dx
+ region
->dy
* cfb
->fb
.var
.xres_virtual
;
197 if (region
->sx
< region
->dx
) {
198 src
+= region
->width
- 1;
199 dst
+= region
->width
- 1;
200 cmd
|= CO_CMD_L_INC_LEFT
;
203 if (region
->sy
< region
->dy
) {
204 src
+= (region
->height
- 1) * cfb
->fb
.var
.xres_virtual
;
205 dst
+= (region
->height
- 1) * cfb
->fb
.var
.xres_virtual
;
206 cmd
|= CO_CMD_L_INC_UP
;
209 if (cfb
->fb
.var
.bits_per_pixel
== 24) {
210 cyber2000fb_writeb(dst
, CO_REG_X_PHASE
, cfb
);
214 cyber2000fb_writel(src
, CO_REG_SRC1_PTR
, cfb
);
215 cyber2000fb_writel(dst
, CO_REG_DEST_PTR
, cfb
);
216 cyber2000fb_writew(CO_FG_MIX_SRC
, CO_REG_FGMIX
, cfb
);
217 cyber2000fb_writew(cmd
, CO_REG_CMD_L
, cfb
);
218 cyber2000fb_writew(CO_CMD_H_FGSRCMAP
| CO_CMD_H_BLITTER
,
223 cyber2000fb_imageblit(struct fb_info
*info
, const struct fb_image
*image
)
225 // struct cfb_info *cfb = (struct cfb_info *)info;
227 // if (!(cfb->fb.var.accel_flags & FB_ACCELF_TEXT)) {
228 cfb_imageblit(info
, image
);
233 static int cyber2000fb_sync(struct fb_info
*info
)
235 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
238 if (!(cfb
->fb
.var
.accel_flags
& FB_ACCELF_TEXT
))
241 while (cyber2000fb_readb(CO_REG_CONTROL
, cfb
) & CO_CTRL_BUSY
) {
243 debug_printf("accel_wait timed out\n");
244 cyber2000fb_writeb(0, CO_REG_CONTROL
, cfb
);
253 * ===========================================================================
256 static inline u32
convert_bitfield(u_int val
, struct fb_bitfield
*bf
)
258 u_int mask
= (1 << bf
->length
) - 1;
260 return (val
>> (16 - bf
->length
) & mask
) << bf
->offset
;
264 * Set a single color register. Return != 0 for invalid regno.
267 cyber2000fb_setcolreg(u_int regno
, u_int red
, u_int green
, u_int blue
,
268 u_int transp
, struct fb_info
*info
)
270 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
271 struct fb_var_screeninfo
*var
= &cfb
->fb
.var
;
275 switch (cfb
->fb
.fix
.visual
) {
282 * pixel --/--+--/--> red lut --> red dac
284 * +--/--> green lut --> green dac
286 * +--/--> blue lut --> blue dac
288 case FB_VISUAL_PSEUDOCOLOR
:
289 if (regno
>= NR_PALETTE
)
296 cfb
->palette
[regno
].red
= red
;
297 cfb
->palette
[regno
].green
= green
;
298 cfb
->palette
[regno
].blue
= blue
;
300 cyber2000fb_writeb(regno
, 0x3c8, cfb
);
301 cyber2000fb_writeb(red
, 0x3c9, cfb
);
302 cyber2000fb_writeb(green
, 0x3c9, cfb
);
303 cyber2000fb_writeb(blue
, 0x3c9, cfb
);
309 * pixel --/--+--/--> red lut --> red dac
311 * +--/--> green lut --> green dac
313 * +--/--> blue lut --> blue dac
314 * n = bpp, rl = red length, gl = green length, bl = blue length
316 case FB_VISUAL_DIRECTCOLOR
:
321 if (var
->green
.length
== 6 && regno
< 64) {
322 cfb
->palette
[regno
<< 2].green
= green
;
325 * The 6 bits of the green component are applied
326 * to the high 6 bits of the LUT.
328 cyber2000fb_writeb(regno
<< 2, 0x3c8, cfb
);
329 cyber2000fb_writeb(cfb
->palette
[regno
>> 1].red
, 0x3c9, cfb
);
330 cyber2000fb_writeb(green
, 0x3c9, cfb
);
331 cyber2000fb_writeb(cfb
->palette
[regno
>> 1].blue
, 0x3c9, cfb
);
333 green
= cfb
->palette
[regno
<< 3].green
;
338 if (var
->green
.length
>= 5 && regno
< 32) {
339 cfb
->palette
[regno
<< 3].red
= red
;
340 cfb
->palette
[regno
<< 3].green
= green
;
341 cfb
->palette
[regno
<< 3].blue
= blue
;
344 * The 5 bits of each colour component are
345 * applied to the high 5 bits of the LUT.
347 cyber2000fb_writeb(regno
<< 3, 0x3c8, cfb
);
348 cyber2000fb_writeb(red
, 0x3c9, cfb
);
349 cyber2000fb_writeb(green
, 0x3c9, cfb
);
350 cyber2000fb_writeb(blue
, 0x3c9, cfb
);
354 if (var
->green
.length
== 4 && regno
< 16) {
355 cfb
->palette
[regno
<< 4].red
= red
;
356 cfb
->palette
[regno
<< 4].green
= green
;
357 cfb
->palette
[regno
<< 4].blue
= blue
;
360 * The 5 bits of each colour component are
361 * applied to the high 5 bits of the LUT.
363 cyber2000fb_writeb(regno
<< 4, 0x3c8, cfb
);
364 cyber2000fb_writeb(red
, 0x3c9, cfb
);
365 cyber2000fb_writeb(green
, 0x3c9, cfb
);
366 cyber2000fb_writeb(blue
, 0x3c9, cfb
);
371 * Since this is only used for the first 16 colours, we
372 * don't have to care about overflowing for regno >= 32
374 pseudo_val
= regno
<< var
->red
.offset
|
375 regno
<< var
->green
.offset
|
376 regno
<< var
->blue
.offset
;
382 * pixel --/--+--/--> red dac
387 * n = bpp, rl = red length, gl = green length, bl = blue length
389 case FB_VISUAL_TRUECOLOR
:
390 pseudo_val
= convert_bitfield(transp
^ 0xffff, &var
->transp
);
391 pseudo_val
|= convert_bitfield(red
, &var
->red
);
392 pseudo_val
|= convert_bitfield(green
, &var
->green
);
393 pseudo_val
|= convert_bitfield(blue
, &var
->blue
);
398 * Now set our pseudo palette for the CFB16/24/32 drivers.
401 ((u32
*)cfb
->fb
.pseudo_palette
)[regno
] = pseudo_val
;
426 static const u_char crtc_idx
[] = {
427 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
429 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18
432 static void cyber2000fb_write_ramdac_ctrl(struct cfb_info
*cfb
)
435 unsigned int val
= cfb
->ramdac_ctrl
| cfb
->ramdac_powerdown
;
437 cyber2000fb_writeb(0x56, 0x3ce, cfb
);
438 i
= cyber2000fb_readb(0x3cf, cfb
);
439 cyber2000fb_writeb(i
| 4, 0x3cf, cfb
);
440 cyber2000fb_writeb(val
, 0x3c6, cfb
);
441 cyber2000fb_writeb(i
, 0x3cf, cfb
);
444 static void cyber2000fb_set_timing(struct cfb_info
*cfb
, struct par_info
*hw
)
451 for (i
= 0; i
< NR_PALETTE
; i
++) {
452 cyber2000fb_writeb(i
, 0x3c8, cfb
);
453 cyber2000fb_writeb(0, 0x3c9, cfb
);
454 cyber2000fb_writeb(0, 0x3c9, cfb
);
455 cyber2000fb_writeb(0, 0x3c9, cfb
);
458 cyber2000fb_writeb(0xef, 0x3c2, cfb
);
459 cyber2000_crtcw(0x11, 0x0b, cfb
);
460 cyber2000_attrw(0x11, 0x00, cfb
);
462 cyber2000_seqw(0x00, 0x01, cfb
);
463 cyber2000_seqw(0x01, 0x01, cfb
);
464 cyber2000_seqw(0x02, 0x0f, cfb
);
465 cyber2000_seqw(0x03, 0x00, cfb
);
466 cyber2000_seqw(0x04, 0x0e, cfb
);
467 cyber2000_seqw(0x00, 0x03, cfb
);
469 for (i
= 0; i
< sizeof(crtc_idx
); i
++)
470 cyber2000_crtcw(crtc_idx
[i
], hw
->crtc
[i
], cfb
);
472 for (i
= 0x0a; i
< 0x10; i
++)
473 cyber2000_crtcw(i
, 0, cfb
);
475 cyber2000_grphw(EXT_CRT_VRTOFL
, hw
->crtc_ofl
, cfb
);
476 cyber2000_grphw(0x00, 0x00, cfb
);
477 cyber2000_grphw(0x01, 0x00, cfb
);
478 cyber2000_grphw(0x02, 0x00, cfb
);
479 cyber2000_grphw(0x03, 0x00, cfb
);
480 cyber2000_grphw(0x04, 0x00, cfb
);
481 cyber2000_grphw(0x05, 0x60, cfb
);
482 cyber2000_grphw(0x06, 0x05, cfb
);
483 cyber2000_grphw(0x07, 0x0f, cfb
);
484 cyber2000_grphw(0x08, 0xff, cfb
);
486 /* Attribute controller registers */
487 for (i
= 0; i
< 16; i
++)
488 cyber2000_attrw(i
, i
, cfb
);
490 cyber2000_attrw(0x10, 0x01, cfb
);
491 cyber2000_attrw(0x11, 0x00, cfb
);
492 cyber2000_attrw(0x12, 0x0f, cfb
);
493 cyber2000_attrw(0x13, 0x00, cfb
);
494 cyber2000_attrw(0x14, 0x00, cfb
);
497 cyber2000_grphw(EXT_DCLK_MULT
, hw
->clock_mult
, cfb
);
498 cyber2000_grphw(EXT_DCLK_DIV
, hw
->clock_div
, cfb
);
499 cyber2000_grphw(EXT_MCLK_MULT
, cfb
->mclk_mult
, cfb
);
500 cyber2000_grphw(EXT_MCLK_DIV
, cfb
->mclk_div
, cfb
);
501 cyber2000_grphw(0x90, 0x01, cfb
);
502 cyber2000_grphw(0xb9, 0x80, cfb
);
503 cyber2000_grphw(0xb9, 0x00, cfb
);
505 cfb
->ramdac_ctrl
= hw
->ramdac
;
506 cyber2000fb_write_ramdac_ctrl(cfb
);
508 cyber2000fb_writeb(0x20, 0x3c0, cfb
);
509 cyber2000fb_writeb(0xff, 0x3c6, cfb
);
511 cyber2000_grphw(0x14, hw
->fetch
, cfb
);
512 cyber2000_grphw(0x15, ((hw
->fetch
>> 8) & 0x03) |
513 ((hw
->pitch
>> 4) & 0x30), cfb
);
514 cyber2000_grphw(EXT_SEQ_MISC
, hw
->extseqmisc
, cfb
);
517 * Set up accelerator registers
519 cyber2000fb_writew(hw
->width
, CO_REG_SRC_WIDTH
, cfb
);
520 cyber2000fb_writew(hw
->width
, CO_REG_DEST_WIDTH
, cfb
);
521 cyber2000fb_writeb(hw
->co_pixfmt
, CO_REG_PIXFMT
, cfb
);
525 cyber2000fb_update_start(struct cfb_info
*cfb
, struct fb_var_screeninfo
*var
)
527 u_int base
= var
->yoffset
* var
->xres_virtual
+ var
->xoffset
;
529 base
*= var
->bits_per_pixel
;
532 * Convert to bytes and shift two extra bits because DAC
533 * can only start on 4 byte aligned data.
540 cyber2000_grphw(0x10, base
>> 16 | 0x10, cfb
);
541 cyber2000_crtcw(0x0c, base
>> 8, cfb
);
542 cyber2000_crtcw(0x0d, base
, cfb
);
548 cyber2000fb_decode_crtc(struct par_info
*hw
, struct cfb_info
*cfb
,
549 struct fb_var_screeninfo
*var
)
551 u_int Htotal
, Hblankend
, Hsyncend
;
552 u_int Vtotal
, Vdispend
, Vblankstart
, Vblankend
, Vsyncstart
, Vsyncend
;
553 #define BIT(v,b1,m,b2) (((v >> b1) & m) << b2)
555 hw
->crtc
[13] = hw
->pitch
;
560 Htotal
= var
->xres
+ var
->right_margin
+
561 var
->hsync_len
+ var
->left_margin
;
566 hw
->crtc
[0] = (Htotal
>> 3) - 5;
567 hw
->crtc
[1] = (var
->xres
>> 3) - 1;
568 hw
->crtc
[2] = var
->xres
>> 3;
569 hw
->crtc
[4] = (var
->xres
+ var
->right_margin
) >> 3;
571 Hblankend
= (Htotal
- 4*8) >> 3;
573 hw
->crtc
[3] = BIT(Hblankend
, 0, 0x1f, 0) |
576 Hsyncend
= (var
->xres
+ var
->right_margin
+ var
->hsync_len
) >> 3;
578 hw
->crtc
[5] = BIT(Hsyncend
, 0, 0x1f, 0) |
579 BIT(Hblankend
, 5, 0x01, 7);
581 Vdispend
= var
->yres
- 1;
582 Vsyncstart
= var
->yres
+ var
->lower_margin
;
583 Vsyncend
= var
->yres
+ var
->lower_margin
+ var
->vsync_len
;
584 Vtotal
= var
->yres
+ var
->lower_margin
+ var
->vsync_len
+
585 var
->upper_margin
- 2;
590 Vblankstart
= var
->yres
+ 6;
591 Vblankend
= Vtotal
- 10;
593 hw
->crtc
[6] = Vtotal
;
594 hw
->crtc
[7] = BIT(Vtotal
, 8, 0x01, 0) |
595 BIT(Vdispend
, 8, 0x01, 1) |
596 BIT(Vsyncstart
, 8, 0x01, 2) |
597 BIT(Vblankstart
,8, 0x01, 3) |
599 BIT(Vtotal
, 9, 0x01, 5) |
600 BIT(Vdispend
, 9, 0x01, 6) |
601 BIT(Vsyncstart
, 9, 0x01, 7);
602 hw
->crtc
[9] = BIT(0, 0, 0x1f, 0) |
603 BIT(Vblankstart
,9, 0x01, 5) |
605 hw
->crtc
[10] = Vsyncstart
;
606 hw
->crtc
[11] = BIT(Vsyncend
, 0, 0x0f, 0) |
608 hw
->crtc
[12] = Vdispend
;
609 hw
->crtc
[15] = Vblankstart
;
610 hw
->crtc
[16] = Vblankend
;
614 * overflow - graphics reg 0x11
615 * 0=VTOTAL:10 1=VDEND:10 2=VRSTART:10 3=VBSTART:10
616 * 4=LINECOMP:10 5-IVIDEO 6=FIXCNT
619 BIT(Vtotal
, 10, 0x01, 0) |
620 BIT(Vdispend
, 10, 0x01, 1) |
621 BIT(Vsyncstart
, 10, 0x01, 2) |
622 BIT(Vblankstart
,10, 0x01, 3) |
623 EXT_CRT_VRTOFL_LINECOMP10
;
625 /* woody: set the interlaced bit... */
626 /* FIXME: what about doublescan? */
627 if ((var
->vmode
& FB_VMODE_MASK
) == FB_VMODE_INTERLACED
)
628 hw
->crtc_ofl
|= EXT_CRT_VRTOFL_INTERLACE
;
634 * The following was discovered by a good monitor, bit twiddling, theorising
635 * and but mostly luck. Strangely, it looks like everyone elses' PLL!
638 * fclock = fpll / div2
639 * fpll = fref * mult / div1
641 * fref = 14.318MHz (69842ps)
643 * div1 = (reg0xb1.5:0 + 1)
644 * div2 = 2^(reg0xb1.7:6)
645 * fpll should be between 115 and 260 MHz
646 * (8696ps and 3846ps)
649 cyber2000fb_decode_clock(struct par_info
*hw
, struct cfb_info
*cfb
,
650 struct fb_var_screeninfo
*var
)
652 u_long pll_ps
= var
->pixclock
;
653 const u_long ref_ps
= cfb
->ref_ps
;
654 u_int div2
, t_div1
, best_div1
, best_mult
;
660 * find div2 such that 115MHz < fpll < 260MHz
663 for (div2
= 0; div2
< 4; div2
++) {
666 new_pll
= pll_ps
/ cfb
->divisors
[div2
];
667 if (8696 > new_pll
&& new_pll
> 3846) {
678 * Given pll_ps and ref_ps, find:
679 * pll_ps * 0.995 < pll_ps_calc < pll_ps * 1.005
680 * where { 1 < best_div1 < 32, 1 < best_mult < 256 }
681 * pll_ps_calc = best_div1 / (ref_ps * best_mult)
683 best_diff
= 0x7fffffff;
686 for (t_div1
= 32; t_div1
> 1; t_div1
-= 1) {
687 u_int rr
, t_mult
, t_pll_ps
;
691 * Find the multiplier for this divisor
693 rr
= ref_ps
* t_div1
;
694 t_mult
= (rr
+ pll_ps
/ 2) / pll_ps
;
697 * Is the multiplier within the correct range?
699 if (t_mult
> 256 || t_mult
< 2)
703 * Calculate the actual clock period from this multiplier
704 * and divisor, and estimate the error.
706 t_pll_ps
= (rr
+ t_mult
/ 2) / t_mult
;
707 diff
= pll_ps
- t_pll_ps
;
711 if (diff
< best_diff
) {
718 * If we hit an exact value, there is no point in continuing.
728 hw
->clock_mult
= best_mult
- 1;
729 hw
->clock_div
= div2
<< 6 | (best_div1
- 1);
731 vco
= ref_ps
* best_div1
/ best_mult
;
732 if ((ref_ps
== 40690) && (vco
< 5556))
733 /* Set VFSEL when VCO > 180MHz (5.556 ps). */
734 hw
->clock_div
|= EXT_DCLK_DIV_VFSEL
;
740 * Set the User Defined Part of the Display
743 cyber2000fb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
745 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
750 var
->transp
.msb_right
= 0;
751 var
->red
.msb_right
= 0;
752 var
->green
.msb_right
= 0;
753 var
->blue
.msb_right
= 0;
755 switch (var
->bits_per_pixel
) {
756 case 8: /* PSEUDOCOLOUR, 256 */
757 var
->transp
.offset
= 0;
758 var
->transp
.length
= 0;
761 var
->green
.offset
= 0;
762 var
->green
.length
= 8;
763 var
->blue
.offset
= 0;
764 var
->blue
.length
= 8;
767 case 16:/* DIRECTCOLOUR, 64k or 32k */
768 switch (var
->green
.length
) {
769 case 6: /* RGB565, 64k */
770 var
->transp
.offset
= 0;
771 var
->transp
.length
= 0;
772 var
->red
.offset
= 11;
774 var
->green
.offset
= 5;
775 var
->green
.length
= 6;
776 var
->blue
.offset
= 0;
777 var
->blue
.length
= 5;
781 case 5: /* RGB555, 32k */
782 var
->transp
.offset
= 0;
783 var
->transp
.length
= 0;
784 var
->red
.offset
= 10;
786 var
->green
.offset
= 5;
787 var
->green
.length
= 5;
788 var
->blue
.offset
= 0;
789 var
->blue
.length
= 5;
792 case 4: /* RGB444, 4k + transparency? */
793 var
->transp
.offset
= 12;
794 var
->transp
.length
= 4;
797 var
->green
.offset
= 4;
798 var
->green
.length
= 4;
799 var
->blue
.offset
= 0;
800 var
->blue
.length
= 4;
805 case 24:/* TRUECOLOUR, 16m */
806 var
->transp
.offset
= 0;
807 var
->transp
.length
= 0;
808 var
->red
.offset
= 16;
810 var
->green
.offset
= 8;
811 var
->green
.length
= 8;
812 var
->blue
.offset
= 0;
813 var
->blue
.length
= 8;
816 case 32:/* TRUECOLOUR, 16m */
817 var
->transp
.offset
= 24;
818 var
->transp
.length
= 8;
819 var
->red
.offset
= 16;
821 var
->green
.offset
= 8;
822 var
->green
.length
= 8;
823 var
->blue
.offset
= 0;
824 var
->blue
.length
= 8;
831 mem
= var
->xres_virtual
* var
->yres_virtual
* (var
->bits_per_pixel
/ 8);
832 if (mem
> cfb
->fb
.fix
.smem_len
)
833 var
->yres_virtual
= cfb
->fb
.fix
.smem_len
* 8 /
834 (var
->bits_per_pixel
* var
->xres_virtual
);
836 if (var
->yres
> var
->yres_virtual
)
837 var
->yres
= var
->yres_virtual
;
838 if (var
->xres
> var
->xres_virtual
)
839 var
->xres
= var
->xres_virtual
;
841 err
= cyber2000fb_decode_clock(&hw
, cfb
, var
);
845 err
= cyber2000fb_decode_crtc(&hw
, cfb
, var
);
852 static int cyber2000fb_set_par(struct fb_info
*info
)
854 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
855 struct fb_var_screeninfo
*var
= &cfb
->fb
.var
;
859 hw
.width
= var
->xres_virtual
;
860 hw
.ramdac
= RAMDAC_VREFEN
| RAMDAC_DAC8BIT
;
862 switch (var
->bits_per_pixel
) {
864 hw
.co_pixfmt
= CO_PIXFMT_8BPP
;
865 hw
.pitch
= hw
.width
>> 3;
866 hw
.extseqmisc
= EXT_SEQ_MISC_8
;
870 hw
.co_pixfmt
= CO_PIXFMT_16BPP
;
871 hw
.pitch
= hw
.width
>> 2;
873 switch (var
->green
.length
) {
874 case 6: /* RGB565, 64k */
875 hw
.extseqmisc
= EXT_SEQ_MISC_16_RGB565
;
877 case 5: /* RGB555, 32k */
878 hw
.extseqmisc
= EXT_SEQ_MISC_16_RGB555
;
880 case 4: /* RGB444, 4k + transparency? */
881 hw
.extseqmisc
= EXT_SEQ_MISC_16_RGB444
;
886 case 24:/* TRUECOLOUR, 16m */
887 hw
.co_pixfmt
= CO_PIXFMT_24BPP
;
889 hw
.pitch
= hw
.width
>> 3;
890 hw
.ramdac
|= (RAMDAC_BYPASS
| RAMDAC_RAMPWRDN
);
891 hw
.extseqmisc
= EXT_SEQ_MISC_24_RGB888
;
894 case 32:/* TRUECOLOUR, 16m */
895 hw
.co_pixfmt
= CO_PIXFMT_32BPP
;
896 hw
.pitch
= hw
.width
>> 1;
897 hw
.ramdac
|= (RAMDAC_BYPASS
| RAMDAC_RAMPWRDN
);
898 hw
.extseqmisc
= EXT_SEQ_MISC_32
;
906 * Sigh, this is absolutely disgusting, but caused by
907 * the way the fbcon developers want to separate out
908 * the "checking" and the "setting" of the video mode.
910 * If the mode is not suitable for the hardware here,
911 * we can't prevent it being set by returning an error.
913 * In theory, since NetWinders contain just one VGA card,
914 * we should never end up hitting this problem.
916 BUG_ON(cyber2000fb_decode_clock(&hw
, cfb
, var
) != 0);
917 BUG_ON(cyber2000fb_decode_crtc(&hw
, cfb
, var
) != 0);
921 if (!(cfb
->mem_ctl2
& MEM_CTL2_64BIT
))
925 cfb
->fb
.fix
.line_length
= var
->xres_virtual
* var
->bits_per_pixel
/ 8;
928 * Same here - if the size of the video mode exceeds the
929 * available RAM, we can't prevent this mode being set.
931 * In theory, since NetWinders contain just one VGA card,
932 * we should never end up hitting this problem.
934 mem
= cfb
->fb
.fix
.line_length
* var
->yres_virtual
;
935 BUG_ON(mem
> cfb
->fb
.fix
.smem_len
);
938 * 8bpp displays are always pseudo colour. 16bpp and above
939 * are direct colour or true colour, depending on whether
940 * the RAMDAC palettes are bypassed. (Direct colour has
941 * palettes, true colour does not.)
943 if (var
->bits_per_pixel
== 8)
944 cfb
->fb
.fix
.visual
= FB_VISUAL_PSEUDOCOLOR
;
945 else if (hw
.ramdac
& RAMDAC_BYPASS
)
946 cfb
->fb
.fix
.visual
= FB_VISUAL_TRUECOLOR
;
948 cfb
->fb
.fix
.visual
= FB_VISUAL_DIRECTCOLOR
;
950 cyber2000fb_set_timing(cfb
, &hw
);
951 cyber2000fb_update_start(cfb
, var
);
958 * Pan or Wrap the Display
961 cyber2000fb_pan_display(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
963 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
965 if (cyber2000fb_update_start(cfb
, var
))
968 cfb
->fb
.var
.xoffset
= var
->xoffset
;
969 cfb
->fb
.var
.yoffset
= var
->yoffset
;
971 if (var
->vmode
& FB_VMODE_YWRAP
) {
972 cfb
->fb
.var
.vmode
|= FB_VMODE_YWRAP
;
974 cfb
->fb
.var
.vmode
&= ~FB_VMODE_YWRAP
;
981 * (Un)Blank the display.
983 * Blank the screen if blank_mode != 0, else unblank. If
984 * blank == NULL then the caller blanks by setting the CLUT
985 * (Color Look Up Table) to all black. Return 0 if blanking
986 * succeeded, != 0 if un-/blanking failed due to e.g. a
987 * video mode which doesn't support it. Implements VESA
988 * suspend and powerdown modes on hardware that supports
989 * disabling hsync/vsync:
990 * blank_mode == 2: suspend vsync
991 * blank_mode == 3: suspend hsync
992 * blank_mode == 4: powerdown
994 * wms...Enable VESA DMPS compatible powerdown mode
995 * run "setterm -powersave powerdown" to take advantage
997 static int cyber2000fb_blank(int blank
, struct fb_info
*info
)
999 struct cfb_info
*cfb
= (struct cfb_info
*)info
;
1000 unsigned int sync
= 0;
1004 case FB_BLANK_POWERDOWN
: /* powerdown - both sync lines down */
1005 sync
= EXT_SYNC_CTL_VS_0
| EXT_SYNC_CTL_HS_0
;
1007 case FB_BLANK_HSYNC_SUSPEND
: /* hsync off */
1008 sync
= EXT_SYNC_CTL_VS_NORMAL
| EXT_SYNC_CTL_HS_0
;
1010 case FB_BLANK_VSYNC_SUSPEND
: /* vsync off */
1011 sync
= EXT_SYNC_CTL_VS_0
| EXT_SYNC_CTL_HS_NORMAL
;
1013 case FB_BLANK_NORMAL
: /* soft blank */
1014 default: /* unblank */
1018 cyber2000_grphw(EXT_SYNC_CTL
, sync
, cfb
);
1021 /* turn on ramdacs */
1022 cfb
->ramdac_powerdown
&= ~(RAMDAC_DACPWRDN
| RAMDAC_BYPASS
| RAMDAC_RAMPWRDN
);
1023 cyber2000fb_write_ramdac_ctrl(cfb
);
1027 * Soft blank/unblank the display.
1029 if (blank
) { /* soft blank */
1030 for (i
= 0; i
< NR_PALETTE
; i
++) {
1031 cyber2000fb_writeb(i
, 0x3c8, cfb
);
1032 cyber2000fb_writeb(0, 0x3c9, cfb
);
1033 cyber2000fb_writeb(0, 0x3c9, cfb
);
1034 cyber2000fb_writeb(0, 0x3c9, cfb
);
1036 } else { /* unblank */
1037 for (i
= 0; i
< NR_PALETTE
; i
++) {
1038 cyber2000fb_writeb(i
, 0x3c8, cfb
);
1039 cyber2000fb_writeb(cfb
->palette
[i
].red
, 0x3c9, cfb
);
1040 cyber2000fb_writeb(cfb
->palette
[i
].green
, 0x3c9, cfb
);
1041 cyber2000fb_writeb(cfb
->palette
[i
].blue
, 0x3c9, cfb
);
1046 /* turn off ramdacs */
1047 cfb
->ramdac_powerdown
|= RAMDAC_DACPWRDN
| RAMDAC_BYPASS
| RAMDAC_RAMPWRDN
;
1048 cyber2000fb_write_ramdac_ctrl(cfb
);
1054 static struct fb_ops cyber2000fb_ops
= {
1055 .owner
= THIS_MODULE
,
1056 .fb_check_var
= cyber2000fb_check_var
,
1057 .fb_set_par
= cyber2000fb_set_par
,
1058 .fb_setcolreg
= cyber2000fb_setcolreg
,
1059 .fb_blank
= cyber2000fb_blank
,
1060 .fb_pan_display
= cyber2000fb_pan_display
,
1061 .fb_fillrect
= cyber2000fb_fillrect
,
1062 .fb_copyarea
= cyber2000fb_copyarea
,
1063 .fb_imageblit
= cyber2000fb_imageblit
,
1064 .fb_sync
= cyber2000fb_sync
,
1068 * This is the only "static" reference to the internal data structures
1069 * of this driver. It is here solely at the moment to support the other
1070 * CyberPro modules external to this driver.
1072 static struct cfb_info
*int_cfb_info
;
1075 * Enable access to the extended registers
1077 void cyber2000fb_enable_extregs(struct cfb_info
*cfb
)
1079 cfb
->func_use_count
+= 1;
1081 if (cfb
->func_use_count
== 1) {
1084 old
= cyber2000_grphr(EXT_FUNC_CTL
, cfb
);
1085 old
|= EXT_FUNC_CTL_EXTREGENBL
;
1086 cyber2000_grphw(EXT_FUNC_CTL
, old
, cfb
);
1091 * Disable access to the extended registers
1093 void cyber2000fb_disable_extregs(struct cfb_info
*cfb
)
1095 if (cfb
->func_use_count
== 1) {
1098 old
= cyber2000_grphr(EXT_FUNC_CTL
, cfb
);
1099 old
&= ~EXT_FUNC_CTL_EXTREGENBL
;
1100 cyber2000_grphw(EXT_FUNC_CTL
, old
, cfb
);
1103 if (cfb
->func_use_count
== 0)
1104 printk(KERN_ERR
"disable_extregs: count = 0\n");
1106 cfb
->func_use_count
-= 1;
1109 void cyber2000fb_get_fb_var(struct cfb_info
*cfb
, struct fb_var_screeninfo
*var
)
1111 memcpy(var
, &cfb
->fb
.var
, sizeof(struct fb_var_screeninfo
));
1115 * Attach a capture/tv driver to the core CyberX0X0 driver.
1117 int cyber2000fb_attach(struct cyberpro_info
*info
, int idx
)
1119 if (int_cfb_info
!= NULL
) {
1120 info
->dev
= int_cfb_info
->dev
;
1121 info
->regs
= int_cfb_info
->regs
;
1122 info
->fb
= int_cfb_info
->fb
.screen_base
;
1123 info
->fb_size
= int_cfb_info
->fb
.fix
.smem_len
;
1124 info
->enable_extregs
= cyber2000fb_enable_extregs
;
1125 info
->disable_extregs
= cyber2000fb_disable_extregs
;
1126 info
->info
= int_cfb_info
;
1128 strlcpy(info
->dev_name
, int_cfb_info
->fb
.fix
.id
, sizeof(info
->dev_name
));
1131 return int_cfb_info
!= NULL
;
1135 * Detach a capture/tv driver from the core CyberX0X0 driver.
1137 void cyber2000fb_detach(int idx
)
1141 EXPORT_SYMBOL(cyber2000fb_attach
);
1142 EXPORT_SYMBOL(cyber2000fb_detach
);
1143 EXPORT_SYMBOL(cyber2000fb_enable_extregs
);
1144 EXPORT_SYMBOL(cyber2000fb_disable_extregs
);
1145 EXPORT_SYMBOL(cyber2000fb_get_fb_var
);
1148 * These parameters give
1149 * 640x480, hsync 31.5kHz, vsync 60Hz
1151 static struct fb_videomode __devinitdata cyber2000fb_default_mode
= {
1162 .sync
= FB_SYNC_COMP_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
1163 .vmode
= FB_VMODE_NONINTERLACED
1166 static char igs_regs
[] = {
1170 EXT_SEG_WRITE_PTR
, 0,
1171 EXT_SEG_READ_PTR
, 0,
1172 EXT_BIU_MISC
, EXT_BIU_MISC_LIN_ENABLE
|
1173 EXT_BIU_MISC_COP_ENABLE
|
1174 EXT_BIU_MISC_COP_BFC
,
1177 CURS_H_START
+ 1, 0,
1180 CURS_V_START
+ 1, 0,
1183 EXT_ATTRIB_CTL
, EXT_ATTRIB_CTL_EXT
,
1184 EXT_OVERSCAN_RED
, 0,
1185 EXT_OVERSCAN_GREEN
, 0,
1186 EXT_OVERSCAN_BLUE
, 0,
1188 /* some of these are questionable when we have a BIOS */
1189 EXT_MEM_CTL0
, EXT_MEM_CTL0_7CLK
|
1190 EXT_MEM_CTL0_RAS_1
|
1191 EXT_MEM_CTL0_MULTCAS
,
1192 EXT_HIDDEN_CTL1
, 0x30,
1194 EXT_FIFO_CTL
+ 1, 0x17,
1196 EXT_HIDDEN_CTL4
, 0xc8
1200 * Initialise the CyberPro hardware. On the CyberPro5XXXX,
1201 * ensure that we're using the correct PLL (5XXX's may be
1202 * programmed to use an additional set of PLLs.)
1204 static void cyberpro_init_hw(struct cfb_info
*cfb
)
1208 for (i
= 0; i
< sizeof(igs_regs
); i
+= 2)
1209 cyber2000_grphw(igs_regs
[i
], igs_regs
[i
+1], cfb
);
1211 if (cfb
->id
== ID_CYBERPRO_5000
) {
1213 cyber2000fb_writeb(0xba, 0x3ce, cfb
);
1214 val
= cyber2000fb_readb(0x3cf, cfb
) & 0x80;
1215 cyber2000fb_writeb(val
, 0x3cf, cfb
);
1219 static struct cfb_info
* __devinit
1220 cyberpro_alloc_fb_info(unsigned int id
, char *name
)
1222 struct cfb_info
*cfb
;
1224 cfb
= kmalloc(sizeof(struct cfb_info
), GFP_KERNEL
);
1228 memset(cfb
, 0, sizeof(struct cfb_info
));
1232 if (id
== ID_CYBERPRO_5000
)
1233 cfb
->ref_ps
= 40690; // 24.576 MHz
1235 cfb
->ref_ps
= 69842; // 14.31818 MHz (69841?)
1237 cfb
->divisors
[0] = 1;
1238 cfb
->divisors
[1] = 2;
1239 cfb
->divisors
[2] = 4;
1241 if (id
== ID_CYBERPRO_2000
)
1242 cfb
->divisors
[3] = 8;
1244 cfb
->divisors
[3] = 6;
1246 strcpy(cfb
->fb
.fix
.id
, name
);
1248 cfb
->fb
.fix
.type
= FB_TYPE_PACKED_PIXELS
;
1249 cfb
->fb
.fix
.type_aux
= 0;
1250 cfb
->fb
.fix
.xpanstep
= 0;
1251 cfb
->fb
.fix
.ypanstep
= 1;
1252 cfb
->fb
.fix
.ywrapstep
= 0;
1256 cfb
->fb
.fix
.accel
= 0;
1259 case ID_CYBERPRO_2000
:
1260 cfb
->fb
.fix
.accel
= FB_ACCEL_IGS_CYBER2000
;
1263 case ID_CYBERPRO_2010
:
1264 cfb
->fb
.fix
.accel
= FB_ACCEL_IGS_CYBER2010
;
1267 case ID_CYBERPRO_5000
:
1268 cfb
->fb
.fix
.accel
= FB_ACCEL_IGS_CYBER5000
;
1272 cfb
->fb
.var
.nonstd
= 0;
1273 cfb
->fb
.var
.activate
= FB_ACTIVATE_NOW
;
1274 cfb
->fb
.var
.height
= -1;
1275 cfb
->fb
.var
.width
= -1;
1276 cfb
->fb
.var
.accel_flags
= FB_ACCELF_TEXT
;
1278 cfb
->fb
.fbops
= &cyber2000fb_ops
;
1279 cfb
->fb
.flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1280 cfb
->fb
.pseudo_palette
= cfb
->pseudo_palette
;
1282 fb_alloc_cmap(&cfb
->fb
.cmap
, NR_PALETTE
, 0);
1288 cyberpro_free_fb_info(struct cfb_info
*cfb
)
1292 * Free the colourmap
1294 fb_alloc_cmap(&cfb
->fb
.cmap
, 0, 0);
1301 * Parse Cyber2000fb options. Usage:
1302 * video=cyber2000:font:fontname
1306 cyber2000fb_setup(char *options
)
1310 if (!options
|| !*options
)
1313 while ((opt
= strsep(&options
, ",")) != NULL
) {
1317 if (strncmp(opt
, "font:", 5) == 0) {
1318 static char default_font_storage
[40];
1320 strlcpy(default_font_storage
, opt
+ 5, sizeof(default_font_storage
));
1321 default_font
= default_font_storage
;
1325 printk(KERN_ERR
"CyberPro20x0: unknown parameter: %s\n", opt
);
1332 * The CyberPro chips can be placed on many different bus types.
1333 * This probe function is common to all bus types. The bus-specific
1334 * probe function is expected to have:
1335 * - enabled access to the linear memory region
1336 * - memory mapped access to the registers
1337 * - initialised mem_ctl1 and mem_ctl2 appropriately.
1339 static int __devinit
cyberpro_common_probe(struct cfb_info
*cfb
)
1342 u_int h_sync
, v_sync
;
1345 cyberpro_init_hw(cfb
);
1348 * Get the video RAM size and width from the VGA register.
1349 * This should have been already initialised by the BIOS,
1350 * but if it's garbage, claim default 1MB VRAM (woody)
1352 cfb
->mem_ctl1
= cyber2000_grphr(EXT_MEM_CTL1
, cfb
);
1353 cfb
->mem_ctl2
= cyber2000_grphr(EXT_MEM_CTL2
, cfb
);
1356 * Determine the size of the memory.
1358 switch (cfb
->mem_ctl2
& MEM_CTL2_SIZE_MASK
) {
1359 case MEM_CTL2_SIZE_4MB
: smem_size
= 0x00400000; break;
1360 case MEM_CTL2_SIZE_2MB
: smem_size
= 0x00200000; break;
1361 case MEM_CTL2_SIZE_1MB
: smem_size
= 0x00100000; break;
1362 default: smem_size
= 0x00100000; break;
1365 cfb
->fb
.fix
.smem_len
= smem_size
;
1366 cfb
->fb
.fix
.mmio_len
= MMIO_SIZE
;
1367 cfb
->fb
.screen_base
= cfb
->region
;
1370 if (!fb_find_mode(&cfb
->fb
.var
, &cfb
->fb
, NULL
, NULL
, 0,
1371 &cyber2000fb_default_mode
, 8)) {
1372 printk("%s: no valid mode found\n", cfb
->fb
.fix
.id
);
1376 cfb
->fb
.var
.yres_virtual
= cfb
->fb
.fix
.smem_len
* 8 /
1377 (cfb
->fb
.var
.bits_per_pixel
* cfb
->fb
.var
.xres_virtual
);
1379 if (cfb
->fb
.var
.yres_virtual
< cfb
->fb
.var
.yres
)
1380 cfb
->fb
.var
.yres_virtual
= cfb
->fb
.var
.yres
;
1382 // fb_set_var(&cfb->fb.var, -1, &cfb->fb);
1385 * Calculate the hsync and vsync frequencies. Note that
1386 * we split the 1e12 constant up so that we can preserve
1387 * the precision and fit the results into 32-bit registers.
1388 * (1953125000 * 512 = 1e12)
1390 h_sync
= 1953125000 / cfb
->fb
.var
.pixclock
;
1391 h_sync
= h_sync
* 512 / (cfb
->fb
.var
.xres
+ cfb
->fb
.var
.left_margin
+
1392 cfb
->fb
.var
.right_margin
+ cfb
->fb
.var
.hsync_len
);
1393 v_sync
= h_sync
/ (cfb
->fb
.var
.yres
+ cfb
->fb
.var
.upper_margin
+
1394 cfb
->fb
.var
.lower_margin
+ cfb
->fb
.var
.vsync_len
);
1396 printk(KERN_INFO
"%s: %dKiB VRAM, using %dx%d, %d.%03dkHz, %dHz\n",
1397 cfb
->fb
.fix
.id
, cfb
->fb
.fix
.smem_len
>> 10,
1398 cfb
->fb
.var
.xres
, cfb
->fb
.var
.yres
,
1399 h_sync
/ 1000, h_sync
% 1000, v_sync
);
1402 cfb
->fb
.device
= &cfb
->dev
->dev
;
1403 err
= register_framebuffer(&cfb
->fb
);
1409 static void cyberpro_common_resume(struct cfb_info
*cfb
)
1411 cyberpro_init_hw(cfb
);
1414 * Reprogram the MEM_CTL1 and MEM_CTL2 registers
1416 cyber2000_grphw(EXT_MEM_CTL1
, cfb
->mem_ctl1
, cfb
);
1417 cyber2000_grphw(EXT_MEM_CTL2
, cfb
->mem_ctl2
, cfb
);
1420 * Restore the old video mode and the palette.
1421 * We also need to tell fbcon to redraw the console.
1423 cyber2000fb_set_par(&cfb
->fb
);
1426 #ifdef CONFIG_ARCH_SHARK
1428 #include <asm/arch/hardware.h>
1430 static int __devinit
1431 cyberpro_vl_probe(void)
1433 struct cfb_info
*cfb
;
1436 if (!request_mem_region(FB_START
,FB_SIZE
,"CyberPro2010")) return err
;
1438 cfb
= cyberpro_alloc_fb_info(ID_CYBERPRO_2010
, "CyberPro2010");
1440 goto failed_release
;
1443 cfb
->region
= ioremap(FB_START
,FB_SIZE
);
1445 goto failed_ioremap
;
1447 cfb
->regs
= cfb
->region
+ MMIO_OFFSET
;
1448 cfb
->fb
.fix
.mmio_start
= FB_START
+ MMIO_OFFSET
;
1449 cfb
->fb
.fix
.smem_start
= FB_START
;
1452 * Bring up the hardware. This is expected to enable access
1453 * to the linear memory region, and allow access to the memory
1454 * mapped registers. Also, mem_ctl1 and mem_ctl2 must be
1457 cyber2000fb_writeb(0x18, 0x46e8, cfb
);
1458 cyber2000fb_writeb(0x01, 0x102, cfb
);
1459 cyber2000fb_writeb(0x08, 0x46e8, cfb
);
1460 cyber2000fb_writeb(EXT_BIU_MISC
, 0x3ce, cfb
);
1461 cyber2000fb_writeb(EXT_BIU_MISC_LIN_ENABLE
, 0x3cf, cfb
);
1463 cfb
->mclk_mult
= 0xdb;
1464 cfb
->mclk_div
= 0x54;
1466 err
= cyberpro_common_probe(cfb
);
1470 if (int_cfb_info
== NULL
)
1476 iounmap(cfb
->region
);
1478 cyberpro_free_fb_info(cfb
);
1480 release_mem_region(FB_START
,FB_SIZE
);
1484 #endif /* CONFIG_ARCH_SHARK */
1487 * PCI specific support.
1491 * We need to wake up the CyberPro, and make sure its in linear memory
1492 * mode. Unfortunately, this is specific to the platform and card that
1493 * we are running on.
1495 * On x86 and ARM, should we be initialising the CyberPro first via the
1496 * IO registers, and then the MMIO registers to catch all cases? Can we
1497 * end up in the situation where the chip is in MMIO mode, but not awake
1500 static int cyberpro_pci_enable_mmio(struct cfb_info
*cfb
)
1504 #if defined(__sparc_v9__)
1505 #error "You lose, consult DaveM."
1506 #elif defined(__sparc__)
1508 * SPARC does not have an "outb" instruction, so we generate
1509 * I/O cycles storing into a reserved memory space at
1510 * physical address 0x3000000
1512 unsigned char __iomem
*iop
;
1514 iop
= ioremap(0x3000000, 0x5000);
1516 prom_printf("iga5000: cannot map I/O\n");
1520 writeb(0x18, iop
+ 0x46e8);
1521 writeb(0x01, iop
+ 0x102);
1522 writeb(0x08, iop
+ 0x46e8);
1523 writeb(EXT_BIU_MISC
, iop
+ 0x3ce);
1524 writeb(EXT_BIU_MISC_LIN_ENABLE
, iop
+ 0x3cf);
1529 * Most other machine types are "normal", so
1530 * we use the standard IO-based wakeup.
1535 outb(EXT_BIU_MISC
, 0x3ce);
1536 outb(EXT_BIU_MISC_LIN_ENABLE
, 0x3cf);
1540 * Allow the CyberPro to accept PCI burst accesses
1542 if (cfb
->id
== ID_CYBERPRO_2010
) {
1543 printk(KERN_INFO
"%s: NOT enabling PCI bursts\n", cfb
->fb
.fix
.id
);
1545 val
= cyber2000_grphr(EXT_BUS_CTL
, cfb
);
1546 if (!(val
& EXT_BUS_CTL_PCIBURST_WRITE
)) {
1547 printk(KERN_INFO
"%s: enabling PCI bursts\n",
1550 val
|= EXT_BUS_CTL_PCIBURST_WRITE
;
1552 if (cfb
->id
== ID_CYBERPRO_5000
)
1553 val
|= EXT_BUS_CTL_PCIBURST_READ
;
1555 cyber2000_grphw(EXT_BUS_CTL
, val
, cfb
);
1562 static int __devinit
1563 cyberpro_pci_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
1565 struct cfb_info
*cfb
;
1569 sprintf(name
, "CyberPro%4X", id
->device
);
1571 err
= pci_enable_device(dev
);
1575 err
= pci_request_regions(dev
, name
);
1580 cfb
= cyberpro_alloc_fb_info(id
->driver_data
, name
);
1582 goto failed_release
;
1585 cfb
->region
= ioremap(pci_resource_start(dev
, 0),
1586 pci_resource_len(dev
, 0));
1588 goto failed_ioremap
;
1590 cfb
->regs
= cfb
->region
+ MMIO_OFFSET
;
1591 cfb
->fb
.fix
.mmio_start
= pci_resource_start(dev
, 0) + MMIO_OFFSET
;
1592 cfb
->fb
.fix
.smem_start
= pci_resource_start(dev
, 0);
1595 * Bring up the hardware. This is expected to enable access
1596 * to the linear memory region, and allow access to the memory
1597 * mapped registers. Also, mem_ctl1 and mem_ctl2 must be
1600 err
= cyberpro_pci_enable_mmio(cfb
);
1605 * Use MCLK from BIOS. FIXME: what about hotplug?
1607 cfb
->mclk_mult
= cyber2000_grphr(EXT_MCLK_MULT
, cfb
);
1608 cfb
->mclk_div
= cyber2000_grphr(EXT_MCLK_DIV
, cfb
);
1612 * MCLK on the NetWinder and the Shark is fixed at 75MHz
1614 if (machine_is_netwinder()) {
1615 cfb
->mclk_mult
= 0xdb;
1616 cfb
->mclk_div
= 0x54;
1620 err
= cyberpro_common_probe(cfb
);
1627 pci_set_drvdata(dev
, cfb
);
1628 if (int_cfb_info
== NULL
)
1634 iounmap(cfb
->region
);
1636 cyberpro_free_fb_info(cfb
);
1638 pci_release_regions(dev
);
1643 static void __devexit
cyberpro_pci_remove(struct pci_dev
*dev
)
1645 struct cfb_info
*cfb
= pci_get_drvdata(dev
);
1649 * If unregister_framebuffer fails, then
1650 * we will be leaving hooks that could cause
1651 * oopsen laying around.
1653 if (unregister_framebuffer(&cfb
->fb
))
1654 printk(KERN_WARNING
"%s: danger Will Robinson, "
1655 "danger danger! Oopsen imminent!\n",
1657 iounmap(cfb
->region
);
1658 cyberpro_free_fb_info(cfb
);
1661 * Ensure that the driver data is no longer
1664 pci_set_drvdata(dev
, NULL
);
1665 if (cfb
== int_cfb_info
)
1666 int_cfb_info
= NULL
;
1668 pci_release_regions(dev
);
1672 static int cyberpro_pci_suspend(struct pci_dev
*dev
, pm_message_t state
)
1678 * Re-initialise the CyberPro hardware
1680 static int cyberpro_pci_resume(struct pci_dev
*dev
)
1682 struct cfb_info
*cfb
= pci_get_drvdata(dev
);
1685 cyberpro_pci_enable_mmio(cfb
);
1686 cyberpro_common_resume(cfb
);
1692 static struct pci_device_id cyberpro_pci_table
[] = {
1694 // { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682,
1695 // PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_IGA_1682 },
1696 { PCI_VENDOR_ID_INTERG
, PCI_DEVICE_ID_INTERG_2000
,
1697 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, ID_CYBERPRO_2000
},
1698 { PCI_VENDOR_ID_INTERG
, PCI_DEVICE_ID_INTERG_2010
,
1699 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, ID_CYBERPRO_2010
},
1700 { PCI_VENDOR_ID_INTERG
, PCI_DEVICE_ID_INTERG_5000
,
1701 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, ID_CYBERPRO_5000
},
1705 MODULE_DEVICE_TABLE(pci
,cyberpro_pci_table
);
1707 static struct pci_driver cyberpro_driver
= {
1709 .probe
= cyberpro_pci_probe
,
1710 .remove
= __devexit_p(cyberpro_pci_remove
),
1711 .suspend
= cyberpro_pci_suspend
,
1712 .resume
= cyberpro_pci_resume
,
1713 .id_table
= cyberpro_pci_table
1718 * I don't think we can use the "module_init" stuff here because
1719 * the fbcon stuff may not be initialised yet. Hence the #ifdef
1720 * around module_init.
1722 * Tony: "module_init" is now required
1724 static int __init
cyber2000fb_init(void)
1729 char *option
= NULL
;
1731 if (fb_get_options("cyber2000fb", &option
))
1733 cyber2000fb_setup(option
);
1736 #ifdef CONFIG_ARCH_SHARK
1737 err
= cyberpro_vl_probe();
1740 __module_get(THIS_MODULE
);
1744 err
= pci_register_driver(&cyberpro_driver
);
1749 return ret
? err
: 0;
1752 static void __exit
cyberpro_exit(void)
1754 pci_unregister_driver(&cyberpro_driver
);
1757 module_init(cyber2000fb_init
);
1758 module_exit(cyberpro_exit
);
1760 MODULE_AUTHOR("Russell King");
1761 MODULE_DESCRIPTION("CyberPro 2000, 2010 and 5000 framebuffer driver");
1762 MODULE_LICENSE("GPL");