/* cg3.c: CGTHREE frame buffer driver
*
- * Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net)
+ * Copyright (C) 2003 David S. Miller (davem@redhat.com)
* 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)
#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"
};
struct bt_regs {
- u32 addr;
- u32 color_map;
- u32 control;
- u32 cursor;
+ volatile u32 addr;
+ volatile u32 color_map;
+ volatile u32 control;
+ volatile u32 cursor;
};
struct cg3_regs {
struct bt_regs cmap;
- 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;
+ 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;
};
/* Offset of interesting structures in the OBIO space */
#define CG3_FLAG_RDI 0x00000002
unsigned long physbase;
- unsigned long which_io;
unsigned long fbsize;
+
+ struct sbus_dev *sdev;
};
/**
return sbusfb_mmap_helper(cg3_mmap_map,
par->physbase, par->fbsize,
- par->which_io,
+ par->sdev->reg_addrs[0].which_io,
vma);
}
*/
static void
-cg3_init_fix(struct fb_info *info, int linebytes, struct device_node *dp)
+cg3_init_fix(struct fb_info *info, int linebytes)
{
- strlcpy(info->fix.id, dp->name, sizeof(info->fix.id));
+ struct cg3_par *par = (struct cg3_par *)info->par;
+
+ strlcpy(info->fix.id, par->sdev->prom_name, sizeof(info->fix.id));
info->fix.type = FB_TYPE_PACKED_PIXELS;
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
}
static void cg3_rdi_maybe_fixup_var(struct fb_var_screeninfo *var,
- struct device_node *dp)
+ struct sbus_dev *sdev)
{
- char *params;
+ char buffer[40];
char *p;
int ww, hh;
- params = of_get_property(dp, "params", NULL);
- if (params) {
- ww = simple_strtoul(params, &p, 10);
+ *buffer = 0;
+ prom_getstring(sdev->prom_node, "params", buffer, sizeof(buffer));
+ if (*buffer) {
+ ww = simple_strtoul(buffer, &p, 10);
if (ww && *p == 'x') {
hh = simple_strtoul(p + 1, &p, 10);
if (hh && *p == '-') {
sbus_writeb(p[1], regp);
}
for (p = cg3_dacvals; *p; p += 2) {
- u8 __iomem *regp;
+ volatile u8 __iomem *regp;
- regp = (u8 __iomem *)&par->regs->cmap.addr;
+ regp = (volatile u8 __iomem *)&par->regs->cmap.addr;
sbus_writeb(p[0], regp);
- regp = (u8 __iomem *)&par->regs->cmap.control;
+ regp = (volatile u8 __iomem *)&par->regs->cmap.control;
sbus_writeb(p[1], regp);
}
}
struct all_info {
struct fb_info info;
struct cg3_par par;
+ struct list_head list;
};
+static LIST_HEAD(cg3_list);
-static int __devinit cg3_init_one(struct of_device *op)
+static void cg3_init_one(struct sbus_dev *sdev)
{
- struct device_node *dp = op->node;
struct all_info *all;
- int linebytes, err;
+ int linebytes;
+
+ all = kmalloc(sizeof(*all), GFP_KERNEL);
+ if (!all) {
+ printk(KERN_ERR "cg3: Cannot allocate memory.\n");
+ return;
+ }
+ memset(all, 0, sizeof(*all));
- all = kzalloc(sizeof(*all), GFP_KERNEL);
- if (!all)
- return -ENOMEM;
+ INIT_LIST_HEAD(&all->list);
spin_lock_init(&all->par.lock);
+ all->par.sdev = sdev;
- all->par.physbase = op->resource[0].start;
- all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
+ all->par.physbase = sdev->reg_addrs[0].phys_addr;
- sbusfb_fill_var(&all->info.var, dp->node, 8);
+ sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
all->info.var.red.length = 8;
all->info.var.green.length = 8;
all->info.var.blue.length = 8;
- if (!strcmp(dp->name, "cgRDI"))
+ if (!strcmp(sdev->prom_name, "cgRDI"))
all->par.flags |= CG3_FLAG_RDI;
if (all->par.flags & CG3_FLAG_RDI)
- cg3_rdi_maybe_fixup_var(&all->info.var, dp);
+ cg3_rdi_maybe_fixup_var(&all->info.var, sdev);
- linebytes = of_getintprop_default(dp, "linebytes",
- all->info.var.xres);
+ linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
+ all->info.var.xres);
all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
- all->par.regs = of_ioremap(&op->resource[0], CG3_REGS_OFFSET,
- sizeof(struct cg3_regs), "cg3 regs");
+ all->par.regs = sbus_ioremap(&sdev->resource[0], CG3_REGS_OFFSET,
+ sizeof(struct cg3_regs), "cg3 regs");
all->info.flags = FBINFO_DEFAULT;
all->info.fbops = &cg3_ops;
- all->info.screen_base =
- of_ioremap(&op->resource[0], CG3_RAM_OFFSET,
- all->par.fbsize, "cg3 ram");
+#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.par = &all->par;
cg3_blank(0, &all->info);
- if (!of_find_property(dp, "width", NULL))
+ if (!prom_getbool(sdev->prom_node, "width"))
cg3_do_default_mode(&all->par);
if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
- of_iounmap(all->par.regs, sizeof(struct cg3_regs));
- of_iounmap(all->info.screen_base, all->par.fbsize);
+ printk(KERN_ERR "cg3: Could not allocate color map.\n");
kfree(all);
- return -ENOMEM;
+ return;
}
fb_set_cmap(&all->info.cmap, &all->info);
- cg3_init_fix(&all->info, linebytes, dp);
+ cg3_init_fix(&all->info, linebytes);
- err = register_framebuffer(&all->info);
- if (err < 0) {
+ if (register_framebuffer(&all->info) < 0) {
+ printk(KERN_ERR "cg3: Could not register framebuffer.\n");
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 err;
+ return;
}
- dev_set_drvdata(&op->dev, all);
-
- printk("%s: cg3 at %lx:%lx\n",
- dp->full_name, all->par.which_io, all->par.physbase);
+ list_add(&all->list, &cg3_list);
- return 0;
+ printk("cg3: %s at %lx:%lx\n",
+ sdev->prom_name,
+ (long) sdev->reg_addrs[0].which_io,
+ (long) sdev->reg_addrs[0].phys_addr);
}
-static int __devinit cg3_probe(struct of_device *dev, const struct of_device_id *match)
+int __init cg3_init(void)
{
- struct of_device *op = to_of_device(&dev->dev);
+ struct sbus_bus *sbus;
+ struct sbus_dev *sdev;
- return cg3_init_one(op);
-}
-
-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);
+ if (fb_get_options("cg3fb", NULL))
+ return -ENODEV;
- dev_set_drvdata(&dev->dev, NULL);
+ for_all_sbusdev(sdev, sbus) {
+ if (!strcmp(sdev->prom_name, "cgthree") ||
+ !strcmp(sdev->prom_name, "cgRDI"))
+ cg3_init_one(sdev);
+ }
return 0;
}
-static struct of_device_id cg3_match[] = {
- {
- .name = "cgthree",
- },
- {
- .name = "cgRDI",
- },
- {},
-};
-MODULE_DEVICE_TABLE(of, cg3_match);
-
-static struct of_platform_driver cg3_driver = {
- .name = "cg3",
- .match_table = cg3_match,
- .probe = cg3_probe,
- .remove = __devexit_p(cg3_remove),
-};
-
-static int __init cg3_init(void)
+void __exit cg3_exit(void)
{
- if (fb_get_options("cg3fb", NULL))
- return -ENODEV;
+ struct list_head *pos, *tmp;
+
+ list_for_each_safe(pos, tmp, &cg3_list) {
+ struct all_info *all = list_entry(pos, typeof(*all), list);
- return of_register_driver(&cg3_driver, &of_bus_type);
+ unregister_framebuffer(&all->info);
+ fb_dealloc_cmap(&all->info.cmap);
+ kfree(all);
+ }
}
-static void __exit cg3_exit(void)
+int __init
+cg3_setup(char *arg)
{
- of_unregister_driver(&cg3_driver);
+ /* No cmdline options yet... */
+ return 0;
}
module_init(cg3_init);
+
+#ifdef MODULE
module_exit(cg3_exit);
+#endif
MODULE_DESCRIPTION("framebuffer driver for CGthree chipsets");
-MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
-MODULE_VERSION("2.0");
+MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_LICENSE("GPL");