1 #include <linux/kernel.h>
2 #include <linux/errno.h>
3 #include <linux/string.h>
6 #include <linux/malloc.h>
7 #include <linux/delay.h>
8 #include <linux/interrupt.h>
10 #include <asm/segment.h>
11 #include <asm/system.h>
13 #include <asm/apollohw.h>
15 #include <linux/module.h>
17 #include <video/fbcon-mfb.h>
20 /* apollo video HW definitions */
23 * Control Registers. IOBASE + $x
25 * Note: these are the Memory/IO BASE definitions for a mono card set to the
28 * Control 3A and 3B serve identical functions except that 3A
29 * deals with control 1 and 3b deals with Color LUT reg.
32 #define AP_IOBASE 0x5d80 /* Base address of 1 plane board. */
33 #define AP_STATUS 0x5d80 /* Status register. Read */
34 #define AP_WRITE_ENABLE 0x5d80 /* Write Enable Register Write */
35 #define AP_DEVICE_ID 0x5d81 /* Device ID Register. Read */
36 #define AP_ROP_1 0x5d82 /* Raster Operation reg. Write Word */
37 #define AP_DIAG_MEM_REQ 0x5d84 /* Diagnostic Memory Request. Write Word */
38 #define AP_CONTROL_0 0x5d88 /* Control Register 0. Read/Write */
39 #define AP_CONTROL_1 0x5d8a /* Control Register 1. Read/Write */
40 #define AP_CONTROL_3A 0x5d8e /* Control Register 3a. Read/Write */
41 #define AP_CONTROL_2 0x5d8c /* Control Register 2. Read/Write */
44 #define FRAME_BUFFER_START 0x0FA0000
45 #define FRAME_BUFFER_LEN 0x40000
48 #define VECTOR_MODE 0x40 /* 010x.xxxx */
49 #define DBLT_MODE 0x80 /* 100x.xxxx */
50 #define NORMAL_MODE 0xE0 /* 111x.xxxx */
51 #define SHIFT_BITS 0x1F /* xxx1.1111 */
52 /* other bits are Shift value */
55 #define AD_BLT 0x80 /* 1xxx.xxxx */
56 #define NORMAL 0x80 /* 1xxx.xxxx */ /* What is happening here ?? */
57 #define INVERSE 0x00 /* 0xxx.xxxx */ /* Clearing this reverses the screen */
58 #define PIX_BLT 0x00 /* 0xxx.xxxx */
60 #define AD_HIBIT 0x40 /* xIxx.xxxx */
62 #define ROP_EN 0x10 /* xxx1.xxxx */
63 #define DST_EQ_SRC 0x00 /* xxx0.xxxx */
64 #define nRESET_SYNC 0x08 /* xxxx.1xxx */
65 #define SYNC_ENAB 0x02 /* xxxx.xx1x */
67 #define BLANK_DISP 0x00 /* xxxx.xxx0 */
68 #define ENAB_DISP 0x01 /* xxxx.xxx1 */
70 #define NORM_CREG1 (nRESET_SYNC | SYNC_ENAB | ENAB_DISP) /* no reset sync */
75 * Following 3 defines are common to 1, 4 and 8 plane.
78 #define S_DATA_1s 0x00 /* 00xx.xxxx */ /* set source to all 1's -- vector drawing */
79 #define S_DATA_PIX 0x40 /* 01xx.xxxx */ /* takes source from ls-bits and replicates over 16 bits */
80 #define S_DATA_PLN 0xC0 /* 11xx.xxxx */ /* normal, each data access =16-bits in
81 one plane of image mem */
84 # define RESET_CREG 0x80 /* 1000.0000 */
86 /* ROP REG - all one nibble */
87 /* ********* NOTE : this is used r0,r1,r2,r3 *********** */
88 #define ROP(r2,r3,r0,r1) ( (U_SHORT)((r0)|((r1)<<4)|((r2)<<8)|((r3)<<12)) )
90 #define SRC_AND_DEST 0x1
91 #define SRC_AND_nDEST 0x2
93 #define nSRC_AND_DEST 0x4
95 #define SRC_XOR_DEST 0x6
96 #define SRC_OR_DEST 0x7
97 #define SRC_NOR_DEST 0x8
98 #define SRC_XNOR_DEST 0x9
100 #define SRC_OR_nDEST 0xB
102 #define nSRC_OR_DEST 0xD
103 #define SRC_NAND_DEST 0xE
106 #define SWAP(A) ((A>>8) | ((A&0xff) <<8))
109 #define outb(a,d) *(char *)(a)=(d)
110 #define outw(a,d) *(unsigned short *)a=d
114 /* frame buffer operations */
116 static int dnfb_open(struct fb_info
*info
, int user
);
117 static int dnfb_release(struct fb_info
*info
, int user
);
118 static int dnfb_get_fix(struct fb_fix_screeninfo
*fix
, int con
,
119 struct fb_info
*info
);
120 static int dnfb_get_var(struct fb_var_screeninfo
*var
, int con
,
121 struct fb_info
*info
);
122 static int dnfb_set_var(struct fb_var_screeninfo
*var
, int con
,
123 struct fb_info
*info
);
124 static int dnfb_get_cmap(struct fb_cmap
*cmap
,int kspc
,int con
,
125 struct fb_info
*info
);
126 static int dnfb_set_cmap(struct fb_cmap
*cmap
,int kspc
,int con
,
127 struct fb_info
*info
);
128 static int dnfb_pan_display(struct fb_var_screeninfo
*var
, int con
,
129 struct fb_info
*info
);
130 static int dnfb_ioctl(struct inode
*inode
, struct file
*file
,
131 unsigned int cmd
, unsigned long arg
, int con
,
132 struct fb_info
*info
);
134 static int dnfbcon_switch(int con
, struct fb_info
*info
);
135 static int dnfbcon_updatevar(int con
, struct fb_info
*info
);
136 static void dnfbcon_blank(int blank
, struct fb_info
*info
);
138 static void dnfb_set_disp(int con
, struct fb_info
*info
);
140 static struct display disp
[MAX_NR_CONSOLES
];
141 static struct fb_info fb_info
;
142 static struct fb_ops dnfb_ops
= {
143 dnfb_open
,dnfb_release
, dnfb_get_fix
, dnfb_get_var
, dnfb_set_var
,
144 dnfb_get_cmap
, dnfb_set_cmap
, dnfb_pan_display
, dnfb_ioctl
147 static int currcon
=0;
149 static char dnfb_name
[]="Apollo";
151 static int dnfb_open(struct fb_info
*info
, int user
)
154 * Nothing, only a usage count for the moment
161 static int dnfb_release(struct fb_info
*info
, int user
)
167 static int dnfb_get_fix(struct fb_fix_screeninfo
*fix
, int con
,
168 struct fb_info
*info
)
170 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
171 strcpy(fix
->id
,"Apollo Mono");
172 fix
->smem_start
=FRAME_BUFFER_START
+IO_BASE
;
173 fix
->smem_len
=FRAME_BUFFER_LEN
;
174 fix
->type
=FB_TYPE_PACKED_PIXELS
;
176 fix
->visual
=FB_VISUAL_MONO10
;
180 fix
->line_length
=256;
186 static int dnfb_get_var(struct fb_var_screeninfo
*var
, int con
,
187 struct fb_info
*info
)
189 memset(var
, 0, sizeof(struct fb_var_screeninfo
));
192 var
->xres_virtual
=2048;
193 var
->yres_virtual
=1024;
196 var
->bits_per_pixel
=1;
208 var
->vmode
=FB_VMODE_NONINTERLACED
;
214 static int dnfb_set_var(struct fb_var_screeninfo
*var
, int con
,
215 struct fb_info
*info
)
221 if(var
->xres_virtual
!=2048)
223 if(var
->yres_virtual
!=1024)
229 if(var
->bits_per_pixel
!=1)
231 if(var
->grayscale
!=0)
239 if(var
->left_margin
!=0)
241 if(var
->right_margin
!=0)
243 if(var
->hsync_len
!=0)
245 if(var
->vsync_len
!=0)
249 if(var
->vmode
!=FB_VMODE_NONINTERLACED
)
256 static int dnfb_get_cmap(struct fb_cmap
*cmap
, int kspc
, int con
,
257 struct fb_info
*info
)
259 printk("get cmap not supported\n");
264 static int dnfb_set_cmap(struct fb_cmap
*cmap
, int kspc
, int con
,
265 struct fb_info
*info
)
267 printk("set cmap not supported\n");
273 static int dnfb_pan_display(struct fb_var_screeninfo
*var
, int con
,
274 struct fb_info
*info
)
276 printk("panning not supported\n");
282 static int dnfb_ioctl(struct inode
*inode
, struct file
*file
,
283 unsigned int cmd
, unsigned long arg
, int con
,
284 struct fb_info
*info
)
289 static void dnfb_set_disp(int con
, struct fb_info
*info
)
291 struct fb_fix_screeninfo fix
;
293 dnfb_get_fix(&fix
, con
, info
);
297 disp
[con
].screen_base
= fix
.smem_start
;
298 disp
[con
].visual
= fix
.visual
;
299 disp
[con
].type
= fix
.type
;
300 disp
[con
].type_aux
= fix
.type_aux
;
301 disp
[con
].ypanstep
= fix
.ypanstep
;
302 disp
[con
].ywrapstep
= fix
.ywrapstep
;
303 disp
[con
].can_soft_blank
= 1;
304 disp
[con
].inverse
= 0;
305 disp
[con
].line_length
= fix
.line_length
;
307 disp
[con
].dispsw
= &fbcon_mfb
;
309 disp
[con
].dispsw
= &fbcon_dummy
;
315 fb_info
.changevar
=NULL
;
316 strcpy(&fb_info
.modename
[0],dnfb_name
);
317 fb_info
.fontname
[0]=0;
319 fb_info
.switch_con
=&dnfbcon_switch
;
320 fb_info
.updatevar
=&dnfbcon_updatevar
;
321 fb_info
.blank
=&dnfbcon_blank
;
323 fb_info
.fbops
= &dnfb_ops
;
324 fb_info
.flags
= FBINFO_FLAG_DEFAULT
;
326 outb(RESET_CREG
, AP_CONTROL_3A
);
327 outw(0x0, AP_WRITE_ENABLE
);
328 outb(NORMAL_MODE
,AP_CONTROL_0
);
329 outb((AD_BLT
| DST_EQ_SRC
| NORM_CREG1
), AP_CONTROL_1
);
330 outb(S_DATA_PLN
, AP_CONTROL_2
);
331 outw(SWAP(0x3),AP_ROP_1
);
333 dnfb_get_var(&disp
[0].var
, 0, &fb_info
);
334 dnfb_set_disp(-1, &fb_info
);
336 if (register_framebuffer(&fb_info
) < 0) {
337 printk(KERN_ERR
"unable to register apollo frame buffer\n");
341 printk("fb%d: apollo frame buffer alive and kicking !\n",
342 GET_FB_IDX(fb_info
.node
));
347 static int dnfbcon_switch(int con
, struct fb_info
*info
)
355 static int dnfbcon_updatevar(int con
, struct fb_info
*info
)
360 static void dnfbcon_blank(int blank
, struct fb_info
*info
)
363 outb(0, AP_CONTROL_3A
);
364 outb((AD_BLT
| DST_EQ_SRC
| NORM_CREG1
) & ~ENAB_DISP
,
368 outb(1, AP_CONTROL_3A
);
369 outb((AD_BLT
| DST_EQ_SRC
| NORM_CREG1
), AP_CONTROL_1
);