Commit 50312ce9 authored by David S. Miller's avatar David S. Miller Committed by David S. Miller

[SPARC]: Convert all FB SBUS drivers to of_driver framework.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3ca9fab4
/* bw2.c: BWTWO frame buffer driver
*
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
* Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net)
* Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
* Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
* Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
......@@ -19,14 +19,11 @@
#include <linux/mm.h>
#include <asm/io.h>
#include <asm/sbus.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/of_device.h>
#include <asm/fbio.h>
#ifdef CONFIG_SPARC32
#include <asm/sun4paddr.h>
#endif
#include "sbuslib.h"
/*
......@@ -59,30 +56,30 @@ static struct fb_ops bw2_ops = {
#define BWTWO_REGISTER_OFFSET 0x400000
struct bt_regs {
volatile u32 addr;
volatile u32 color_map;
volatile u32 control;
volatile u32 cursor;
u32 addr;
u32 color_map;
u32 control;
u32 cursor;
};
struct bw2_regs {
struct bt_regs cmap;
volatile u8 control;
volatile u8 status;
volatile u8 cursor_start;
volatile u8 cursor_end;
volatile u8 h_blank_start;
volatile u8 h_blank_end;
volatile u8 h_sync_start;
volatile u8 h_sync_end;
volatile u8 comp_sync_end;
volatile u8 v_blank_start_high;
volatile u8 v_blank_start_low;
volatile u8 v_blank_end;
volatile u8 v_sync_start;
volatile u8 v_sync_end;
volatile u8 xfer_holdoff_start;
volatile u8 xfer_holdoff_end;
u8 control;
u8 status;
u8 cursor_start;
u8 cursor_end;
u8 h_blank_start;
u8 h_blank_end;
u8 h_sync_start;
u8 h_sync_end;
u8 comp_sync_end;
u8 v_blank_start_high;
u8 v_blank_start_low;
u8 v_blank_end;
u8 v_sync_start;
u8 v_sync_end;
u8 xfer_holdoff_start;
u8 xfer_holdoff_end;
};
/* Status Register Constants */
......@@ -117,9 +114,8 @@ struct bw2_par {
#define BW2_FLAG_BLANKED 0x00000001
unsigned long physbase;
unsigned long which_io;
unsigned long fbsize;
struct sbus_dev *sdev;
};
/**
......@@ -174,9 +170,7 @@ static int bw2_mmap(struct fb_info *info, struct vm_area_struct *vma)
return sbusfb_mmap_helper(bw2_mmap_map,
par->physbase, par->fbsize,
(par->sdev ?
par->sdev->reg_addrs[0].which_io :
0),
par->which_io,
vma);
}
......@@ -288,139 +282,124 @@ static void bw2_do_default_mode(struct bw2_par *par, struct fb_info *info,
struct all_info {
struct fb_info info;
struct bw2_par par;
struct list_head list;
};
static LIST_HEAD(bw2_list);
static void bw2_init_one(struct sbus_dev *sdev)
static int __devinit bw2_init_one(struct of_device *op)
{
struct device_node *dp = op->node;
struct all_info *all;
struct resource *resp;
#ifdef CONFIG_SUN4
struct resource res;
#endif
int linebytes;
int linebytes, err;
all = kmalloc(sizeof(*all), GFP_KERNEL);
if (!all) {
printk(KERN_ERR "bw2: Cannot allocate memory.\n");
return;
}
memset(all, 0, sizeof(*all));
INIT_LIST_HEAD(&all->list);
all = kzalloc(sizeof(*all), GFP_KERNEL);
if (!all)
return -ENOMEM;
spin_lock_init(&all->par.lock);
all->par.sdev = sdev;
#ifdef CONFIG_SUN4
if (!sdev) {
all->par.physbase = sun4_bwtwo_physaddr;
res.start = sun4_bwtwo_physaddr;
res.end = res.start + BWTWO_REGISTER_OFFSET + sizeof(struct bw2_regs) - 1;
res.flags = IORESOURCE_IO;
resp = &res;
all->info.var.xres = all->info.var.xres_virtual = 1152;
all->info.var.yres = all->info.var.yres_virtual = 900;
all->info.var.bits_per_pixel = 1;
linebytes = 1152 / 8;
} else
#else
{
BUG_ON(!sdev);
all->par.physbase = sdev->reg_addrs[0].phys_addr;
resp = &sdev->resource[0];
sbusfb_fill_var(&all->info.var, (sdev ? sdev->prom_node : 0), 1);
linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
all->info.var.xres);
}
#endif
all->par.physbase = op->resource[0].start;
all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
sbusfb_fill_var(&all->info.var, dp->node, 1);
linebytes = of_getintprop_default(dp, "linebytes",
all->info.var.xres);
all->info.var.red.length = all->info.var.green.length =
all->info.var.blue.length = all->info.var.bits_per_pixel;
all->info.var.red.offset = all->info.var.green.offset =
all->info.var.blue.offset = 0;
all->par.regs = sbus_ioremap(resp, BWTWO_REGISTER_OFFSET,
sizeof(struct bw2_regs), "bw2 regs");
all->par.regs = of_ioremap(&op->resource[0], BWTWO_REGISTER_OFFSET,
sizeof(struct bw2_regs), "bw2 regs");
if (sdev && !prom_getbool(sdev->prom_node, "width"))
if (!of_find_property(dp, "width", NULL))
bw2_do_default_mode(&all->par, &all->info, &linebytes);
all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
all->info.flags = FBINFO_DEFAULT;
all->info.fbops = &bw2_ops;
#if defined(CONFIG_SPARC32)
if (sdev)
all->info.screen_base = (char __iomem *)
prom_getintdefault(sdev->prom_node, "address", 0);
#endif
if (!all->info.screen_base)
all->info.screen_base =
sbus_ioremap(resp, 0, all->par.fbsize, "bw2 ram");
all->info.screen_base =
sbus_ioremap(&op->resource[0], 0, all->par.fbsize, "bw2 ram");
all->info.par = &all->par;
bw2_blank(0, &all->info);
bw2_init_fix(&all->info, linebytes);
if (register_framebuffer(&all->info) < 0) {
printk(KERN_ERR "bw2: Could not register framebuffer.\n");
err= register_framebuffer(&all->info);
if (err < 0) {
of_iounmap(all->par.regs, sizeof(struct bw2_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
return;
return err;
}
list_add(&all->list, &bw2_list);
dev_set_drvdata(&op->dev, all);
printk("%s: bwtwo at %lx:%lx\n",
dp->full_name,
all->par.which_io, all->par.physbase);
printk("bw2: bwtwo at %lx:%lx\n",
(long) (sdev ? sdev->reg_addrs[0].which_io : 0),
(long) all->par.physbase);
return 0;
}
int __init bw2_init(void)
static int __devinit bw2_probe(struct of_device *dev, const struct of_device_id *match)
{
struct sbus_bus *sbus;
struct sbus_dev *sdev;
struct of_device *op = to_of_device(&dev->dev);
if (fb_get_options("bw2fb", NULL))
return -ENODEV;
return bw2_init_one(op);
}
#ifdef CONFIG_SUN4
bw2_init_one(NULL);
#endif
for_all_sbusdev(sdev, sbus) {
if (!strcmp(sdev->prom_name, "bwtwo"))
bw2_init_one(sdev);
}
static int __devexit bw2_remove(struct of_device *dev)
{
struct all_info *all = dev_get_drvdata(&dev->dev);
unregister_framebuffer(&all->info);
of_iounmap(all->par.regs, sizeof(struct bw2_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
dev_set_drvdata(&dev->dev, NULL);
return 0;
}
void __exit bw2_exit(void)
{
struct list_head *pos, *tmp;
static struct of_device_id bw2_match[] = {
{
.name = "bwtwo",
},
{},
};
MODULE_DEVICE_TABLE(of, bw2_match);
list_for_each_safe(pos, tmp, &bw2_list) {
struct all_info *all = list_entry(pos, typeof(*all), list);
static struct of_platform_driver bw2_driver = {
.name = "bw2",
.match_table = bw2_match,
.probe = bw2_probe,
.remove = __devexit_p(bw2_remove),
};
unregister_framebuffer(&all->info);
kfree(all);
}
static int __init bw2_init(void)
{
if (fb_get_options("bw2fb", NULL))
return -ENODEV;
return of_register_driver(&bw2_driver, &of_bus_type);
}
int __init
bw2_setup(char *arg)
static void __exit bw2_exit(void)
{
/* No cmdline options yet... */
return 0;
return of_unregister_driver(&bw2_driver);
}
module_init(bw2_init);
#ifdef MODULE
module_init(bw2_init);
module_exit(bw2_exit);
#endif
MODULE_DESCRIPTION("framebuffer driver for BWTWO chipsets");
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
MODULE_VERSION("2.0");
MODULE_LICENSE("GPL");
This diff is collapsed.
/* cg3.c: CGTHREE frame buffer driver
*
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
* Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net)
* Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
* Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
* Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
......@@ -19,8 +19,9 @@
#include <linux/mm.h>
#include <asm/io.h>
#include <asm/sbus.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/of_device.h>
#include <asm/fbio.h>
#include "sbuslib.h"
......@@ -80,30 +81,30 @@ enum cg3_type {
};
struct bt_regs {
volatile u32 addr;
volatile u32 color_map;
volatile u32 control;
volatile u32 cursor;
u32 addr;
u32 color_map;
u32 control;
u32 cursor;
};
struct cg3_regs {
struct bt_regs cmap;
volatile u8 control;
volatile u8 status;
volatile u8 cursor_start;
volatile u8 cursor_end;
volatile u8 h_blank_start;
volatile u8 h_blank_end;
volatile u8 h_sync_start;
volatile u8 h_sync_end;
volatile u8 comp_sync_end;
volatile u8 v_blank_start_high;
volatile u8 v_blank_start_low;
volatile u8 v_blank_end;
volatile u8 v_sync_start;
volatile u8 v_sync_end;
volatile u8 xfer_holdoff_start;
volatile u8 xfer_holdoff_end;
u8 control;
u8 status;
u8 cursor_start;
u8 cursor_end;
u8 h_blank_start;
u8 h_blank_end;
u8 h_sync_start;
u8 h_sync_end;
u8 comp_sync_end;
u8 v_blank_start_high;
u8 v_blank_start_low;
u8 v_blank_end;
u8 v_sync_start;
u8 v_sync_end;
u8 xfer_holdoff_start;
u8 xfer_holdoff_end;
};
/* Offset of interesting structures in the OBIO space */
......@@ -120,9 +121,8 @@ struct cg3_par {
#define CG3_FLAG_RDI 0x00000002
unsigned long physbase;
unsigned long which_io;
unsigned long fbsize;
struct sbus_dev *sdev;
};
/**
......@@ -235,7 +235,7 @@ static int cg3_mmap(struct fb_info *info, struct vm_area_struct *vma)
return sbusfb_mmap_helper(cg3_mmap_map,
par->physbase, par->fbsize,
par->sdev->reg_addrs[0].which_io,
par->which_io,
vma);
}
......@@ -252,11 +252,9 @@ static int cg3_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
*/
static void
cg3_init_fix(struct fb_info *info, int linebytes)
cg3_init_fix(struct fb_info *info, int linebytes, struct device_node *dp)
{
struct cg3_par *par = (struct cg3_par *)info->par;
strlcpy(info->fix.id, par->sdev->prom_name, sizeof(info->fix.id));
strlcpy(info->fix.id, dp->name, sizeof(info->fix.id));
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
......@@ -267,16 +265,15 @@ cg3_init_fix(struct fb_info *info, int linebytes)
}
static void cg3_rdi_maybe_fixup_var(struct fb_var_screeninfo *var,
struct sbus_dev *sdev)
struct device_node *dp)
{
char buffer[40];
char *params;
char *p;
int ww, hh;
*buffer = 0;
prom_getstring(sdev->prom_node, "params", buffer, sizeof(buffer));
if (*buffer) {
ww = simple_strtoul(buffer, &p, 10);
params = of_get_property(dp, "params", NULL);
if (params) {
ww = simple_strtoul(params, &p, 10);
if (ww && *p == 'x') {
hh = simple_strtoul(p + 1, &p, 10);
if (hh && *p == '-') {
......@@ -348,11 +345,11 @@ static void cg3_do_default_mode(struct cg3_par *par)
sbus_writeb(p[1], regp);
}
for (p = cg3_dacvals; *p; p += 2) {
volatile u8 __iomem *regp;
u8 __iomem *regp;
regp = (volatile u8 __iomem *)&par->regs->cmap.addr;
regp = (u8 __iomem *)&par->regs->cmap.addr;
sbus_writeb(p[0], regp);
regp = (volatile u8 __iomem *)&par->regs->cmap.control;
regp = (u8 __iomem *)&par->regs->cmap.control;
sbus_writeb(p[1], regp);
}
}
......@@ -360,129 +357,137 @@ static void cg3_do_default_mode(struct cg3_par *par)
struct all_info {
struct fb_info info;
struct cg3_par par;
struct list_head list;
};
static LIST_HEAD(cg3_list);
static void cg3_init_one(struct sbus_dev *sdev)
static int __devinit cg3_init_one(struct of_device *op)
{
struct device_node *dp = op->node;
struct all_info *all;
int linebytes;
all = kmalloc(sizeof(*all), GFP_KERNEL);
if (!all) {
printk(KERN_ERR "cg3: Cannot allocate memory.\n");
return;
}
memset(all, 0, sizeof(*all));
int linebytes, err;
INIT_LIST_HEAD(&all->list);
all = kzalloc(sizeof(*all), GFP_KERNEL);
if (!all)
return -ENOMEM;
spin_lock_init(&all->par.lock);
all->par.sdev = sdev;
all->par.physbase = sdev->reg_addrs[0].phys_addr;
all->par.physbase = op->resource[0].start;
all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
sbusfb_fill_var(&all->info.var, dp->node, 8);
all->info.var.red.length = 8;
all->info.var.green.length = 8;
all->info.var.blue.length = 8;
if (!strcmp(sdev->prom_name, "cgRDI"))
if (!strcmp(dp->name, "cgRDI"))
all->par.flags |= CG3_FLAG_RDI;
if (all->par.flags & CG3_FLAG_RDI)
cg3_rdi_maybe_fixup_var(&all->info.var, sdev);
cg3_rdi_maybe_fixup_var(&all->info.var, dp);
linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
all->info.var.xres);
linebytes = of_getintprop_default(dp, "linebytes",
all->info.var.xres);
all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
all->par.regs = sbus_ioremap(&sdev->resource[0], CG3_REGS_OFFSET,
sizeof(struct cg3_regs), "cg3 regs");
all->par.regs = of_ioremap(&op->resource[0], CG3_REGS_OFFSET,
sizeof(struct cg3_regs), "cg3 regs");
all->info.flags = FBINFO_DEFAULT;
all->info.fbops = &cg3_ops;
#ifdef CONFIG_SPARC32
all->info.screen_base = (char __iomem *)
prom_getintdefault(sdev->prom_node, "address", 0);
#endif
if (!all->info.screen_base)
all->info.screen_base =
sbus_ioremap(&sdev->resource[0], CG3_RAM_OFFSET,
all->par.fbsize, "cg3 ram");
all->info.screen_base =
of_ioremap(&op->resource[0], CG3_RAM_OFFSET,
all->par.fbsize, "cg3 ram");
all->info.par = &all->par;
cg3_blank(0, &all->info);
if (!prom_getbool(sdev->prom_node, "width"))
if (!of_find_property(dp, "width", NULL))
cg3_do_default_mode(&all->par);
if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
printk(KERN_ERR "cg3: Could not allocate color map.\n");
of_iounmap(all->par.regs, sizeof(struct cg3_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
return;
return -ENOMEM;
}
fb_set_cmap(&all->info.cmap, &all->info);
cg3_init_fix(&all->info, linebytes);
cg3_init_fix(&all->info, linebytes, dp);
if (register_framebuffer(&all->info) < 0) {
printk(KERN_ERR "cg3: Could not register framebuffer.\n");
err = register_framebuffer(&all->info);
if (err < 0) {
fb_dealloc_cmap(&all->info.cmap);
of_iounmap(all->par.regs, sizeof(struct cg3_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
return;
return err;
}
list_add(&all->list, &cg3_list);
dev_set_drvdata(&op->dev, all);
printk("%s: cg3 at %lx:%lx\n",
dp->full_name, all->par.which_io, all->par.physbase);
printk("cg3: %s at %lx:%lx\n",
sdev->prom_name,
(long) sdev->reg_addrs[0].which_io,
(long) sdev->reg_addrs[0].phys_addr);
return 0;
}
int __init cg3_init(void)
static int __devinit cg3_probe(struct of_device *dev, const struct of_device_id *match)
{
struct sbus_bus *sbus;
struct sbus_dev *sdev;
struct of_device *op = to_of_device(&dev->dev);
if (fb_get_options("cg3fb", NULL))
return -ENODEV;
return cg3_init_one(op);
}
for_all_sbusdev(sdev, sbus) {
if (!strcmp(sdev->prom_name, "cgthree") ||
!strcmp(sdev->prom_name, "cgRDI"))
cg3_init_one(sdev);
}
static int __devexit cg3_remove(struct of_device *dev)
{
struct all_info *all = dev_get_drvdata(&dev->dev);
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
of_iounmap(all->par.regs, sizeof(struct cg3_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
dev_set_drvdata(&dev->dev, NULL);
return 0;
}
void __exit cg3_exit(void)
{
struct list_head *pos, *tmp;
static struct of_device_id cg3_match[] = {
{
.name = "cgthree",
},
{
.name = "cgRDI",
},
{},
};
MODULE_DEVICE_TABLE(of, cg3_match);
list_for_each_safe(pos, tmp, &cg3_list) {
struct all_info *all = list_entry(pos, typeof(*all), list);
static struct of_platform_driver cg3_driver = {
.name = "cg3",
.match_table = cg3_match,
.probe = cg3_probe,
.remove = __devexit_p(cg3_remove),
};
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
kfree(all);
}
static int __init cg3_init(void)
{
if (fb_get_options("cg3fb", NULL))
return -ENODEV;
return of_register_driver(&cg3_driver, &of_bus_type);
}
int __init
cg3_setup(char *arg)
static void __exit cg3_exit(void)
{
/* No cmdline options yet... */
return 0;
of_unregister_driver(&cg3_driver);
}
module_init(cg3_init);
#ifdef MODULE
module_exit(cg3_exit);
#endif
MODULE_DESCRIPTION("framebuffer driver for CGthree chipsets");
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
MODULE_VERSION("2.0");
MODULE_LICENSE("GPL");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* p9100.c: P9100 frame buffer driver
*
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
* Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net)
* Copyright 1999 Derrick J Brashear (shadow@dementia.org)
*
* Driver layout based loosely on tgafb.c, see that file for credits.
......@@ -17,8 +17,8 @@
#include <linux/mm.h>
#include <asm/io.h>
#include <asm/sbus.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/of_device.h>
#include <asm/fbio.h>
#include "sbuslib.h"
......@@ -72,60 +72,60 @@ static struct fb_ops p9100_ops = {
struct p9100_regs {
/* Registers for the system control */
volatile u32 sys_base;
volatile u32 sys_config;
volatile u32 sys_intr;
volatile u32 sys_int_ena;
volatile u32 sys_alt_rd;
volatile u32 sys_alt_wr;
volatile u32 sys_xxx[58];
u32 sys_base;
u32 sys_config;
u32 sys_intr;
u32 sys_int_ena;
u32 sys_alt_rd;
u32 sys_alt_wr;
u32 sys_xxx[58];
/* Registers for the video control */
volatile u32 vid_base;
volatile u32 vid_hcnt;
volatile u32 vid_htotal;
volatile u32 vid_hsync_rise;
volatile u32 vid_hblank_rise;
volatile u32 vid_hblank_fall;
volatile u32 vid_hcnt_preload;
volatile u32 vid_vcnt;
volatile u32 vid_vlen;
volatile u32 vid_vsync_rise;
volatile u32 vid_vblank_rise;
volatile u32 vid_vblank_fall;
volatile u32 vid_vcnt_preload;
volatile u32 vid_screenpaint_addr;
volatile u32 vid_screenpaint_timectl1;
volatile u32 vid_screenpaint_qsfcnt;
volatile u32 vid_screenpaint_timectl2;
volatile u32 vid_xxx[15];
u32 vid_base;
u32 vid_hcnt;
u32 vid_htotal;
u32 vid_hsync_rise;
u32 vid_hblank_rise;
u32 vid_hblank_fall;
u32 vid_hcnt_preload;
u32 vid_vcnt;
u32 vid_vlen;
u32 vid_vsync_rise;
u32 vid_vblank_rise;
u32 vid_vblank_fall;
u32 vid_vcnt_preload;
u32 vid_screenpaint_addr;
u32 vid_screenpaint_timectl1;
u32 vid_screenpaint_qsfcnt;
u32 vid_screenpaint_timectl2;
u32 vid_xxx[15];
/* Registers for the video control */
volatile u32 vram_base;
volatile u32 vram_memcfg;
volatile u32 vram_refresh_pd;
volatile u32 vram_refresh_cnt;
volatile u32 vram_raslo_max;
volatile u32 vram_raslo_cur;
volatile u32 pwrup_cfg;
volatile u32 vram_xxx[25];
u32 vram_base;
u32 vram_memcfg;
u32 vram_refresh_pd;
u32 vram_refresh_cnt;
u32 vram_raslo_max;
u32 vram_raslo_cur;
u32 pwrup_cfg;
u32 vram_xxx[25];
/* Registers for IBM RGB528 Palette */
volatile u32 ramdac_cmap_wridx;
volatile u32 ramdac_palette_data;
volatile u32 ramdac_pixel_mask;
volatile u32 ramdac_palette_rdaddr;
volatile u32 ramdac_idx_lo;
volatile u32 ramdac_idx_hi;
volatile u32 ramdac_idx_data;
volatile u32 ramdac_idx_ctl;
volatile u32 ramdac_xxx[1784];
u32 ramdac_cmap_wridx;
u32 ramdac_palette_data;
u32 ramdac_pixel_mask;
u32 ramdac_palette_rdaddr;
u32 ramdac_idx_lo;
u32 ramdac_idx_hi;
u32 ramdac_idx_data;
u32 ramdac_idx_ctl;
u32 ramdac_xxx[1784];
};
struct p9100_cmd_parameng {
volatile u32 parameng_status;
volatile u32 parameng_bltcmd;
volatile u32 parameng_quadcmd;
u32 parameng_status;
u32 parameng_bltcmd;
u32 parameng_quadcmd;
};
struct p9100_par {
......@@ -136,9 +136,8 @@ struct p9100_par {
#define P9100_FLAG_BLANKED 0x00000001
unsigned long physbase;
unsigned long which_io;
unsigned long fbsize;
struct sbus_dev *sdev;
};
/**
......@@ -227,8 +226,7 @@ static int p9100_mmap(struct fb_info *info, struct vm_area_struct *vma)
return sbusfb_mmap_helper(p9100_mmap_map,
par->physbase, par->fbsize,
par->sdev->reg_addrs[0].which_io,
vma);
par->which_io, vma);
}
static int p9100_ioctl(struct fb_info *info, unsigned int cmd,
......@@ -245,12 +243,9 @@ static int p9100_ioctl(struct fb_info *info, unsigned int cmd,
* Initialisation
*/
static void
p9100_init_fix(struct fb_info *info, int linebytes)
static void p9100_init_fix(struct fb_info *info, int linebytes, struct device_node *dp)
{
struct p9100_par *par = (struct p9100_par *)info->par;
strlcpy(info->fix.id, par->sdev->prom_name, sizeof(info->fix.id));
strlcpy(info->fix.id, dp->name, sizeof(info->fix.id));
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
......@@ -263,121 +258,137 @@ p9100_init_fix(struct fb_info *info, int linebytes)
struct all_info {
struct fb_info info;
struct p9100_par par;
struct list_head list;
};
static LIST_HEAD(p9100_list);
static void p9100_init_one(struct sbus_dev *sdev)
static int __devinit p9100_init_one(struct of_device *op)
{
struct device_node *dp = op->node;
struct all_info *all;
int linebytes;
all = kmalloc(sizeof(*all), GFP_KERNEL);
if (!all) {
printk(KERN_ERR "p9100: Cannot allocate memory.\n");
return;
}
memset(all, 0, sizeof(*all));
int linebytes, err;
INIT_LIST_HEAD(&all->list);
all = kzalloc(sizeof(*all), GFP_KERNEL);
if (!all)
return -ENOMEM;
spin_lock_init(&all->par.lock);
all->par.sdev = sdev;
/* This is the framebuffer and the only resource apps can mmap. */
all->par.physbase = sdev->reg_addrs[2].phys_addr;
all->par.physbase = op->resource[2].start;
all->par.which_io = op->resource[2].flags & IORESOURCE_BITS;
sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
sbusfb_fill_var(&all->info.var, dp->node, 8);
all->info.var.red.length = 8;
all->info.var.green.length = 8;
all->info.var.blue.length = 8;
linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
all->info.var.xres);
linebytes = of_getintprop_default(dp, "linebytes",
all->info.var.xres);
all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
all->par.regs = sbus_ioremap(&sdev->resource[0], 0,
sizeof(struct p9100_regs), "p9100 regs");
all->par.regs = of_ioremap(&op->resource[0], 0,
sizeof(struct p9100_regs), "p9100 regs");
if (!all->par.regs) {
kfree(all);
return -ENOMEM;
}
all->info.flags = FBINFO_DEFAULT;
all->info.fbops = &p9100_ops;
#ifdef CONFIG_SPARC32
all->info.screen_base = (char __iomem *)
prom_getintdefault(sdev->prom_node, "address", 0);
#endif
if (!all->info.screen_base)
all->info.screen_base = sbus_ioremap(&sdev->resource[2], 0,
all->par.fbsize, "p9100 ram");
all->info.screen_base = of_ioremap(&op->resource[2], 0,
all->par.fbsize, "p9100 ram");
if (!all->info.screen_base) {
of_iounmap(all->par.regs, sizeof(struct p9100_regs));
kfree(all);
return -ENOMEM;
}
all->info.par = &all->par;
p9100_blank(0, &all->info);
if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
printk(KERN_ERR "p9100: Could not allocate color map.\n");
of_iounmap(all->par.regs, sizeof(struct p9100_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
return;
return -ENOMEM;
}
p9100_init_fix(&all->info, linebytes);
p9100_init_fix(&all->info, linebytes, dp);
if (register_framebuffer(&all->info) < 0) {
printk(KERN_ERR "p9100: Could not register framebuffer.\n");
err = register_framebuffer(&all->info);
if (err < 0) {
fb_dealloc_cmap(&all->info.cmap);
of_iounmap(all->par.regs, sizeof(struct p9100_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
return;
return err;
}
fb_set_cmap(&all->info.cmap, &all->info);
list_add(&all->list, &p9100_list);
dev_set_drvdata(&op->dev, all);
printk("%s: p9100 at %lx:%lx\n",
dp->full_name,
all->par.which_io, all->par.physbase);
printk("p9100: %s at %lx:%lx\n",
sdev->prom_name,
(long) sdev->reg_addrs[0].which_io,
(long) sdev->reg_addrs[0].phys_addr);
return 0;
}
int __init p9100_init(void)
static int __devinit p9100_probe(struct of_device *dev, const struct of_device_id *match)
{
struct sbus_bus *sbus;
struct sbus_dev *sdev;
struct of_device *op = to_of_device(&dev->dev);
if (fb_get_options("p9100fb", NULL))
return -ENODEV;
return p9100_init_one(op);
}
for_all_sbusdev(sdev, sbus) {
if (!strcmp(sdev->prom_name, "p9100"))
p9100_init_one(sdev);
}
static int __devexit p9100_remove(struct of_device *dev)
{
struct all_info *all = dev_get_drvdata(&dev->dev);
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
of_iounmap(all->par.regs, sizeof(struct p9100_regs));
of_iounmap(all->info.screen_base, all->par.fbsize);
kfree(all);
dev_set_drvdata(&dev->dev, NULL);
return 0;
}
void __exit p9100_exit(void)
{
struct list_head *pos, *tmp;
static struct of_device_id p9100_match[] = {
{
.name = "p9100",
},
{},
};
MODULE_DEVICE_TABLE(of, p9100_match);
list_for_each_safe(pos, tmp, &p9100_list) {
struct all_info *all = list_entry(pos, typeof(*all), list);
static struct of_platform_driver p9100_driver = {
.name = "p9100",
.match_table = p9100_match,
.probe = p9100_probe,
.remove = __devexit_p(p9100_remove),
};
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
kfree(all);
}
static int __init p9100_init(void)
{
if (fb_get_options("p9100fb", NULL))
return -ENODEV;
return of_register_driver(&p9100_driver, &of_bus_type);
}
int __init
p9100_setup(char *arg)
static void __exit p9100_exit(void)
{
/* No cmdline options yet... */
return 0;
of_unregister_driver(&p9100_driver);
}
module_init(p9100_init);
#ifdef MODULE
module_exit(p9100_exit);
#endif
MODULE_DESCRIPTION("framebuffer driver for P9100 chipsets");
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
MODULE_VERSION("2.0");
MODULE_LICENSE("GPL");
/* tcx.c: TCX frame buffer driver
*
* Copyright (C) 2003 David S. Miller (davem@redhat.com)
* Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net)
* Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
* Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
* Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
......@@ -19,8 +19,8 @@
#include <linux/mm.h>
#include <asm/io.h>
#include <asm/sbus.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/of_device.h>
#include <asm/fbio.h>
#include "sbuslib.h"
......@@ -77,32 +77,32 @@ static struct fb_ops tcx_ops = {
/* The contents are unknown */
struct tcx_tec {
volatile u32 tec_matrix;
volatile u32 tec_clip;
volatile u32 tec_vdc;
u32 tec_matrix;
u32 tec_clip;
u32 tec_vdc;
};
struct tcx_thc {
volatile u32 thc_rev;
u32 thc_rev;
u32 thc_pad0[511];
volatile u32 thc_hs; /* hsync timing */
volatile u32 thc_hsdvs;
volatile u32 thc_hd;
volatile u32 thc_vs; /* vsync timing */
volatile u32 thc_vd;
volatile u32 thc_refresh;
volatile u32 thc_misc;
u32 thc_hs; /* hsync timing */
u32 thc_hsdvs;
u32 thc_hd;
u32 thc_vs; /* vsync timing */
u32 thc_vd;
u32 thc_refresh;
u32 thc_misc;
u32 thc_pad1[56];
volatile u32 thc_cursxy; /* cursor x,y position (16 bits each) */
volatile u32 thc_cursmask[32]; /* cursor mask bits */
volatile u32 thc_cursbits[32]; /* what to show where mask enabled */
u32 thc_cursxy; /* cursor x,y position (16 bits each) */
u32 thc_cursmask[32]; /* cursor mask bits */
u32 thc_cursbits[32]; /* what to show where mask enabled */
};
struct bt_regs {
volatile u32 addr;
volatile u32 color_map;
volatile u32 control;
volatile u32 cursor;
u32 addr;
u32 color_map;
u32 control;
u32 cursor;
};
#define TCX_MMAP_ENTRIES 14
......@@ -112,24 +112,23 @@ struct tcx_par {
struct bt_regs __iomem *bt;
struct tcx_thc __iomem *thc;
struct tcx_tec __iomem *tec;
volatile u32 __iomem *cplane;
u32 __iomem *cplane;
u32 flags;
#define TCX_FLAG_BLANKED 0x00000001
unsigned long physbase;
unsigned long which_io;
unsigned long fbsize;
struct sbus_mmap_map mmap_map[TCX_MMAP_ENTRIES];
int lowdepth;
struct sbus_dev *sdev;
};
/* Reset control plane so that WID is 8-bit plane. */
static void __tcx_set_control_plane (struct tcx_par *par)
{
volatile u32 __iomem *p, *pend;
u32 __iomem *p, *pend;
if (par->lowdepth)
return;
......@@ -307,8 +306,7 @@ static int tcx_mmap(struct fb_info *info, struct vm_area_struct *vma)
return sbusfb_mmap_helper(par->mmap_map,
par->physbase, par->fbsize,
par->sdev->reg_addrs[0].which_io,
vma);
par->which_io, vma);
}
static int tcx_ioctl(struct fb_info *info, unsigned int cmd,
......@@ -350,48 +348,71 @@ tcx_init_fix(struct fb_info *info, int linebytes)
struct all_info {
struct fb_info info;
struct tcx_par par;
struct list_head list;
};
static LIST_HEAD(tcx_list);
static void tcx_init_one(struct sbus_dev *sdev)
static void tcx_unmap_regs(struct all_info *all)
{
struct all_info *all;
int linebytes, i;
if (all->par.tec)
of_iounmap(all->par.tec, sizeof(struct tcx_tec));
if (all->par.thc)
of_iounmap(all->par.thc, sizeof(struct tcx_thc));
if (all->par.bt)
of_iounmap(all->par.bt, sizeof(struct bt_regs));
if (all->par.cplane)
of_iounmap(all->par.cplane, all->par.fbsize * sizeof(u32));
if (all->info.screen_base)
of_iounmap(all->info.screen_base, all->par.fbsize);
}
all = kmalloc(sizeof(*all), GFP_KERNEL);
if (!all) {
printk(KERN_ERR "tcx: Cannot allocate memory.\n");
return;
}
memset(all, 0, sizeof(*all));
static int __devinit tcx_init_one(struct of_device *op)
{
struct device_node *dp = op->node;
struct all_info *all;
int linebytes, i, err;
INIT_LIST_HEAD(&all->list);
all = kzalloc(sizeof(*all), GFP_KERNEL);
if (!all)
return -ENOMEM;
spin_lock_init(&all->par.lock);
all->par.sdev = sdev;
all->par.lowdepth = prom_getbool(sdev->prom_node, "tcx-8-bit");
all->par.lowdepth =
(of_find_property(dp, "tcx-8-bit", NULL) != NULL);
sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
sbusfb_fill_var(&all->info.var, dp->node, 8);
all->info.var.red.length = 8;
all->info.var.green.length = 8;
all->info.var.blue.length = 8;
linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
all->info.var.xres);
linebytes = of_getintprop_default(dp, "linebytes",
all->info.var.xres);
all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
all->par.tec = sbus_ioremap(&sdev->resource[7], 0,
sizeof(struct tcx_tec), "tcx tec");
all->par.thc = sbus_ioremap(&sdev->resource[9], 0,
sizeof(struct tcx_thc), "tcx thc");
all->par.bt = sbus_ioremap(&sdev->resource[8], 0,
sizeof(struct bt_regs), "tcx dac");
all->par.tec = of_ioremap(&op->resource[7], 0,
sizeof(struct tcx_tec), "tcx tec");
all->par.thc = of_ioremap(&op->resource[9], 0,
sizeof(struct tcx_thc), "tcx thc");
all->par.bt = of_ioremap(&op->resource[8], 0,
sizeof(struct bt_regs), "tcx dac");
all->info.screen_base = of_ioremap(&op->resource[0], 0,
all->par.fbsize, "tcx ram");
if (!all->par.tec || !all->par.thc ||
!all->par.bt || !all->info.screen_base) {
tcx_unmap_regs(all);
kfree(all);
return -ENOMEM;
}
memcpy(&all->par.mmap_map, &__tcx_mmap_map, sizeof(all->par.mmap_map));
if (!all->par.lowdepth) {
all->par.cplane = sbus_ioremap(&sdev->resource[4], 0,
all->par.fbsize * sizeof(u32), "tcx cplane");
all->par.cplane = of_ioremap(&op->resource[4], 0,
all->par.fbsize * sizeof(u32),
"tcx cplane");
if (!all->par.cplane) {
tcx_unmap_regs(all);
kfree(all);
return -ENOMEM;
}
} else {
all->par.mmap_map[1].size = SBUS_MMAP_EMPTY;
all->par.mmap_map[4].size = SBUS_MMAP_EMPTY;
......@@ -400,6 +421,8 @@ static void tcx_init_one(struct sbus_dev *sdev)
}
all->par.physbase = 0;
all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
for (i = 0; i < TCX_MMAP_ENTRIES; i++) {
int j;
......@@ -416,18 +439,11 @@ static void tcx_init_one(struct sbus_dev *sdev)
j = i;
break;
};
all->par.mmap_map[i].poff = sdev->reg_addrs[j].phys_addr;
all->par.mmap_map[i].poff = op->resource[j].start;
}
all->info.flags = FBINFO_DEFAULT;
all->info.fbops = &tcx_ops;
#ifdef CONFIG_SPARC32
all->info.screen_base = (char __iomem *)
prom_getintdefault(sdev->prom_node, "address", 0);
#endif
if (!all->info.screen_base)
all->info.screen_base = sbus_ioremap(&sdev->resource[0], 0,
all->par.fbsize, "tcx ram");
all->info.par = &all->par;
/* Initialize brooktree DAC. */
......@@ -445,72 +461,88 @@ static void tcx_init_one(struct sbus_dev *sdev)
tcx_blank(FB_BLANK_UNBLANK, &all->info);
if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
printk(KERN_ERR "tcx: Could not allocate color map.\n");
tcx_unmap_regs(all);
kfree(all);
return;
return -ENOMEM;
}
fb_set_cmap(&all->info.cmap, &all->info);
tcx_init_fix(&all->info, linebytes);
if (register_framebuffer(&all->info) < 0) {
printk(KERN_ERR "tcx: Could not register framebuffer.\n");
err = register_framebuffer(&all->info);
if (err < 0) {
fb_dealloc_cmap(&all->info.cmap);
tcx_unmap_regs(all);
kfree(all);
return;
return err;
}
list_add(&all->list, &tcx_list);
dev_set_drvdata(&op->dev, all);
printk("tcx: %s at %lx:%lx, %s\n",
sdev->prom_name,
(long) sdev->reg_addrs[0].which_io,
(long) sdev->reg_addrs[0].phys_addr,
printk("%s: TCX at %lx:%lx, %s\n",
dp->full_name,
all->par.which_io,
op->resource[0].start,
all->par.lowdepth ? "8-bit only" : "24-bit depth");
return 0;
}
int __init tcx_init(void)
static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id *match)
{
struct sbus_bus *sbus;
struct sbus_dev *sdev;
struct of_device *op = to_of_device(&dev->dev);
if (fb_get_options("tcxfb", NULL))
return -ENODEV;
return tcx_init_one(op);
}
for_all_sbusdev(sdev, sbus) {
if (!strcmp(sdev->prom_name, "SUNW,tcx"))
tcx_init_one(sdev);
}
static int __devexit tcx_remove(struct of_device *dev)
{
struct all_info *all = dev_get_drvdata(&dev->dev);
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
tcx_unmap_regs(all);
kfree(all);
dev_set_drvdata(&dev->dev, NULL);
return 0;
}
void __exit tcx_exit(void)
{
struct list_head *pos, *tmp;
static struct of_device_id tcx_match[] = {
{
.name = "SUNW,tcx",
},
{},
};
MODULE_DEVICE_TABLE(of, tcx_match);
list_for_each_safe(pos, tmp, &tcx_list) {
struct all_info *all = list_entry(pos, typeof(*all), list);
static struct of_platform_driver tcx_driver = {
.name = "tcx",
.match_table = tcx_match,
.probe = tcx_probe,
.remove = __devexit_p(tcx_remove),
};
unregister_framebuffer(&all->info);
fb_dealloc_cmap(&all->info.cmap);
kfree(all);
}
int __init tcx_init(void)
{
if (fb_get_options("tcxfb", NULL))
return -ENODEV;
return of_register_driver(&tcx_driver, &of_bus_type);
}
int __init
tcx_setup(char *arg)
void __exit tcx_exit(void)
{
/* No cmdline options yet... */
return 0;
of_unregister_driver(&tcx_driver);
}
module_init(tcx_init);
#ifdef MODULE
module_exit(tcx_exit);
#endif
MODULE_DESCRIPTION("framebuffer driver for TCX chipsets");
MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
MODULE_VERSION("2.0");
MODULE_LICENSE("GPL");
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