2 * linux/drivers/video/maxinefb.c
4 * DECstation 5000/xx onboard framebuffer support ... derived from:
5 * "HP300 Topcat framebuffer support (derived from macfb of all things)
6 * Phil Blundell <philb@gnu.org> 1998", the original code can be
7 * found in the file hpfb.c in the same directory.
9 * DECstation related code Copyright (C) 1999,2000,2001 by
10 * Michael Engel <engel@unix-ag.org> and
11 * Karsten Merker <merker@linuxtag.org>.
12 * This file is subject to the terms and conditions of the GNU General
13 * Public License. See the file COPYING in the main directory of this
14 * archive for more details.
20 * 2001/01/27 removed debugging and testing code, fixed fb_ops
21 * initialization which had caused a crash before,
22 * general cleanup, first official release (KM)
26 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
31 #include <linux/slab.h>
32 #include <linux/delay.h>
33 #include <linux/init.h>
35 #include <video/maxinefb.h>
37 /* bootinfo.h defines the machine type values, needed when checking */
38 /* whether are really running on a maxine, KM */
39 #include <asm/bootinfo.h>
41 static struct fb_info fb_info
;
43 static struct fb_var_screeninfo maxinefb_defined
= {
49 .activate
= FB_ACTIVATE_NOW
,
52 .vmode
= FB_VMODE_NONINTERLACED
,
55 static struct fb_fix_screeninfo maxinefb_fix
= {
57 .smem_len
= (1024*768),
58 .type
= FB_TYPE_PACKED_PIXELS
,
59 .visual
= FB_VISUAL_PSEUDOCOLOR
,
63 /* Handle the funny Inmos RamDAC/video controller ... */
65 void maxinefb_ims332_write_register(int regno
, register unsigned int val
)
67 register unsigned char *regs
= (char *) MAXINEFB_IMS332_ADDRESS
;
70 wptr
= regs
+ 0xa0000 + (regno
<< 4);
71 *((volatile unsigned int *) (regs
)) = (val
>> 8) & 0xff00;
72 *((volatile unsigned short *) (wptr
)) = val
;
75 unsigned int maxinefb_ims332_read_register(int regno
)
77 register unsigned char *regs
= (char *) MAXINEFB_IMS332_ADDRESS
;
79 register unsigned int j
, k
;
81 rptr
= regs
+ 0x80000 + (regno
<< 4);
82 j
= *((volatile unsigned short *) rptr
);
83 k
= *((volatile unsigned short *) regs
);
85 return (j
& 0xffff) | ((k
& 0xff00) << 8);
89 static int maxinefb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
90 unsigned blue
, unsigned transp
, struct fb_info
*info
)
92 /* value to be written into the palette reg. */
93 unsigned long hw_colorvalue
= 0;
95 red
>>= 8; /* The cmap fields are 16 bits */
96 green
>>= 8; /* wide, but the harware colormap */
97 blue
>>= 8; /* registers are only 8 bits wide */
99 hw_colorvalue
= (blue
<< 16) + (green
<< 8) + (red
);
101 maxinefb_ims332_write_register(IMS332_REG_COLOR_PALETTE
+ regno
,
106 static struct fb_ops maxinefb_ops
= {
107 .owner
= THIS_MODULE
,
108 .fb_setcolreg
= maxinefb_setcolreg
,
109 .fb_fillrect
= cfb_fillrect
,
110 .fb_copyarea
= cfb_copyarea
,
111 .fb_imageblit
= cfb_imageblit
,
114 int __init
maxinefb_init(void)
117 unsigned long fb_start
;
120 if (fb_get_options("maxinefb", NULL
))
123 /* Validate we're on the proper machine type */
124 if (mips_machtype
!= MACH_DS5000_XX
) {
128 printk(KERN_INFO
"Maxinefb: Personal DECstation detected\n");
129 printk(KERN_INFO
"Maxinefb: initializing onboard framebuffer\n");
131 /* Framebuffer display memory base address */
132 fb_start
= DS5000_xx_ONBOARD_FBMEM_START
;
135 for (fboff
= fb_start
; fboff
< fb_start
+ 0x1ffff; fboff
++)
136 *(volatile unsigned char *)fboff
= 0x0;
138 maxinefb_fix
.smem_start
= fb_start
;
140 /* erase hardware cursor */
141 for (i
= 0; i
< 512; i
++) {
142 maxinefb_ims332_write_register(IMS332_REG_CURSOR_RAM
+ i
,
146 maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0x0f);
148 maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0xf0);
152 fb_info
.fbops
= &maxinefb_ops
;
153 fb_info
.screen_base
= (char *)maxinefb_fix
.smem_start
;
154 fb_info
.var
= maxinefb_defined
;
155 fb_info
.fix
= maxinefb_fix
;
156 fb_info
.flags
= FBINFO_DEFAULT
;
158 fb_alloc_cmap(&fb_info
.cmap
, 256, 0);
160 if (register_framebuffer(&fb_info
) < 0)
165 static void __exit
maxinefb_exit(void)
167 unregister_framebuffer(&fb_info
);
171 MODULE_LICENSE("GPL");
173 module_init(maxinefb_init
);
174 module_exit(maxinefb_exit
);