[PATCH] Update platinumfb driver

This updates the PowerMac-only platinumfb driver to use the new mac-io
device infrastructure.  It also switch allocation to the new
framebuffer_alloc/release and fix a couple of bugs.
parent f2d07c25
...@@ -103,6 +103,8 @@ extern int hgafb_setup(char*); ...@@ -103,6 +103,8 @@ extern int hgafb_setup(char*);
extern int matroxfb_init(void); extern int matroxfb_init(void);
extern int matroxfb_setup(char*); extern int matroxfb_setup(char*);
extern int hpfb_init(void); extern int hpfb_init(void);
extern int platinumfb_init(void);
extern int platinumfb_setup(char*);
extern int control_init(void); extern int control_init(void);
extern int control_setup(char*); extern int control_setup(char*);
extern int platinum_init(void); extern int platinum_init(void);
...@@ -230,7 +232,7 @@ static struct { ...@@ -230,7 +232,7 @@ static struct {
{ "controlfb", control_init, control_setup }, { "controlfb", control_init, control_setup },
#endif #endif
#ifdef CONFIG_FB_PLATINUM #ifdef CONFIG_FB_PLATINUM
{ "platinumfb", platinum_init, platinum_setup }, { "platinumfb", platinumfb_init, platinumfb_setup },
#endif #endif
#ifdef CONFIG_FB_VALKYRIE #ifdef CONFIG_FB_VALKYRIE
{ "valkyriefb", valkyriefb_init, valkyriefb_setup }, { "valkyriefb", valkyriefb_init, valkyriefb_setup },
......
...@@ -43,16 +43,13 @@ ...@@ -43,16 +43,13 @@
static int default_vmode = VMODE_NVRAM; static int default_vmode = VMODE_NVRAM;
static int default_cmode = CMODE_NVRAM; static int default_cmode = CMODE_NVRAM;
struct fb_par_platinum {
int vmode, cmode;
int xres, yres;
int vxres, vyres;
int xoffset, yoffset;
};
struct fb_info_platinum { struct fb_info_platinum {
struct fb_info info; struct fb_info *info;
struct fb_par_platinum par;
int vmode, cmode;
int xres, yres;
int vxres, vyres;
int xoffset, yoffset;
struct { struct {
__u8 red, green, blue; __u8 red, green, blue;
...@@ -89,23 +86,19 @@ static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info * ...@@ -89,23 +86,19 @@ static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *
*/ */
static inline int platinum_vram_reqd(int video_mode, int color_mode); static inline int platinum_vram_reqd(int video_mode, int color_mode);
static int read_platinum_sense(struct fb_info_platinum *info); static int read_platinum_sense(struct fb_info_platinum *pinfo);
static void set_platinum_clock(struct fb_info_platinum *info); static void set_platinum_clock(struct fb_info_platinum *pinfo);
static void platinum_set_hardware(struct fb_info_platinum *info, static void platinum_set_hardware(struct fb_info_platinum *pinfo);
const struct fb_par_platinum *par); static int platinum_var_to_par(struct fb_var_screeninfo *var,
static int platinum_par_to_var(struct fb_var_screeninfo *var, struct fb_info_platinum *pinfo,
const struct fb_par_platinum *par, int check_only);
const struct fb_info_platinum *info);
static int platinum_var_to_par(const struct fb_var_screeninfo *var,
struct fb_par_platinum *par,
const struct fb_info_platinum *info);
/* /*
* Interface used by the world * Interface used by the world
*/ */
int platinum_init(void); int platinumfb_init(void);
int platinum_setup(char*); int platinumfb_setup(char*);
static struct fb_ops platinumfb_ops = { static struct fb_ops platinumfb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -124,16 +117,7 @@ static struct fb_ops platinumfb_ops = { ...@@ -124,16 +117,7 @@ static struct fb_ops platinumfb_ops = {
*/ */
static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info) static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info)
{ {
struct fb_info_platinum *p = (struct fb_info_platinum *) info; return platinum_var_to_par(var, info->par, 1);
struct fb_par_platinum par;
int err;
err = platinum_var_to_par(var, &par, p);
if (err)
return err;
platinum_par_to_var(var, &par, p);
return 0;
} }
/* /*
...@@ -141,27 +125,28 @@ static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info * ...@@ -141,27 +125,28 @@ static int platinumfb_check_var (struct fb_var_screeninfo *var, struct fb_info *
*/ */
static int platinumfb_set_par (struct fb_info *info) static int platinumfb_set_par (struct fb_info *info)
{ {
struct fb_info_platinum *p = (struct fb_info_platinum *) info; struct fb_info_platinum *pinfo = info->par;
struct platinum_regvals *init; struct platinum_regvals *init;
struct fb_par_platinum par; int err, offset = 0x20;
int err;
if((err = platinum_var_to_par(&info->var, &par, p))) { if((err = platinum_var_to_par(&info->var, pinfo, 0))) {
printk (KERN_ERR "platinumfb_set_par: error calling" printk (KERN_ERR "platinumfb_set_par: error calling"
" platinum_var_to_par: %d.\n", err); " platinum_var_to_par: %d.\n", err);
return err; return err;
} }
platinum_set_hardware(p, &par); platinum_set_hardware(pinfo);
init = platinum_reg_init[p->par.vmode-1]; init = platinum_reg_init[pinfo->vmode-1];
info->screen_base = (char *) p->frame_buffer + init->fb_offset + 0x20; if (pinfo->vmode == 13 && pinfo->cmode > 0)
info->fix.smem_start = (p->frame_buffer_phys) + init->fb_offset + 0x20; offset = 0x10;
info->fix.visual = (p->par.cmode == CMODE_8) ? info->screen_base = (char *) pinfo->frame_buffer + init->fb_offset + offset;
info->fix.smem_start = (pinfo->frame_buffer_phys) + init->fb_offset + offset;
info->fix.visual = (pinfo->cmode == CMODE_8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
info->fix.line_length = vmode_attrs[p->par.vmode-1].hres * (1<<p->par.cmode) + 0x20; info->fix.line_length = vmode_attrs[pinfo->vmode-1].hres * (1<<pinfo->cmode) + offset;
printk("line_length: %x\n", info->fix.line_length);
return 0; return 0;
} }
...@@ -198,8 +183,8 @@ static int platinumfb_blank(int blank, struct fb_info *fb) ...@@ -198,8 +183,8 @@ static int platinumfb_blank(int blank, struct fb_info *fb)
static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info) u_int transp, struct fb_info *info)
{ {
struct fb_info_platinum *p = (struct fb_info_platinum *) info; struct fb_info_platinum *pinfo = info->par;
volatile struct cmap_regs *cmap_regs = p->cmap_regs; volatile struct cmap_regs *cmap_regs = pinfo->cmap_regs;
if (regno > 255) if (regno > 255)
return 1; return 1;
...@@ -208,9 +193,9 @@ static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -208,9 +193,9 @@ static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
green >>= 8; green >>= 8;
blue >>= 8; blue >>= 8;
p->palette[regno].red = red; pinfo->palette[regno].red = red;
p->palette[regno].green = green; pinfo->palette[regno].green = green;
p->palette[regno].blue = blue; pinfo->palette[regno].blue = blue;
out_8(&cmap_regs->addr, regno); /* tell clut what addr to fill */ out_8(&cmap_regs->addr, regno); /* tell clut what addr to fill */
out_8(&cmap_regs->lut, red); /* send one color channel at */ out_8(&cmap_regs->lut, red); /* send one color channel at */
...@@ -220,7 +205,7 @@ static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -220,7 +205,7 @@ static int platinumfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
if (regno < 16) { if (regno < 16) {
int i; int i;
u32 *pal = info->pseudo_palette; u32 *pal = info->pseudo_palette;
switch (p->par.cmode) { switch (pinfo->cmode) {
case CMODE_16: case CMODE_16:
pal[regno] = (regno << 10) | (regno << 5) | regno; pal[regno] = (regno << 10) | (regno << 5) | regno;
break; break;
...@@ -245,23 +230,23 @@ static inline int platinum_vram_reqd(int video_mode, int color_mode) ...@@ -245,23 +230,23 @@ static inline int platinum_vram_reqd(int video_mode, int color_mode)
out_8(&cmap_regs->d2, (d)); \ out_8(&cmap_regs->d2, (d)); \
} }
static void set_platinum_clock(struct fb_info_platinum *info) static void set_platinum_clock(struct fb_info_platinum *pinfo)
{ {
volatile struct cmap_regs *cmap_regs = info->cmap_regs; volatile struct cmap_regs *cmap_regs = pinfo->cmap_regs;
struct platinum_regvals *init; struct platinum_regvals *init;
init = platinum_reg_init[info->par.vmode-1]; init = platinum_reg_init[pinfo->vmode-1];
STORE_D2(6, 0xc6); STORE_D2(6, 0xc6);
out_8(&cmap_regs->addr,3+32); out_8(&cmap_regs->addr,3+32);
if (in_8(&cmap_regs->d2) == 2) { if (in_8(&cmap_regs->d2) == 2) {
STORE_D2(7, init->clock_params[info->clktype][0]); STORE_D2(7, init->clock_params[pinfo->clktype][0]);
STORE_D2(8, init->clock_params[info->clktype][1]); STORE_D2(8, init->clock_params[pinfo->clktype][1]);
STORE_D2(3, 3); STORE_D2(3, 3);
} else { } else {
STORE_D2(4, init->clock_params[info->clktype][0]); STORE_D2(4, init->clock_params[pinfo->clktype][0]);
STORE_D2(5, init->clock_params[info->clktype][1]); STORE_D2(5, init->clock_params[pinfo->clktype][1]);
STORE_D2(3, 2); STORE_D2(3, 2);
} }
...@@ -272,18 +257,16 @@ static void set_platinum_clock(struct fb_info_platinum *info) ...@@ -272,18 +257,16 @@ static void set_platinum_clock(struct fb_info_platinum *info)
/* Now how about actually saying, Make it so! */ /* Now how about actually saying, Make it so! */
/* Some things in here probably don't need to be done each time. */ /* Some things in here probably don't need to be done each time. */
static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb_par_platinum *par) static void platinum_set_hardware(struct fb_info_platinum *pinfo)
{ {
volatile struct platinum_regs *platinum_regs = info->platinum_regs; volatile struct platinum_regs *platinum_regs = pinfo->platinum_regs;
volatile struct cmap_regs *cmap_regs = info->cmap_regs; volatile struct cmap_regs *cmap_regs = pinfo->cmap_regs;
struct platinum_regvals *init; struct platinum_regvals *init;
int i; int i;
int vmode, cmode; int vmode, cmode;
info->par = *par; vmode = pinfo->vmode;
cmode = pinfo->cmode;
vmode = par->vmode;
cmode = par->cmode;
init = platinum_reg_init[vmode - 1]; init = platinum_reg_init[vmode - 1];
...@@ -293,15 +276,15 @@ static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb ...@@ -293,15 +276,15 @@ static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb
for (i = 0; i < 26; ++i) for (i = 0; i < 26; ++i)
out_be32(&platinum_regs->reg[i+32].r, init->regs[i]); out_be32(&platinum_regs->reg[i+32].r, init->regs[i]);
out_be32(&platinum_regs->reg[26+32].r, (info->total_vram == 0x100000 ? out_be32(&platinum_regs->reg[26+32].r, (pinfo->total_vram == 0x100000 ?
init->offset[cmode] + 4 - cmode : init->offset[cmode] + 4 - cmode :
init->offset[cmode])); init->offset[cmode]));
out_be32(&platinum_regs->reg[16].r, (unsigned) info->frame_buffer_phys+init->fb_offset+0x10); out_be32(&platinum_regs->reg[16].r, (unsigned) pinfo->frame_buffer_phys+init->fb_offset+0x10);
out_be32(&platinum_regs->reg[18].r, init->pitch[cmode]); out_be32(&platinum_regs->reg[18].r, init->pitch[cmode]);
out_be32(&platinum_regs->reg[19].r, (info->total_vram == 0x100000 ? out_be32(&platinum_regs->reg[19].r, (pinfo->total_vram == 0x100000 ?
init->mode[cmode+1] : init->mode[cmode+1] :
init->mode[cmode])); init->mode[cmode]));
out_be32(&platinum_regs->reg[20].r, (info->total_vram == 0x100000 ? 0x11 : 0x1011)); out_be32(&platinum_regs->reg[20].r, (pinfo->total_vram == 0x100000 ? 0x11 : 0x1011));
out_be32(&platinum_regs->reg[21].r, 0x100); out_be32(&platinum_regs->reg[21].r, 0x100);
out_be32(&platinum_regs->reg[22].r, 1); out_be32(&platinum_regs->reg[22].r, 1);
out_be32(&platinum_regs->reg[23].r, 1); out_be32(&platinum_regs->reg[23].r, 1);
...@@ -309,13 +292,13 @@ static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb ...@@ -309,13 +292,13 @@ static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb
out_be32(&platinum_regs->reg[27].r, 0x235); out_be32(&platinum_regs->reg[27].r, 0x235);
/* out_be32(&platinum_regs->reg[27].r, 0x2aa); */ /* out_be32(&platinum_regs->reg[27].r, 0x2aa); */
STORE_D2(0, (info->total_vram == 0x100000 ? STORE_D2(0, (pinfo->total_vram == 0x100000 ?
init->dacula_ctrl[cmode] & 0xf : init->dacula_ctrl[cmode] & 0xf :
init->dacula_ctrl[cmode])); init->dacula_ctrl[cmode]));
STORE_D2(1, 4); STORE_D2(1, 4);
STORE_D2(2, 0); STORE_D2(2, 0);
set_platinum_clock(info); set_platinum_clock(pinfo);
out_be32(&platinum_regs->reg[24].r, 0); /* turn display on */ out_be32(&platinum_regs->reg[24].r, 0); /* turn display on */
} }
...@@ -323,24 +306,23 @@ static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb ...@@ -323,24 +306,23 @@ static void platinum_set_hardware(struct fb_info_platinum *info, const struct fb
/* /*
* Set misc info vars for this driver * Set misc info vars for this driver
*/ */
static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_platinum *p) static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_platinum *pinfo)
{ {
/* Fill fb_info */ /* Fill fb_info */
info->par = &p->par;
info->fbops = &platinumfb_ops; info->fbops = &platinumfb_ops;
info->pseudo_palette = p->pseudo_palette; info->pseudo_palette = pinfo->pseudo_palette;
info->flags = FBINFO_FLAG_DEFAULT; info->flags = FBINFO_FLAG_DEFAULT;
info->screen_base = (char *) p->frame_buffer + 0x20; info->screen_base = (char *) pinfo->frame_buffer + 0x20;
fb_alloc_cmap(&info->cmap, 256, 0); fb_alloc_cmap(&info->cmap, 256, 0);
/* Fill fix common fields */ /* Fill fix common fields */
strcpy(info->fix.id, "platinum"); strcpy(info->fix.id, "platinum");
info->fix.mmio_start = p->platinum_regs_phys; info->fix.mmio_start = pinfo->platinum_regs_phys;
info->fix.mmio_len = 0x1000; info->fix.mmio_len = 0x1000;
info->fix.type = FB_TYPE_PACKED_PIXELS; info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.smem_start = p->frame_buffer_phys + 0x20; /* will be updated later */ info->fix.smem_start = pinfo->frame_buffer_phys + 0x20; /* will be updated later */
info->fix.smem_len = p->total_vram - 0x20; info->fix.smem_len = pinfo->total_vram - 0x20;
info->fix.ywrapstep = 0; info->fix.ywrapstep = 0;
info->fix.xpanstep = 0; info->fix.xpanstep = 0;
info->fix.ypanstep = 0; info->fix.ypanstep = 0;
...@@ -349,13 +331,14 @@ static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_pl ...@@ -349,13 +331,14 @@ static void __devinit platinum_init_info(struct fb_info *info, struct fb_info_pl
} }
static int __devinit platinum_init_fb(struct fb_info_platinum *p) static int __devinit platinum_init_fb(struct fb_info *info)
{ {
struct fb_info_platinum *pinfo = info->par;
struct fb_var_screeninfo var; struct fb_var_screeninfo var;
int sense, rc; int sense, rc;
sense = read_platinum_sense(p); sense = read_platinum_sense(pinfo);
printk(KERN_INFO "Monitor sense value = 0x%x, ", sense); printk(KERN_INFO "platinumfb: Monitor sense value = 0x%x, ", sense);
if (default_vmode == VMODE_NVRAM) { if (default_vmode == VMODE_NVRAM) {
default_vmode = nvram_read_byte(NV_VMODE); default_vmode = nvram_read_byte(NV_VMODE);
...@@ -375,10 +358,11 @@ static int __devinit platinum_init_fb(struct fb_info_platinum *p) ...@@ -375,10 +358,11 @@ static int __devinit platinum_init_fb(struct fb_info_platinum *p)
/* /*
* Reduce the pixel size if we don't have enough VRAM. * Reduce the pixel size if we don't have enough VRAM.
*/ */
while(default_cmode > CMODE_8 && platinum_vram_reqd(default_vmode, default_cmode) > p->total_vram) while(default_cmode > CMODE_8 &&
platinum_vram_reqd(default_vmode, default_cmode) > pinfo->total_vram)
default_cmode--; default_cmode--;
printk("using video mode %d and color mode %d.\n", default_vmode, default_cmode); printk("platinumfb: Using video mode %d and color mode %d.\n", default_vmode, default_cmode);
/* Setup default var */ /* Setup default var */
if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) { if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) {
...@@ -394,22 +378,21 @@ static int __devinit platinum_init_fb(struct fb_info_platinum *p) ...@@ -394,22 +378,21 @@ static int __devinit platinum_init_fb(struct fb_info_platinum *p)
} }
/* Initialize info structure */ /* Initialize info structure */
platinum_init_info(&p->info, p); platinum_init_info(info, pinfo);
/* Apply default var */ /* Apply default var */
p->info.var = var; info->var = var;
var.activate = FB_ACTIVATE_NOW; var.activate = FB_ACTIVATE_NOW;
rc = fb_set_var(&p->info, &var); rc = fb_set_var(info, &var);
if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8)) if (rc && (default_vmode != VMODE_640_480_60 || default_cmode != CMODE_8))
goto try_again; goto try_again;
/* Register with fbdev layer */ /* Register with fbdev layer */
rc = register_framebuffer(&p->info); rc = register_framebuffer(info);
if (rc < 0) if (rc < 0)
return rc; return rc;
printk(KERN_INFO "fb%d: platinum frame buffer device\n", printk(KERN_INFO "fb%d: Apple Platinum frame buffer device\n", info->node);
p->info.node);
return 0; return 0;
} }
...@@ -445,12 +428,17 @@ static int read_platinum_sense(struct fb_info_platinum *info) ...@@ -445,12 +428,17 @@ static int read_platinum_sense(struct fb_info_platinum *info)
return sense; return sense;
} }
/* This routine takes a user-supplied var, and picks the best vmode/cmode from it. */ /*
static int platinum_var_to_par(const struct fb_var_screeninfo *var, * This routine takes a user-supplied var, and picks the best vmode/cmode from it.
struct fb_par_platinum *par, * It also updates the var structure to the actual mode data obtained
const struct fb_info_platinum *info) */
static int platinum_var_to_par(struct fb_var_screeninfo *var,
struct fb_info_platinum *pinfo,
int check_only)
{ {
if(mac_var_to_vmode(var, &par->vmode, &par->cmode) != 0) { int vmode, cmode;
if (mac_var_to_vmode(var, &vmode, &cmode) != 0) {
printk(KERN_ERR "platinum_var_to_par: mac_var_to_vmode unsuccessful.\n"); printk(KERN_ERR "platinum_var_to_par: mac_var_to_vmode unsuccessful.\n");
printk(KERN_ERR "platinum_var_to_par: var->xres = %d\n", var->xres); printk(KERN_ERR "platinum_var_to_par: var->xres = %d\n", var->xres);
printk(KERN_ERR "platinum_var_to_par: var->yres = %d\n", var->yres); printk(KERN_ERR "platinum_var_to_par: var->yres = %d\n", var->yres);
...@@ -462,37 +450,39 @@ static int platinum_var_to_par(const struct fb_var_screeninfo *var, ...@@ -462,37 +450,39 @@ static int platinum_var_to_par(const struct fb_var_screeninfo *var,
return -EINVAL; return -EINVAL;
} }
if(!platinum_reg_init[par->vmode-1]) { if (!platinum_reg_init[vmode-1]) {
printk(KERN_ERR "platinum_var_to_par, vmode %d not valid.\n", par->vmode); printk(KERN_ERR "platinum_var_to_par, vmode %d not valid.\n", vmode);
return -EINVAL; return -EINVAL;
} }
if (platinum_vram_reqd(par->vmode, par->cmode) > info->total_vram) { if (platinum_vram_reqd(vmode, cmode) > pinfo->total_vram) {
printk(KERN_ERR "platinum_var_to_par, not enough ram for vmode %d, cmode %d.\n", par->vmode, par->cmode); printk(KERN_ERR "platinum_var_to_par, not enough ram for vmode %d, cmode %d.\n", vmode, cmode);
return -EINVAL; return -EINVAL;
} }
par->xres = vmode_attrs[par->vmode-1].hres; if (mac_vmode_to_var(vmode, cmode, var))
par->yres = vmode_attrs[par->vmode-1].vres; return -EINVAL;
par->xoffset = 0;
par->yoffset = 0; if (check_only)
par->vxres = par->xres; return 0;
par->vyres = par->yres;
pinfo->vmode = vmode;
pinfo->cmode = cmode;
pinfo->xres = vmode_attrs[vmode-1].hres;
pinfo->yres = vmode_attrs[vmode-1].vres;
pinfo->xoffset = 0;
pinfo->yoffset = 0;
pinfo->vxres = pinfo->xres;
pinfo->vyres = pinfo->yres;
return 0; return 0;
} }
static int platinum_par_to_var(struct fb_var_screeninfo *var,
const struct fb_par_platinum *par,
const struct fb_info_platinum *info)
{
return mac_vmode_to_var(par->vmode, par->cmode, var);
}
/* /*
* Parse user speficied options (`video=platinumfb:') * Parse user speficied options (`video=platinumfb:')
*/ */
int __init platinum_setup(char *options) int __init platinumfb_setup(char *options)
{ {
char *this_opt; char *this_opt;
...@@ -536,7 +526,8 @@ int __init platinum_setup(char *options) ...@@ -536,7 +526,8 @@ int __init platinum_setup(char *options)
static int __devinit platinumfb_probe(struct of_device* odev, const struct of_match *match) static int __devinit platinumfb_probe(struct of_device* odev, const struct of_match *match)
{ {
struct device_node *dp = odev->node; struct device_node *dp = odev->node;
struct fb_info_platinum *info; struct fb_info *info;
struct fb_info_platinum *pinfo;
unsigned long addr, size; unsigned long addr, size;
volatile __u8 *fbuffer; volatile __u8 *fbuffer;
int i, bank0, bank1, bank2, bank3, rc; int i, bank0, bank1, bank2, bank3, rc;
...@@ -545,11 +536,12 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma ...@@ -545,11 +536,12 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma
printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs); printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
return -ENXIO; return -ENXIO;
} }
printk(KERN_INFO "platinumfb: Found Apple Platinum video hardware\n");
info = kmalloc(sizeof(*info), GFP_ATOMIC); info = framebuffer_alloc(sizeof(*pinfo), &odev->dev);
if (info == 0) if (info == NULL)
return -ENOMEM; return -ENOMEM;
memset(info, 0, sizeof(*info)); pinfo = info->par;
/* Map in frame buffer and registers */ /* Map in frame buffer and registers */
for (i = 0; i < dp->n_addrs; ++i) { for (i = 0; i < dp->n_addrs; ++i) {
...@@ -557,31 +549,31 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma ...@@ -557,31 +549,31 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma
size = dp->addrs[i].size; size = dp->addrs[i].size;
/* Let's assume we can request either all or nothing */ /* Let's assume we can request either all or nothing */
if (!request_mem_region(addr, size, "platinumfb")) { if (!request_mem_region(addr, size, "platinumfb")) {
kfree(info); framebuffer_release(info);
return -ENXIO; return -ENXIO;
} }
if (size >= 0x400000) { if (size >= 0x400000) {
/* frame buffer - map only 4MB */ /* frame buffer - map only 4MB */
info->frame_buffer_phys = addr; pinfo->frame_buffer_phys = addr;
info->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU); pinfo->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
info->base_frame_buffer = info->frame_buffer; pinfo->base_frame_buffer = pinfo->frame_buffer;
} else { } else {
/* registers */ /* registers */
info->platinum_regs_phys = addr; pinfo->platinum_regs_phys = addr;
info->platinum_regs = ioremap(addr, size); pinfo->platinum_regs = ioremap(addr, size);
} }
} }
info->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */ pinfo->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */
request_mem_region(info->cmap_regs_phys, 0x1000, "platinumfb cmap"); request_mem_region(pinfo->cmap_regs_phys, 0x1000, "platinumfb cmap");
info->cmap_regs = ioremap(info->cmap_regs_phys, 0x1000); pinfo->cmap_regs = ioremap(pinfo->cmap_regs_phys, 0x1000);
/* Grok total video ram */ /* Grok total video ram */
out_be32(&info->platinum_regs->reg[16].r, (unsigned)info->frame_buffer_phys); out_be32(&pinfo->platinum_regs->reg[16].r, (unsigned)pinfo->frame_buffer_phys);
out_be32(&info->platinum_regs->reg[20].r, 0x1011); /* select max vram */ out_be32(&pinfo->platinum_regs->reg[20].r, 0x1011); /* select max vram */
out_be32(&info->platinum_regs->reg[24].r, 0); /* switch in vram */ out_be32(&pinfo->platinum_regs->reg[24].r, 0); /* switch in vram */
fbuffer = info->base_frame_buffer; fbuffer = pinfo->base_frame_buffer;
fbuffer[0x100000] = 0x34; fbuffer[0x100000] = 0x34;
fbuffer[0x100008] = 0x0; fbuffer[0x100008] = 0x0;
invalidate_cache(&fbuffer[0x100000]); invalidate_cache(&fbuffer[0x100000]);
...@@ -595,24 +587,27 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma ...@@ -595,24 +587,27 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma
bank1 = fbuffer[0x100000] == 0x34; bank1 = fbuffer[0x100000] == 0x34;
bank2 = fbuffer[0x200000] == 0x56; bank2 = fbuffer[0x200000] == 0x56;
bank3 = fbuffer[0x300000] == 0x78; bank3 = fbuffer[0x300000] == 0x78;
info->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000; pinfo->total_vram = (bank0 + bank1 + bank2 + bank3) * 0x100000;
printk(KERN_INFO "Total VRAM = %dMB %d%d%d%d\n", (int) (info->total_vram / 1024 / 1024), bank3, bank2, bank1, bank0); printk(KERN_INFO "platinumfb: Total VRAM = %dMB (%d%d%d%d)\n", (int) (pinfo->total_vram / 1024 / 1024),
bank3, bank2, bank1, bank0);
/* /*
* Try to determine whether we have an old or a new DACula. * Try to determine whether we have an old or a new DACula.
*/ */
out_8(&info->cmap_regs->addr, 0x40); out_8(&pinfo->cmap_regs->addr, 0x40);
info->dactype = in_8(&info->cmap_regs->d2); pinfo->dactype = in_8(&pinfo->cmap_regs->d2);
switch (info->dactype) { switch (pinfo->dactype) {
case 0x3c: case 0x3c:
info->clktype = 1; pinfo->clktype = 1;
printk(KERN_INFO "platinumfb: DACula type 0x3c\n");
break; break;
case 0x84: case 0x84:
info->clktype = 0; pinfo->clktype = 0;
printk(KERN_INFO "platinumfb: DACula type 0x84\n");
break; break;
default: default:
info->clktype = 0; pinfo->clktype = 0;
printk(KERN_INFO "Unknown DACula type: %x\n", info->dactype); printk(KERN_INFO "platinumfb: Unknown DACula type: %x\n", pinfo->dactype);
break; break;
} }
dev_set_drvdata(&odev->dev, info); dev_set_drvdata(&odev->dev, info);
...@@ -620,7 +615,7 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma ...@@ -620,7 +615,7 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma
rc = platinum_init_fb(info); rc = platinum_init_fb(info);
if (rc != 0) { if (rc != 0) {
dev_set_drvdata(&odev->dev, NULL); dev_set_drvdata(&odev->dev, NULL);
kfree(info); framebuffer_release(info);
} }
return rc; return rc;
...@@ -628,15 +623,13 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma ...@@ -628,15 +623,13 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_ma
static int __devexit platinumfb_remove(struct of_device* odev) static int __devexit platinumfb_remove(struct of_device* odev)
{ {
struct fb_info_platinum *pinfo = dev_get_drvdata(&odev->dev); struct fb_info *info = dev_get_drvdata(&odev->dev);
struct fb_info_platinum *pinfo = info->par;
struct device_node *dp = odev->node; struct device_node *dp = odev->node;
unsigned long addr, size; unsigned long addr, size;
int i; int i;
if (!pinfo) unregister_framebuffer (info);
return 0;
unregister_framebuffer (&pinfo->info);
/* Unmap frame buffer and registers */ /* Unmap frame buffer and registers */
for (i = 0; i < dp->n_addrs; ++i) { for (i = 0; i < dp->n_addrs; ++i) {
...@@ -649,7 +642,7 @@ static int __devexit platinumfb_remove(struct of_device* odev) ...@@ -649,7 +642,7 @@ static int __devexit platinumfb_remove(struct of_device* odev)
release_mem_region(pinfo->cmap_regs_phys, 0x1000); release_mem_region(pinfo->cmap_regs_phys, 0x1000);
iounmap((void *)pinfo->cmap_regs); iounmap((void *)pinfo->cmap_regs);
kfree(pinfo); framebuffer_release(info);
return 0; return 0;
} }
...@@ -672,14 +665,14 @@ static struct of_platform_driver platinum_driver = ...@@ -672,14 +665,14 @@ static struct of_platform_driver platinum_driver =
.remove = platinumfb_remove, .remove = platinumfb_remove,
}; };
int __init platinum_init(void) int __init platinumfb_init(void)
{ {
of_register_driver(&platinum_driver); of_register_driver(&platinum_driver);
return 0; return 0;
} }
void __exit platinum_exit(void) void __exit platinumfb_exit(void)
{ {
of_unregister_driver(&platinum_driver); of_unregister_driver(&platinum_driver);
} }
...@@ -688,6 +681,6 @@ MODULE_LICENSE("GPL"); ...@@ -688,6 +681,6 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("framebuffer driver for Apple Platinum video"); MODULE_DESCRIPTION("framebuffer driver for Apple Platinum video");
#ifdef MODULE #ifdef MODULE
module_init(platinum_init); module_init(platinumfb_init);
module_exit(platinum_exit); module_exit(platinumfb_exit);
#endif #endif
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