Commit 67bf3c24 authored by David S. Miller's avatar David S. Miller

[FRAMEBUFFER]: Convert cg14 driver to new APIs.

parent 57b55f79
...@@ -823,9 +823,9 @@ config FB_TCX ...@@ -823,9 +823,9 @@ config FB_TCX
This is the frame buffer device driver for the TCX 24/8bit frame This is the frame buffer device driver for the TCX 24/8bit frame
buffer. buffer.
config FB_CGFOURTEEN config FB_CG14
bool "CGfourteen (SX) support" bool "CGfourteen (SX) support"
depends on FB_SBUS && SPARC32 depends on FB_SBUS
help help
This is the frame buffer device driver for the CGfourteen frame This is the frame buffer device driver for the CGfourteen frame
buffer on Desktop SPARCsystems with the SX graphics option. buffer on Desktop SPARCsystems with the SX graphics option.
......
...@@ -72,7 +72,6 @@ obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgb ...@@ -72,7 +72,6 @@ obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgb
# One by one these are being converted over to the new APIs # One by one these are being converted over to the new APIs
#obj-$(CONFIG_FB_TCX) += tcxfb.o sbusfb.o #obj-$(CONFIG_FB_TCX) += tcxfb.o sbusfb.o
#obj-$(CONFIG_FB_CGFOURTEEN) += cgfourteenfb.o sbusfb.o
#obj-$(CONFIG_FB_P9100) += p9100fb.o sbusfb.o #obj-$(CONFIG_FB_P9100) += p9100fb.o sbusfb.o
#obj-$(CONFIG_FB_LEO) += leofb.o sbusfb.o #obj-$(CONFIG_FB_LEO) += leofb.o sbusfb.o
...@@ -82,6 +81,8 @@ obj-$(CONFIG_FB_CG3) += cg3.o sbuslib.o cfbimgblt.o cfbcopyarea.o ...@@ -82,6 +81,8 @@ obj-$(CONFIG_FB_CG3) += cg3.o sbuslib.o cfbimgblt.o cfbcopyarea.o
cfbfillrect.o cfbfillrect.o
obj-$(CONFIG_FB_BW2) += bw2.o sbuslib.o cfbimgblt.o cfbcopyarea.o \ obj-$(CONFIG_FB_BW2) += bw2.o sbuslib.o cfbimgblt.o cfbcopyarea.o \
cfbfillrect.o cfbfillrect.o
obj-$(CONFIG_FB_CG14) += cg14.o sbuslib.o cfbimgblt.o cfbcopyarea.o \
cfbfillrect.o
# Files generated that shall be removed upon make clean # Files generated that shall be removed upon make clean
clean-files := promcon_tbl.c clean-files := promcon_tbl.c
......
/* $Id: cgfourteenfb.c,v 1.11 2001/09/19 00:04:33 davem Exp $ /* cg14.c: CGFOURTEEN frame buffer driver
* cgfourteenfb.c: CGfourteen frame buffer driver
* *
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
* Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz) * Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
* Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx) * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
*
* Driver layout based loosely on tgafb.c, see that file for credits.
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/sched.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/mm.h>
#include <linux/tty.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/selection.h> #include <linux/fb.h>
#include <linux/mm.h>
#include <video/sbusfb.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/pgtable.h> #include <asm/sbus.h>
#include <asm/uaccess.h> #include <asm/oplib.h>
#include <asm/fbio.h>
#include "sbuslib.h"
/*
* Local functions.
*/
static int cg14_check_var(struct fb_var_screeninfo *, struct fb_info *);
static int cg14_set_par(struct fb_info *);
static int cg14_setcolreg(unsigned, unsigned, unsigned, unsigned,
unsigned, struct fb_info *);
#include <video/fbcon-cfb8.h> static int cg14_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int cg14_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/*
* Frame buffer operations
*/
static struct fb_ops cg14_ops = {
.owner = THIS_MODULE,
.fb_check_var = cg14_check_var,
.fb_set_par = cg14_set_par,
.fb_setcolreg = cg14_setcolreg,
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
.fb_mmap = cg14_mmap,
.fb_ioctl = cg14_ioctl,
.fb_cursor = soft_cursor,
};
#define CG14_MCR_INTENABLE_SHIFT 7 #define CG14_MCR_INTENABLE_SHIFT 7
#define CG14_MCR_INTENABLE_MASK 0x80 #define CG14_MCR_INTENABLE_MASK 0x80
...@@ -72,8 +99,6 @@ ...@@ -72,8 +99,6 @@
#define CG14_MCR_PIXMODE_16 2 #define CG14_MCR_PIXMODE_16 2
#define CG14_MCR_PIXMODE_32 3 #define CG14_MCR_PIXMODE_32 3
MODULE_LICENSE("GPL");
struct cg14_regs{ struct cg14_regs{
volatile u8 mcr; /* Master Control Reg */ volatile u8 mcr; /* Master Control Reg */
volatile u8 ppr; /* Packed Pixel Reg */ volatile u8 ppr; /* Packed Pixel Reg */
...@@ -161,285 +186,412 @@ struct cg14_clut { ...@@ -161,285 +186,412 @@ struct cg14_clut {
u32 c_clutd_inc [256]; u32 c_clutd_inc [256];
}; };
static struct sbus_mmap_map cg14_mmap_map[] __initdata = { #define CG14_MMAP_ENTRIES 16
{ CG14_REGS, 0x80000000, 0x1000 },
{ CG14_XLUT, 0x80003000, 0x1000 }, struct cg14_par {
{ CG14_CLUT1, 0x80004000, 0x1000 }, spinlock_t lock;
{ CG14_CLUT2, 0x80005000, 0x1000 }, struct cg14_regs *regs;
{ CG14_CLUT3, 0x80006000, 0x1000 }, struct cg14_clut *clut;
{ CG3_MMAP_OFFSET - struct cg14_cursor *cursor;
0x7000, 0x80000000, 0x7000 },
{ CG3_MMAP_OFFSET, 0x00000000, SBUS_MMAP_FBSIZE(1) }, u32 flags;
{ MDI_CURSOR_MAP, 0x80001000, 0x1000 }, #define CG14_FLAG_BLANKED 0x00000001
{ MDI_CHUNKY_BGR_MAP, 0x01000000, 0x400000 },
{ MDI_PLANAR_X16_MAP, 0x02000000, 0x200000 }, unsigned long physbase;
{ MDI_PLANAR_C16_MAP, 0x02800000, 0x200000 }, unsigned long iospace;
{ MDI_PLANAR_X32_MAP, 0x03000000, 0x100000 }, unsigned long fbsize;
{ MDI_PLANAR_B32_MAP, 0x03400000, 0x100000 },
{ MDI_PLANAR_G32_MAP, 0x03800000, 0x100000 }, struct sbus_mmap_map mmap_map[CG14_MMAP_ENTRIES];
{ MDI_PLANAR_R32_MAP, 0x03c00000, 0x100000 },
{ 0, 0, 0 } int mode;
int ramsize;
struct sbus_dev *sdev;
struct list_head list;
}; };
static void cg14_loadcmap (struct fb_info_sbusfb *fb, struct display *p, static void __cg14_reset(struct cg14_par *par)
int index, int count)
{ {
struct cg14_clut *clut = fb->s.cg14.clut; struct cg14_regs *regs = par->regs;
unsigned long flags; u8 val;
spin_lock_irqsave(&fb->lock, flags); val = sbus_readb(&regs->mcr);
for (; count--; index++) { val &= ~(CG14_MCR_PIXMODE_MASK);
u32 val; sbus_writeb(val, &regs->mcr);
val = ((fb->color_map CM(index,2) << 16) |
(fb->color_map CM(index,1) << 8) |
(fb->color_map CM(index,0)));
sbus_writel(val, &clut->c_clut[index]);
}
spin_unlock_irqrestore(&fb->lock, flags);
} }
static void cg14_margins (struct fb_info_sbusfb *fb, struct display *p, /**
int x_margin, int y_margin) * cg14_check_var - Optional function. Validates a var passed in.
* @var: frame buffer variable screen structure
* @info: frame buffer structure that represents a single frame buffer
*/
static int cg14_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
{ {
fb->info.screen_base += (y_margin - fb->y_margin) * if (var->bits_per_pixel != 8)
fb->info.fix.line_length + (x_margin - fb->x_margin); return -EINVAL;
if (var->xres_virtual != var->xres || var->yres_virtual != var->yres)
return -EINVAL;
if (var->nonstd)
return -EINVAL;
if ((var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED)
return -EINVAL;
if (var->xres != info->var.xres || var->yres != info->var.yres)
return -EINVAL;
return 0;
} }
static void cg14_setcursormap (struct fb_info_sbusfb *fb, u8 *red, u8 *green, u8 *blue) /**
* cg14_set_par - Optional function. Alters the hardware state.
* @info: frame buffer structure that represents a single frame buffer
*/
static int
cg14_set_par(struct fb_info *info)
{ {
struct cg14_cursor *cur = fb->s.cg14.cursor; return 0;
unsigned long flags;
spin_lock_irqsave(&fb->lock, flags);
sbus_writel(((red[0]) | (green[0] << 8) | (blue[0] << 16)), &cur->color0);
sbus_writel(((red[1]) | (green[1] << 8) | (blue[1] << 16)), &cur->color1);
spin_unlock_irqrestore(&fb->lock, flags);
} }
/* Set cursor shape */ /**
static void cg14_setcurshape (struct fb_info_sbusfb *fb) * cg14_setcolreg - Optional function. Sets a color register.
* @regno: boolean, 0 copy local, 1 get_user() function
* @red: frame buffer colormap structure
* @green: The green value which can be up to 16 bits wide
* @blue: The blue value which can be up to 16 bits wide.
* @transp: If supported the alpha value which can be up to 16 bits wide.
* @info: frame buffer info structure
*/
static int cg14_setcolreg(unsigned regno,
unsigned red, unsigned green, unsigned blue,
unsigned transp, struct fb_info *info)
{ {
struct cg14_cursor *cur = fb->s.cg14.cursor; struct cg14_par *par = (struct cg14_par *) info->par;
struct cg14_clut *clut = par->clut;
unsigned long flags; unsigned long flags;
int i; u32 val;
spin_lock_irqsave(&fb->lock, flags); if (regno >= 256)
for (i = 0; i < 32; i++){ return 1;
sbus_writel(fb->cursor.bits[0][i], &cur->cpl0[i]);
sbus_writel(fb->cursor.bits[1][i], &cur->cpl1[i]);
}
spin_unlock_irqrestore(&fb->lock, flags);
}
/* Load cursor information */ val = (red | (green << 8) | (blue << 16));
static void cg14_setcursor (struct fb_info_sbusfb *fb)
{
struct cg_cursor *c = &fb->cursor;
struct cg14_cursor *cur = fb->s.cg14.cursor;
unsigned long flags;
spin_lock_irqsave(&fb->lock, flags);
if (c->enable) {
u8 tmp = sbus_readb(&cur->ccr);
tmp |= CG14_CCR_ENABLE; spin_lock_irqsave(&par->lock, flags);
sbus_writeb(tmp, &cur->ccr); sbus_writel(val, &clut->c_clut[regno]);
} else { spin_unlock_irqrestore(&par->lock, flags);
u8 tmp = sbus_readb(&cur->ccr);
tmp &= ~CG14_CCR_ENABLE; return 0;
sbus_writeb(tmp, &cur->ccr);
}
sbus_writew(((c->cpos.fbx - c->chot.fbx) & 0xfff), &cur->cursx);
sbus_writew(((c->cpos.fby - c->chot.fby) & 0xfff), &cur->cursy);
spin_unlock_irqrestore(&fb->lock, flags);
} }
static void cg14_switch_from_graph (struct fb_info_sbusfb *fb) static int cg14_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma)
{ {
unsigned long flags; struct cg14_par *par = (struct cg14_par *) info->par;
spin_lock_irqsave(&fb->lock, flags); return sbusfb_mmap_helper(par->mmap_map,
par->physbase, par->fbsize,
/* Set the 8-bpp mode */ par->iospace, vma);
if (fb->open && fb->mmaped){
volatile char *mcr = &fb->s.cg14.regs->mcr;
char tmp;
fb->s.cg14.mode = 8;
tmp = sbus_readb(mcr);
tmp &= ~(CG14_MCR_PIXMODE_MASK);
sbus_writeb(tmp, mcr);
}
spin_unlock_irqrestore(&fb->lock, flags);
} }
static void cg14_reset (struct fb_info_sbusfb *fb) static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{ {
volatile char *mcr = &fb->s.cg14.regs->mcr; struct cg14_par *par = (struct cg14_par *) info->par;
struct cg14_regs *regs = par->regs;
struct mdi_cfginfo kmdi, *mdii;
unsigned long flags; unsigned long flags;
char tmp; int cur_mode, mode, ret = 0;
spin_lock_irqsave(&fb->lock, flags);
tmp = sbus_readb(mcr);
tmp &= ~(CG14_MCR_PIXMODE_MASK);
sbus_writeb(tmp, mcr);
spin_unlock_irqrestore(&fb->lock, flags);
}
static int cg14_ioctl (struct fb_info_sbusfb *fb, unsigned int cmd, unsigned long arg)
{
volatile char *mcr = &fb->s.cg14.regs->mcr;
struct mdi_cfginfo *mdii;
unsigned long flags;
int mode, ret = 0;
char tmp;
switch (cmd) { switch (cmd) {
case MDI_RESET: case MDI_RESET:
spin_lock_irqsave(&fb->lock, flags); spin_lock_irqsave(&par->lock, flags);
tmp = sbus_readb(mcr); __cg14_reset(par);
tmp &= ~CG14_MCR_PIXMODE_MASK; spin_unlock_irqrestore(&par->lock, flags);
sbus_writeb(tmp, mcr);
spin_unlock_irqrestore(&fb->lock, flags);
break; break;
case MDI_GET_CFGINFO: case MDI_GET_CFGINFO:
mdii = (struct mdi_cfginfo *)arg; memset(&kmdi, 0, sizeof(kmdi));
if (put_user(FBTYPE_MDICOLOR, &mdii->mdi_type) ||
__put_user(fb->type.fb_height, &mdii->mdi_height) || spin_lock_irqsave(&par->lock, flags);
__put_user(fb->type.fb_width, &mdii->mdi_width) || kmdi.mdi_type = FBTYPE_MDICOLOR;
__put_user(fb->s.cg14.mode, &mdii->mdi_mode) || kmdi.mdi_height = info->var.yres;
__put_user(72, &mdii->mdi_pixfreq) || /* FIXME */ kmdi.mdi_width = info->var.xres;
__put_user(fb->s.cg14.ramsize, &mdii->mdi_size)) kmdi.mdi_mode = par->mode;
return -EFAULT; kmdi.mdi_pixfreq = 72; /* FIXME */
kmdi.mdi_size = par->ramsize;
spin_unlock_irqrestore(&par->lock, flags);
mdii = (struct mdi_cfginfo *) arg;
if (copy_to_user(mdii, &kmdi, sizeof(kmdi)))
ret = -EFAULT;
break; break;
case MDI_SET_PIXELMODE: case MDI_SET_PIXELMODE:
if (get_user(mode, (int *)arg)) if (get_user(mode, (int *) arg)) {
return -EFAULT; ret = -EFAULT;
break;
}
spin_lock_irqsave(&fb->lock, flags); spin_lock_irqsave(&par->lock, flags);
tmp = sbus_readb(mcr); cur_mode = sbus_readb(&regs->mcr);
switch (mode){ cur_mode &= ~CG14_MCR_PIXMODE_MASK;
switch(mode) {
case MDI_32_PIX: case MDI_32_PIX:
tmp = (tmp & ~CG14_MCR_PIXMODE_MASK) | cur_mode |= (CG14_MCR_PIXMODE_32 <<
(CG14_MCR_PIXMODE_32 << CG14_MCR_PIXMODE_SHIFT); CG14_MCR_PIXMODE_SHIFT);
break; break;
case MDI_16_PIX: case MDI_16_PIX:
tmp = (tmp & ~CG14_MCR_PIXMODE_MASK) | 0x20; cur_mode |= 0x20;
break; break;
case MDI_8_PIX: case MDI_8_PIX:
tmp = (tmp & ~CG14_MCR_PIXMODE_MASK);
break; break;
default: default:
ret = -ENOSYS; ret = -ENOSYS;
break; break;
}; };
if (ret == 0) { if (!ret) {
sbus_writeb(tmp, mcr); sbus_writeb(cur_mode, &regs->mcr);
fb->s.cg14.mode = mode; par->mode = mode;
} }
spin_unlock_irqrestore(&fb->lock, flags); spin_unlock_irqrestore(&par->lock, flags);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
break;
}; };
return ret; return ret;
} }
static unsigned long __init get_phys(unsigned long addr) /*
{ * Initialisation
return __get_phys(addr); */
}
static int __init get_iospace(unsigned long addr) static void cg14_init_fix(struct fb_info *info, int linebytes)
{ {
return __get_iospace(addr); struct cg14_par *par = (struct cg14_par *)info->par;
strncpy(info->fix.id, par->sdev->prom_name, sizeof(info->fix.id) - 1);
info->fix.id[sizeof(info->fix.id)-1] = 0;
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_TRUECOLOR;
info->fix.line_length = linebytes;
info->fix.accel = FB_ACCEL_SUN_CG14;
} }
static char idstring[60] __initdata = { 0 }; static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] __initdata = {
{ CG14_REGS, 0x80000000, 0x1000 },
{ CG14_XLUT, 0x80003000, 0x1000 },
{ CG14_CLUT1, 0x80004000, 0x1000 },
{ CG14_CLUT2, 0x80005000, 0x1000 },
{ CG14_CLUT3, 0x80006000, 0x1000 },
{ CG3_MMAP_OFFSET -
0x7000, 0x80000000, 0x7000 },
{ CG3_MMAP_OFFSET, 0x00000000, SBUS_MMAP_FBSIZE(1) },
{ MDI_CURSOR_MAP, 0x80001000, 0x1000 },
{ MDI_CHUNKY_BGR_MAP, 0x01000000, 0x400000 },
{ MDI_PLANAR_X16_MAP, 0x02000000, 0x200000 },
{ MDI_PLANAR_C16_MAP, 0x02800000, 0x200000 },
{ MDI_PLANAR_X32_MAP, 0x03000000, 0x100000 },
{ MDI_PLANAR_B32_MAP, 0x03400000, 0x100000 },
{ MDI_PLANAR_G32_MAP, 0x03800000, 0x100000 },
{ MDI_PLANAR_R32_MAP, 0x03c00000, 0x100000 },
{ 0, 0, 0 }
};
struct all_info {
struct fb_info info;
struct cg14_par par;
struct list_head list;
};
static LIST_HEAD(cg14_list);
char __init *cgfourteenfb_init(struct fb_info_sbusfb *fb) static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node)
{ {
struct fb_fix_screeninfo *fix = &fb->info.fix; struct all_info *all;
struct display *disp = &fb->disp; unsigned long phys, rphys;
struct fbtype *type = &fb->type;
unsigned long rphys, phys;
u32 bases[6]; u32 bases[6];
int is_8mb, i; int is_8mb, linebytes, i;
if (!sdev) {
prom_getproperty(node, "address",
(char *) &bases[0], sizeof(bases));
if (!bases[0]) {
printk(KERN_ERR "cg14: Device is not mapped.\n");
return;
}
if (__get_iospace(bases[0]) != __get_iospace(bases[1])) {
printk(KERN_ERR "cg14: I/O spaces don't match.\n");
return;
}
}
#ifndef FBCON_HAS_CFB8 all = kmalloc(sizeof(*all), GFP_KERNEL);
return NULL; if (!all) {
#endif printk(KERN_ERR "cg14: Cannot allocate memory.\n");
prom_getproperty (fb->prom_node, "address", (char *) &bases[0], 8); return;
if (!bases[0]) {
printk("cg14 not mmaped\n");
return NULL;
} }
if (get_iospace(bases[0]) != get_iospace(bases[1])) { memset(all, 0, sizeof(*all));
printk("Ugh. cg14 iospaces don't match\n");
return NULL; INIT_LIST_HEAD(&all->list);
spin_lock_init(&all->par.lock);
sbusfb_fill_var(&all->info.var, node, 8);
linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
all->info.var.xres);
all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
all->par.sdev = sdev;
if (sdev) {
rphys = sdev->reg_addrs[0].phys_addr;
all->par.physbase = phys = sdev->reg_addrs[1].phys_addr;
all->par.iospace = sdev->reg_addrs[0].which_io;
all->par.regs = (struct cg14_regs *)
sbus_ioremap(&sdev->resource[0], 0,
sizeof(struct cg14_regs),
"cg14 regs");
all->par.clut = (struct cg14_clut *)
sbus_ioremap(&sdev->resource[0], CG14_CLUT1,
sizeof(struct cg14_clut),
"cg14 clut");
all->par.cursor = (struct cg14_cursor *)
sbus_ioremap(&sdev->resource[0], CG14_CURSORREGS,
sizeof(struct cg14_cursor),
"cg14 cursor");
all->info.screen_base = (char *)
sbus_ioremap(&sdev->resource[1], 0,
all->par.fbsize, "cg14 ram");
} else {
rphys = __get_phys(bases[0]);
all->par.physbase = phys = __get_phys(bases[1]);
all->par.iospace = __get_iospace(bases[0]);
all->par.regs = (struct cg14_regs *)(unsigned long)bases[0];
all->par.clut = (struct cg14_clut *)((unsigned long)bases[0] +
CG14_CLUT1);
all->par.cursor =
(struct cg14_cursor *)((unsigned long)bases[0] +
CG14_CURSORREGS);
all->info.screen_base = (char *)(unsigned long)bases[1];
} }
fb->physbase = phys = get_phys(bases[1]);
rphys = get_phys(bases[0]); prom_getproperty(node, "reg", (char *) &bases[0], sizeof(bases));
fb->iospace = get_iospace(bases[0]); is_8mb = (bases[5] == 0x800000);
fb->s.cg14.regs = (struct cg14_regs *)(unsigned long)bases[0];
fb->s.cg14.clut = (void *)((unsigned long)bases[0]+CG14_CLUT1); if (sizeof(all->par.mmap_map) != sizeof(__cg14_mmap_map)) {
fb->s.cg14.cursor = (void *)((unsigned long)bases[0]+CG14_CURSORREGS); extern void __cg14_mmap_sized_wrongly(void);
fb->info.screen_base = (char *)bases[1];
__cg14_mmap_sized_wrongly();
/* CG14_VCA_8MB_MASK is not correctly set on the 501-2482 }
* VSIMM, so we read the memory size from the PROM
*/ memcpy(&all->par.mmap_map, &__cg14_mmap_map, sizeof(all->par.mmap_map));
prom_getproperty(fb->prom_node, "reg", (char *) &bases[0], 24); for (i = 0; i < CG14_MMAP_ENTRIES; i++) {
is_8mb = bases[5] == 0x800000; struct sbus_mmap_map *map = &all->par.mmap_map[i];
fb->mmap_map = kmalloc(sizeof(cg14_mmap_map), GFP_KERNEL); if (!map->size)
if (!fb->mmap_map)
return NULL;
for (i = 0; ; i++) {
fb->mmap_map[i].voff = cg14_mmap_map[i].voff;
fb->mmap_map[i].poff = (cg14_mmap_map[i].poff & 0x80000000) ?
(cg14_mmap_map[i].poff & 0x7fffffff) + rphys - phys :
cg14_mmap_map[i].poff;
fb->mmap_map[i].size = cg14_mmap_map[i].size;
if (is_8mb && fb->mmap_map[i].size >= 0x100000 &&
fb->mmap_map[i].size <= 0x400000)
fb->mmap_map[i].size <<= 1;
if (!cg14_mmap_map[i].size)
break; break;
if (map->poff & 0x80000000)
map->poff = (map->poff & 0x7fffffff) + rphys - phys;
if (is_8mb &&
map->size >= 0x100000 &&
map->size <= 0x400000)
map->size *= 2;
} }
strcpy(fb->info.modename, "CGfourteen"); all->par.mode = MDI_8_PIX;
strcpy(fix->id, "CGfourteen"); all->par.ramsize = (is_8mb ? 0x800000 : 0x400000);
fix->line_length = fb->info.var.xres_virtual;
fix->accel = FB_ACCEL_SUN_CG14; all->info.node = NODEV;
all->info.flags = FBINFO_FLAG_DEFAULT;
disp->scrollmode = SCROLL_YREDRAW; all->info.fbops = &cg14_ops;
fb->info.screen_base += fix->line_length * fb->y_margin + fb->x_margin; all->info.currcon = -1;
fb->dispsw = fbcon_cfb8; all->info.par = &all->par;
type->fb_depth = 24; __cg14_reset(&all->par);
fb->emulations[1] = FBTYPE_SUN3COLOR;
if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
fb->margins = cg14_margins; printk(KERN_ERR "cg14: Could not allocate color map.\n");
fb->loadcmap = cg14_loadcmap; kfree(all);
fb->setcursor = cg14_setcursor; return;
fb->setcursormap = cg14_setcursormap; }
fb->setcurshape = cg14_setcurshape;
fb->reset = cg14_reset; cg14_set_par(&all->info);
fb->switch_from_graph = cg14_switch_from_graph; cg14_init_fix(&all->info, linebytes);
fb->ioctl = cg14_ioctl;
if (register_framebuffer(&all->info) < 0) {
fb->s.cg14.mode = 8; printk(KERN_ERR "cg14: Could not register framebuffer.\n");
fb->s.cg14.ramsize = (is_8mb) ? 0x800000 : 0x400000; fb_dealloc_cmap(&all->info.cmap);
kfree(all);
cg14_reset(fb); return;
}
sprintf(idstring, "cgfourteen at %x.%08lx, %dMB, rev=%d, impl=%d", fb->iospace, phys,
is_8mb ? 8 : 4, fb->s.cg14.regs->rev >> 4, fb->s.cg14.regs->rev & 0xf); list_add(&all->list, &cg14_list);
return idstring; printk("cg14: cgfourteen at %lx:%lx\n",
all->par.physbase, all->par.iospace);
} }
int __init cg14_init(void)
{
struct sbus_bus *sbus;
struct sbus_dev *sdev;
#ifdef CONFIG_SPARC32
{
int root, node;
root = prom_getchild(prom_root_node);
root = prom_searchsiblings(root, "obio");
if (root) {
node = prom_searchsiblings(prom_getchild(root),
"cgfourteen");
if (node)
cg14_init_one(NULL, node, root);
}
}
#endif
for_all_sbusdev(sdev, sbus) {
if (!strcmp(sdev->prom_name, "cgfourteen"))
cg14_init_one(sdev, sdev->prom_node, sbus->prom_node);
}
return 0;
}
void __exit cg14_exit(void)
{
struct list_head *pos, *tmp;
list_for_each_safe(pos, tmp, &cg14_list) {
struct all_info *all = list_entry(pos, typeof(*all), list);
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
kfree(all);
}
}
int __init
cg14_setup(char *arg)
{
/* No cmdline options yet... */
return 0;
}
#ifdef MODULE
module_init(cg14_init);
module_exit(cg14_exit);
#endif
MODULE_DESCRIPTION("framebuffer driver for CGfourteen chipsets");
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_LICENSE("GPL");
...@@ -152,6 +152,8 @@ extern int cg3_init(void); ...@@ -152,6 +152,8 @@ extern int cg3_init(void);
extern int cg3_setup(char*); extern int cg3_setup(char*);
extern int bw2_init(void); extern int bw2_init(void);
extern int bw2_setup(char*); extern int bw2_setup(char*);
extern int cg14_init(void);
extern int cg14_setup(char*);
static struct { static struct {
const char *name; const char *name;
...@@ -255,6 +257,9 @@ static struct { ...@@ -255,6 +257,9 @@ static struct {
#ifdef CONFIG_FB_BW2 #ifdef CONFIG_FB_BW2
{ "bw2", bw2_init, bw2_setup }, { "bw2", bw2_init, bw2_setup },
#endif #endif
#ifdef CONFIG_FB_CG14
{ "cg14", cg14_init, cg14_setup },
#endif
/* /*
* Generic drivers that are used as fallbacks * Generic drivers that are used as fallbacks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment