| 1 | |
| 2 | * linux/drivers/video/maxinefb.c
|
| 3 | *
|
| 4 | * DECstation 5000/xx onboard framebuffer support ... derived from:
|
| 5 | * "HP300 Topcat framebuffer support (derived from macfb of all things)
|
| 6 | * Phil Blundell <[email protected]> 1998", the original code can be
|
| 7 | * found in the file hpfb.c in the same directory.
|
| 8 | *
|
| 9 | * DECstation related code Copyright (C) 1999,2000,2001 by
|
| 10 | * Michael Engel <[email protected]> and
|
| 11 | * Karsten Merker <[email protected]>.
|
| 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.
|
| 15 | *
|
| 16 |
|
| 17 |
|
| 18 | |
| 19 | * Changes:
|
| 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)
|
| 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 |
|
| 40 | static struct fb_info fb_info;
|
| 41 |
|
| 42 | static const 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 |
|
| 54 | static struct fb_fix_screeninfo maxinefb_fix __initdata = {
|
| 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 |
|
| 64 | static void 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 |
|
| 74 | #if 0 |
| 75 | /* dead code: leave here for hardware interface documentation */
|
| 76 | static unsigned int maxinefb_ims332_read_register(int regno)
|
| 77 | {
|
| 78 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
|
| 79 | unsigned char *rptr;
|
| 80 | register unsigned int j, k;
|
| 81 |
|
| 82 | rptr = regs + 0x80000 + (regno << 4);
|
| 83 | j = *((volatile unsigned short *) rptr);
|
| 84 | k = *((volatile unsigned short *) regs);
|
| 85 |
|
| 86 | return (j & 0xffff) | ((k & 0xff00) << 8);
|
| 87 | }
|
| 88 | #endif
|
| 89 |
|
| 90 |
|
| 91 | static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
|
| 92 | unsigned blue, unsigned transp, struct fb_info *info)
|
| 93 | {
|
| 94 |
|
| 95 | unsigned long hw_colorvalue = 0;
|
| 96 |
|
| 97 | if (regno > 255)
|
| 98 | return 1;
|
| 99 |
|
| 100 | red >>= 8;
|
| 101 | green >>= 8;
|
| 102 | blue >>= 8;
|
| 103 |
|
| 104 | hw_colorvalue = (blue << 16) + (green << 8) + (red);
|
| 105 |
|
| 106 | maxinefb_ims332_write_register(IMS332_REG_COLOR_PALETTE + regno,
|
| 107 | hw_colorvalue);
|
| 108 | return 0;
|
| 109 | }
|
| 110 |
|
| 111 | static const struct fb_ops maxinefb_ops = {
|
| 112 | .owner = THIS_MODULE,
|
| 113 | FB_DEFAULT_IOMEM_OPS,
|
| 114 | .fb_setcolreg = maxinefb_setcolreg,
|
| 115 | };
|
| 116 |
|
| 117 | static int __init maxinefb_init(void)
|
| 118 | {
|
| 119 | unsigned long fboff;
|
| 120 | unsigned long fb_start;
|
| 121 | int i;
|
| 122 |
|
| 123 | if (fb_get_options("maxinefb", NULL))
|
| 124 | return -ENODEV;
|
| 125 |
|
| 126 |
|
| 127 | if (mips_machtype != MACH_DS5000_XX) {
|
| 128 | return -EINVAL;
|
| 129 | }
|
| 130 |
|
| 131 | printk(KERN_INFO "Maxinefb: Personal DECstation detected\n");
|
| 132 | printk(KERN_INFO "Maxinefb: initializing onboard framebuffer\n");
|
| 133 |
|
| 134 |
|
| 135 | fb_start = DS5000_xx_ONBOARD_FBMEM_START;
|
| 136 |
|
| 137 |
|
| 138 | for (fboff = fb_start; fboff < fb_start + 0x1ffff; fboff++)
|
| 139 | *(volatile unsigned char *)fboff = 0x0;
|
| 140 |
|
| 141 | maxinefb_fix.smem_start = fb_start;
|
| 142 |
|
| 143 |
|
| 144 | for (i = 0; i < 512; i++) {
|
| 145 | maxinefb_ims332_write_register(IMS332_REG_CURSOR_RAM + i,
|
| 146 | 0);
|
| 147 | |
| 148 | if (i&0x8 == 0)
|
| 149 | maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0x0f);
|
| 150 | else
|
| 151 | maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0xf0);
|
| 152 |
|
| 153 | }
|
| 154 |
|
| 155 | fb_info.fbops = &maxinefb_ops;
|
| 156 | fb_info.screen_base = (char *)maxinefb_fix.smem_start;
|
| 157 | fb_info.var = maxinefb_defined;
|
| 158 | fb_info.fix = maxinefb_fix;
|
| 159 |
|
| 160 | fb_alloc_cmap(&fb_info.cmap, 256, 0);
|
| 161 |
|
| 162 | if (register_framebuffer(&fb_info) < 0)
|
| 163 | return -ENODEV;
|
| 164 | return 0;
|
| 165 | }
|
| 166 |
|
| 167 | static void __exit maxinefb_exit(void)
|
| 168 | {
|
| 169 | unregister_framebuffer(&fb_info);
|
| 170 | }
|
| 171 |
|
| 172 | module_init(maxinefb_init);
|
| 173 | module_exit(maxinefb_exit);
|
| 174 |
|
| 175 | MODULE_LICENSE("GPL");
|