2 * HP300 Topcat framebuffer support (derived from macfb of all things)
3 * Phil Blundell <philb@gnu.org> 1998
6 #include <linux/module.h>
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
9 #include <linux/errno.h>
10 #include <linux/string.h>
12 #include <linux/tty.h>
13 #include <linux/slab.h>
14 #include <linux/delay.h>
15 #include <linux/init.h>
17 #include <linux/dio.h>
19 #include <asm/blinken.h>
20 #include <asm/hwtest.h>
22 static struct fb_info fb_info
;
24 unsigned long fb_regs
;
25 unsigned char fb_bitmask
;
29 #define TC_FBEN 0x4090
30 #define TC_NBLANK 0x4080
35 #define SOURCE_X 0x40f2
36 #define SOURCE_Y 0x40f6
39 #define WHEIGHT 0x4106
43 static struct fb_fix_screeninfo hpfb_fix __initdata
= {
46 .type
= FB_TYPE_PACKED_PIXELS
,
47 .visual
= FB_VISUAL_PSEUDOCOLOR
,
49 .accel
= FB_ACCEL_NONE
,
52 static struct fb_var_screeninfo hpfb_defined
= {
58 .red
= {0,2,0}, /* R */
59 .green
= {0,2,0}, /* G */
60 .blue
= {0,2,0}, /* B */
61 .activate
= FB_ACTIVATE_NOW
,
63 .width
= 195, /* 14" monitor */
64 .accel_flags
= FB_ACCEL_NONE
,
65 .vmode
= FB_VMODE_NONINTERLACED
,
69 * Set the palette. This may not work on all boards but only experimentation
71 * XXX Doesn't work at all.
73 static int hpfb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
74 unsigned blue
, unsigned transp
,
77 while (in_be16(fb_regs
+ 0x6002) & 0x4) udelay(1);
78 out_be16(fb_regs
+ 0x60f0, 0);
79 out_be16(fb_regs
+ 0x60b8, regno
);
80 out_be16(fb_regs
+ 0x60b2, red
);
81 out_be16(fb_regs
+ 0x60b4, green
);
82 out_be16(fb_regs
+ 0x60b6, blue
);
83 out_be16(fb_regs
+ 0x60f0, 0xff);
85 out_be16(fb_regs
+ 0x60ba, 0xffff);
89 void hpfb_copyarea(struct fb_info
*info
, const struct fb_copyarea
*area
)
91 while (in_8(fb_regs
+ BUSY
) & fb_bitmask
);
92 out_8(fb_regs
+ WMRR
, 0x3);
93 out_be16(fb_regs
+ SOURCE_X
, area
->sx
);
94 out_be16(fb_regs
+ SOURCE_Y
, area
->sy
);
95 out_be16(fb_regs
+ DEST_X
, area
->dx
);
96 out_be16(fb_regs
+ DEST_Y
, area
->dy
);
97 out_be16(fb_regs
+ WHEIGHT
, area
->height
);
98 out_be16(fb_regs
+ WWIDTH
, area
->width
);
99 out_8(fb_regs
+ WMOVE
, fb_bitmask
);
102 static struct fb_ops hpfb_ops
= {
103 .owner
= THIS_MODULE
,
104 .fb_setcolreg
= hpfb_setcolreg
,
105 .fb_fillrect
= cfb_fillrect
,
106 .fb_copyarea
= hpfb_copyarea
,
107 .fb_imageblit
= cfb_imageblit
,
108 .fb_cursor
= soft_cursor
,
111 #define TOPCAT_FBOMSB 0x5d
112 #define TOPCAT_FBOLSB 0x5f
114 int __init
hpfb_init_one(unsigned long base
)
118 fboff
= (in_8(base
+ TOPCAT_FBOMSB
) << 8) | in_8(base
+ TOPCAT_FBOLSB
);
120 hpfb_fix
.smem_start
= 0xf0000000 | (in_8(base
+ fboff
) << 16);
124 /* This is the magic incantation NetBSD uses to make Catseye boards work. */
125 out_8(base
+0x4800, 0);
126 out_8(base
+0x4510, 0);
127 out_8(base
+0x4512, 0);
128 out_8(base
+0x4514, 0);
129 out_8(base
+0x4516, 0);
130 out_8(base
+0x4206, 0x90);
133 * Give the hardware a bit of a prod and work out how many bits per
134 * pixel are supported.
137 out_8(base
+ TC_WEN
, 0xff);
138 out_8(base
+ TC_FBEN
, 0xff);
139 out_8(hpfb_fix
.smem_start
, 0xff);
140 fb_bitmask
= in_8(hpfb_fix
.smem_start
);
143 * Enable reading/writing of all the planes.
145 out_8(base
+ TC_WEN
, fb_bitmask
);
146 out_8(base
+ TC_REN
, fb_bitmask
);
147 out_8(base
+ TC_FBEN
, fb_bitmask
);
148 out_8(base
+ TC_NBLANK
, 0x1);
151 * Let there be consoles..
153 fb_info
.fbops
= &hpfb_ops
;
154 fb_info
.flags
= FBINFO_FLAG_DEFAULT
;
155 fb_info
.var
= hpfb_defined
;
156 fb_info
.fix
= hpfb_fix
;
157 fb_info
.screen_base
= (char *)hpfb_fix
.smem_start
; // FIXME
159 fb_alloc_cmap(&fb_info
.cmap
, 256, 0);
161 if (register_framebuffer(&fb_info
) < 0)
167 * Check that the secondary ID indicates that we have some hope of working with this
168 * framebuffer. The catseye boards are pretty much like topcats and we can muddle through.
171 #define topcat_sid_ok(x) (((x) == DIO_ID2_LRCATSEYE) || ((x) == DIO_ID2_HRCCATSEYE) \
172 || ((x) == DIO_ID2_HRMCATSEYE) || ((x) == DIO_ID2_TOPCAT))
175 * Initialise the framebuffer
178 int __init
hpfb_init(void)
182 /* Topcats can be on the internal IO bus or real DIO devices.
183 * The internal variant sits at 0xf0560000; it has primary
184 * and secondary ID registers just like the DIO version.
185 * So we merge the two detection routines.
187 * Perhaps this #define should be in a global header file:
188 * I believe it's common to all internal fbs, not just topcat.
190 #define INTFBADDR 0xf0560000
192 if (hwreg_present((void *)INTFBADDR
) &&
193 (DIO_ID(INTFBADDR
) == DIO_ID_FBUFFER
) &&
194 topcat_sid_ok(sid
= DIO_SECID(INTFBADDR
))) {
195 printk("Internal Topcat found (secondary id %02x)\n", sid
);
196 hpfb_init_one(INTFBADDR
);
198 int sc
= dio_find(DIO_ID_FBUFFER
);
201 unsigned long addr
= (unsigned long)dio_scodetoviraddr(sc
);
202 unsigned int sid
= DIO_SECID(addr
);
204 if (topcat_sid_ok(sid
)) {
205 printk("Topcat found at DIO select code %02x "
206 "(secondary id %02x)\n", sc
, sid
);
214 MODULE_LICENSE("GPL");