1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <linux/module.h>
27#include <linux/kernel.h>
28#include <linux/errno.h>
29#include <linux/string.h>
30#include <linux/mm.h>
31#include <linux/delay.h>
32#include <linux/init.h>
33#include <linux/fb.h>
34#include <video/maxinefb.h>
35
36
37
38#include <asm/bootinfo.h>
39
40static struct fb_info fb_info;
41
42static struct fb_var_screeninfo maxinefb_defined = {
43 .xres = 1024,
44 .yres = 768,
45 .xres_virtual = 1024,
46 .yres_virtual = 768,
47 .bits_per_pixel =8,
48 .activate = FB_ACTIVATE_NOW,
49 .height = -1,
50 .width = -1,
51 .vmode = FB_VMODE_NONINTERLACED,
52};
53
54static struct fb_fix_screeninfo maxinefb_fix = {
55 .id = "Maxine",
56 .smem_len = (1024*768),
57 .type = FB_TYPE_PACKED_PIXELS,
58 .visual = FB_VISUAL_PSEUDOCOLOR,
59 .line_length = 1024,
60};
61
62
63
64void maxinefb_ims332_write_register(int regno, register unsigned int val)
65{
66 register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
67 unsigned char *wptr;
68
69 wptr = regs + 0xa0000 + (regno << 4);
70 *((volatile unsigned int *) (regs)) = (val >> 8) & 0xff00;
71 *((volatile unsigned short *) (wptr)) = val;
72}
73
74unsigned int maxinefb_ims332_read_register(int regno)
75{
76 register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
77 unsigned char *rptr;
78 register unsigned int j, k;
79
80 rptr = regs + 0x80000 + (regno << 4);
81 j = *((volatile unsigned short *) rptr);
82 k = *((volatile unsigned short *) regs);
83
84 return (j & 0xffff) | ((k & 0xff00) << 8);
85}
86
87
88static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
89 unsigned blue, unsigned transp, struct fb_info *info)
90{
91
92 unsigned long hw_colorvalue = 0;
93
94 if (regno > 255)
95 return 1;
96
97 red >>= 8;
98 green >>= 8;
99 blue >>= 8;
100
101 hw_colorvalue = (blue << 16) + (green << 8) + (red);
102
103 maxinefb_ims332_write_register(IMS332_REG_COLOR_PALETTE + regno,
104 hw_colorvalue);
105 return 0;
106}
107
108static struct fb_ops maxinefb_ops = {
109 .owner = THIS_MODULE,
110 .fb_setcolreg = maxinefb_setcolreg,
111 .fb_fillrect = cfb_fillrect,
112 .fb_copyarea = cfb_copyarea,
113 .fb_imageblit = cfb_imageblit,
114};
115
116int __init maxinefb_init(void)
117{
118 unsigned long fboff;
119 unsigned long fb_start;
120 int i;
121
122 if (fb_get_options("maxinefb", NULL))
123 return -ENODEV;
124
125
126 if (mips_machtype != MACH_DS5000_XX) {
127 return -EINVAL;
128 }
129
130 printk(KERN_INFO "Maxinefb: Personal DECstation detected\n");
131 printk(KERN_INFO "Maxinefb: initializing onboard framebuffer\n");
132
133
134 fb_start = DS5000_xx_ONBOARD_FBMEM_START;
135
136
137 for (fboff = fb_start; fboff < fb_start + 0x1ffff; fboff++)
138 *(volatile unsigned char *)fboff = 0x0;
139
140 maxinefb_fix.smem_start = fb_start;
141
142
143 for (i = 0; i < 512; i++) {
144 maxinefb_ims332_write_register(IMS332_REG_CURSOR_RAM + i,
145 0);
146
147
148
149
150
151
152 }
153
154 fb_info.fbops = &maxinefb_ops;
155 fb_info.screen_base = (char *)maxinefb_fix.smem_start;
156 fb_info.var = maxinefb_defined;
157 fb_info.fix = maxinefb_fix;
158 fb_info.flags = FBINFO_DEFAULT;
159
160 fb_alloc_cmap(&fb_info.cmap, 256, 0);
161
162 if (register_framebuffer(&fb_info) < 0)
163 return 1;
164 return 0;
165}
166
167static void __exit maxinefb_exit(void)
168{
169 unregister_framebuffer(&fb_info);
170}
171
172#ifdef MODULE
173MODULE_LICENSE("GPL");
174#endif
175module_init(maxinefb_init);
176module_exit(maxinefb_exit);
177
178