Commit 1ff628c5 authored by Antonino Daplas's avatar Antonino Daplas Committed by Linus Torvalds

[PATCH] sgivwfb: salvage sgivwfb from James' tree

Took code from James' tree to be hopefully included in the mm tree so it
can receive more testing.
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 602c196c
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <asm/mtrr.h> #include <asm/mtrr.h>
#define INCLUDE_TIMING_TABLE_DATA #define INCLUDE_TIMING_TABLE_DATA
#define DBE_REG_BASE default_par.regs #define DBE_REG_BASE par->regs
#include <video/sgivw.h> #include <video/sgivw.h>
struct sgivw_par { struct sgivw_par {
...@@ -44,9 +44,6 @@ struct sgivw_par { ...@@ -44,9 +44,6 @@ struct sgivw_par {
extern unsigned long sgivwfb_mem_phys; extern unsigned long sgivwfb_mem_phys;
extern unsigned long sgivwfb_mem_size; extern unsigned long sgivwfb_mem_size;
static struct sgivw_par default_par;
static u32 pseudo_palette[17];
static struct fb_info fb_info;
static int ypan = 0; static int ypan = 0;
static int ywrap = 0; static int ywrap = 0;
...@@ -162,7 +159,7 @@ static unsigned long get_line_length(int xres_virtual, int bpp) ...@@ -162,7 +159,7 @@ static unsigned long get_line_length(int xres_virtual, int bpp)
* console. * console.
*/ */
static void dbe_TurnOffDma(void) static void dbe_TurnOffDma(struct sgivw_par *par)
{ {
unsigned int readVal; unsigned int readVal;
int i; int i;
...@@ -367,7 +364,7 @@ static int sgivwfb_check_var(struct fb_var_screeninfo *var, ...@@ -367,7 +364,7 @@ static int sgivwfb_check_var(struct fb_var_screeninfo *var,
/* /*
* Setup flatpanel related registers. * Setup flatpanel related registers.
*/ */
static void sgivwfb_setup_flatpanel(struct dbe_timing_info *currentTiming) static void sgivwfb_setup_flatpanel(struct sgivw_par *par, struct dbe_timing_info *currentTiming)
{ {
int fp_wid, fp_hgt, fp_vbs, fp_vbe; int fp_wid, fp_hgt, fp_vbs, fp_vbe;
u32 outputVal = 0; u32 outputVal = 0;
...@@ -429,7 +426,7 @@ static int sgivwfb_set_par(struct fb_info *info) ...@@ -429,7 +426,7 @@ static int sgivwfb_set_par(struct fb_info *info)
/* Turn on dotclock PLL */ /* Turn on dotclock PLL */
DBE_SETREG(ctrlstat, 0x20000000); DBE_SETREG(ctrlstat, 0x20000000);
dbe_TurnOffDma(); dbe_TurnOffDma(par);
/* dbe_CalculateScreenParams(); */ /* dbe_CalculateScreenParams(); */
maxPixelsPerTileX = 512 / bytesPerPixel; maxPixelsPerTileX = 512 / bytesPerPixel;
...@@ -453,7 +450,7 @@ static int sgivwfb_set_par(struct fb_info *info) ...@@ -453,7 +450,7 @@ static int sgivwfb_set_par(struct fb_info *info)
DBE_SETREG(vt_xy, 0x00000000); DBE_SETREG(vt_xy, 0x00000000);
udelay(1); udelay(1);
} else } else
dbe_TurnOffDma(); dbe_TurnOffDma(par);
/* dbe_Initdbe(); */ /* dbe_Initdbe(); */
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
...@@ -567,7 +564,7 @@ static int sgivwfb_set_par(struct fb_info *info) ...@@ -567,7 +564,7 @@ static int sgivwfb_set_par(struct fb_info *info)
DBE_SETREG(vt_hcmap, outputVal); DBE_SETREG(vt_hcmap, outputVal);
if (flatpanel_id != -1) if (flatpanel_id != -1)
sgivwfb_setup_flatpanel(currentTiming); sgivwfb_setup_flatpanel(par, currentTiming);
outputVal = 0; outputVal = 0;
temp = currentTiming->vblank_start - currentTiming->vblank_end - 1; temp = currentTiming->vblank_start - currentTiming->vblank_end - 1;
...@@ -752,16 +749,30 @@ int __init sgivwfb_setup(char *options) ...@@ -752,16 +749,30 @@ int __init sgivwfb_setup(char *options)
/* /*
* Initialisation * Initialisation
*/ */
int __init sgivwfb_init(void) static void sgivwfb_release(struct device *device)
{
}
static int __init sgivwfb_probe(struct device *device)
{ {
struct platform_device *dev = to_platform_device(device);
struct sgivw_par *par;
struct fb_info *info;
char *monitor; char *monitor;
info = framebuffer_alloc(sizeof(struct sgivw_par) + sizeof(u32) * 256, &dev->dev);
if (!info)
return -ENOMEM;
par = info->par;
if (!request_mem_region(DBE_REG_PHYS, DBE_REG_SIZE, "sgivwfb")) { if (!request_mem_region(DBE_REG_PHYS, DBE_REG_SIZE, "sgivwfb")) {
printk(KERN_ERR "sgivwfb: couldn't reserve mmio region\n"); printk(KERN_ERR "sgivwfb: couldn't reserve mmio region\n");
framebuffer_release(info);
return -EBUSY; return -EBUSY;
} }
default_par.regs = (struct asregs *) ioremap_nocache(DBE_REG_PHYS, DBE_REG_SIZE);
if (!default_par.regs) { par->regs = (struct asregs *) ioremap_nocache(DBE_REG_PHYS, DBE_REG_SIZE);
if (!par->regs) {
printk(KERN_ERR "sgivwfb: couldn't ioremap registers\n"); printk(KERN_ERR "sgivwfb: couldn't ioremap registers\n");
goto fail_ioremap_regs; goto fail_ioremap_regs;
} }
...@@ -773,66 +784,110 @@ int __init sgivwfb_init(void) ...@@ -773,66 +784,110 @@ int __init sgivwfb_init(void)
sgivwfb_fix.ywrapstep = ywrap; sgivwfb_fix.ywrapstep = ywrap;
sgivwfb_fix.ypanstep = ypan; sgivwfb_fix.ypanstep = ypan;
fb_info.fix = sgivwfb_fix; info->fix = sgivwfb_fix;
switch (flatpanel_id) { switch (flatpanel_id) {
case FLATPANEL_SGI_1600SW: case FLATPANEL_SGI_1600SW:
fb_info.var = sgivwfb_var1600sw; info->var = sgivwfb_var1600sw;
monitor = "SGI 1600SW flatpanel"; monitor = "SGI 1600SW flatpanel";
break; break;
default: default:
fb_info.var = sgivwfb_var; info->var = sgivwfb_var;
monitor = "CRT"; monitor = "CRT";
} }
printk(KERN_INFO "sgivwfb: %s monitor selected\n", monitor); printk(KERN_INFO "sgivwfb: %s monitor selected\n", monitor);
fb_info.fbops = &sgivwfb_ops; info->fbops = &sgivwfb_ops;
fb_info.pseudo_palette = pseudo_palette; info->pseudo_palette = (void *) (par + 1);
fb_info.par = &default_par; info->flags = FBINFO_DEFAULT;
fb_info.flags = FBINFO_DEFAULT;
fb_info.screen_base = ioremap_nocache((unsigned long) sgivwfb_mem_phys, sgivwfb_mem_size); info->screen_base = ioremap_nocache((unsigned long) sgivwfb_mem_phys, sgivwfb_mem_size);
if (!fb_info.screen_base) { if (!info->screen_base) {
printk(KERN_ERR "sgivwfb: couldn't ioremap screen_base\n"); printk(KERN_ERR "sgivwfb: couldn't ioremap screen_base\n");
goto fail_ioremap_fbmem; goto fail_ioremap_fbmem;
} }
fb_alloc_cmap(&fb_info.cmap, 256, 0); if (fb_alloc_cmap(&info->cmap, 256, 0) < 0)
goto fail_color_map;
if (register_framebuffer(&fb_info) < 0) { if (register_framebuffer(info) < 0) {
printk(KERN_ERR "sgivwfb: couldn't register framebuffer\n"); printk(KERN_ERR "sgivwfb: couldn't register framebuffer\n");
goto fail_register_framebuffer; goto fail_register_framebuffer;
} }
dev_set_drvdata(&dev->dev, info);
printk(KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n", printk(KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n",
fb_info.node, sgivwfb_mem_size >> 10, sgivwfb_mem_phys); info->node, sgivwfb_mem_size >> 10, sgivwfb_mem_phys);
return 0; return 0;
fail_register_framebuffer: fail_register_framebuffer:
iounmap((char *) fb_info.screen_base); fb_dealloc_cmap(&info->cmap);
fail_color_map:
iounmap((char *) info->screen_base);
fail_ioremap_fbmem: fail_ioremap_fbmem:
iounmap(default_par.regs); iounmap(par->regs);
fail_ioremap_regs: fail_ioremap_regs:
release_mem_region(DBE_REG_PHYS, DBE_REG_SIZE); release_mem_region(DBE_REG_PHYS, DBE_REG_SIZE);
framebuffer_release(info);
return -ENXIO; return -ENXIO;
} }
#ifdef MODULE static int sgivwfb_remove(struct device *device)
MODULE_LICENSE("GPL"); {
struct fb_info *info = dev_get_drvdata(device);
if (info) {
struct sgivw_par *par = info->par;
unregister_framebuffer(info);
dbe_TurnOffDma(par);
iounmap(par->regs);
iounmap(info->screen_base);
release_mem_region(DBE_REG_PHYS, DBE_REG_SIZE);
}
return 0;
}
static struct device_driver sgivwfb_driver = {
.name = "sgivwfb",
.bus = &platform_bus_type,
.probe = sgivwfb_probe,
.remove = sgivwfb_remove,
};
int init_module(void) static struct platform_device sgivwfb_device = {
.name = "sgivwfb",
.id = 0,
.dev = {
.release = sgivwfb_release,
}
};
int __init sgivwfb_init(void)
{ {
return sgivwfb_init(); int ret;
ret = driver_register(&sgivwfb_driver);
if (!ret) {
ret = platform_device_register(&sgivwfb_device);
if (ret)
driver_unregister(&sgivwfb_driver);
}
return ret;
} }
void cleanup_module(void) #ifdef MODULE
MODULE_LICENSE("GPL");
static void __exit sgivwfb_exit(void)
{ {
unregister_framebuffer(&fb_info); platform_device_unregister(&sgivwfb_device);
dbe_TurnOffDma(); driver_unregister(&sgivwfb_driver);
iounmap(regs);
iounmap(&fb_info.screen_base);
release_mem_region(DBE_REG_PHYS, DBE_REG_SIZE);
} }
module_init(sgivwfb_init);
module_exit(sgivwfb_exit);
#endif /* MODULE */ #endif /* MODULE */
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