/* tcx.c: TCX 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) 1996 Eddie C. Dost (ecd@skynet.be)
#include <linux/mm.h>
#include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/of_device.h>
+#include <asm/sbus.h>
+#include <asm/oplib.h>
#include <asm/fbio.h>
#include "sbuslib.h"
/* The contents are unknown */
struct tcx_tec {
- u32 tec_matrix;
- u32 tec_clip;
- u32 tec_vdc;
+ volatile u32 tec_matrix;
+ volatile u32 tec_clip;
+ volatile u32 tec_vdc;
};
struct tcx_thc {
- u32 thc_rev;
+ volatile u32 thc_rev;
u32 thc_pad0[511];
- 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;
+ 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_pad1[56];
- 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 */
+ 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 */
};
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;
};
#define TCX_MMAP_ENTRIES 14
struct bt_regs __iomem *bt;
struct tcx_thc __iomem *thc;
struct tcx_tec __iomem *tec;
- u32 __iomem *cplane;
+ volatile 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)
{
- u32 __iomem *p, *pend;
+ volatile u32 __iomem *p, *pend;
if (par->lowdepth)
return;
return sbusfb_mmap_helper(par->mmap_map,
par->physbase, par->fbsize,
- par->which_io, vma);
+ par->sdev->reg_addrs[0].which_io,
+ vma);
}
static int tcx_ioctl(struct fb_info *info, unsigned int cmd,
struct all_info {
struct fb_info info;
struct tcx_par par;
+ struct list_head list;
};
+static LIST_HEAD(tcx_list);
-static void tcx_unmap_regs(struct all_info *all)
-{
- 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);
-}
-
-static int __devinit tcx_init_one(struct of_device *op)
+static void tcx_init_one(struct sbus_dev *sdev)
{
- struct device_node *dp = op->node;
struct all_info *all;
- int linebytes, i, err;
+ int linebytes, i;
- all = kzalloc(sizeof(*all), GFP_KERNEL);
- if (!all)
- return -ENOMEM;
+ all = kmalloc(sizeof(*all), GFP_KERNEL);
+ if (!all) {
+ printk(KERN_ERR "tcx: Cannot allocate memory.\n");
+ return;
+ }
+ memset(all, 0, sizeof(*all));
+
+ INIT_LIST_HEAD(&all->list);
spin_lock_init(&all->par.lock);
+ all->par.sdev = sdev;
- all->par.lowdepth =
- (of_find_property(dp, "tcx-8-bit", NULL) != NULL);
+ all->par.lowdepth = prom_getbool(sdev->prom_node, "tcx-8-bit");
- 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;
- 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.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;
- }
-
+ 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");
memcpy(&all->par.mmap_map, &__tcx_mmap_map, sizeof(all->par.mmap_map));
if (!all->par.lowdepth) {
- 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;
- }
+ all->par.cplane = sbus_ioremap(&sdev->resource[4], 0,
+ all->par.fbsize * sizeof(u32), "tcx cplane");
} else {
all->par.mmap_map[1].size = SBUS_MMAP_EMPTY;
all->par.mmap_map[4].size = SBUS_MMAP_EMPTY;
}
all->par.physbase = 0;
- all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
-
for (i = 0; i < TCX_MMAP_ENTRIES; i++) {
int j;
j = i;
break;
};
- all->par.mmap_map[i].poff = op->resource[j].start;
+ all->par.mmap_map[i].poff = sdev->reg_addrs[j].phys_addr;
}
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. */
tcx_blank(FB_BLANK_UNBLANK, &all->info);
if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
- tcx_unmap_regs(all);
+ printk(KERN_ERR "tcx: Could not allocate color map.\n");
kfree(all);
- return -ENOMEM;
+ return;
}
fb_set_cmap(&all->info.cmap, &all->info);
tcx_init_fix(&all->info, linebytes);
- err = register_framebuffer(&all->info);
- if (err < 0) {
+ if (register_framebuffer(&all->info) < 0) {
+ printk(KERN_ERR "tcx: Could not register framebuffer.\n");
fb_dealloc_cmap(&all->info.cmap);
- tcx_unmap_regs(all);
kfree(all);
- return err;
+ return;
}
- dev_set_drvdata(&op->dev, all);
+ list_add(&all->list, &tcx_list);
- printk("%s: TCX at %lx:%lx, %s\n",
- dp->full_name,
- all->par.which_io,
- op->resource[0].start,
+ 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,
all->par.lowdepth ? "8-bit only" : "24-bit depth");
-
- return 0;
}
-static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id *match)
-{
- struct of_device *op = to_of_device(&dev->dev);
-
- return tcx_init_one(op);
-}
-
-static int __devexit tcx_remove(struct of_device *dev)
+int __init tcx_init(void)
{
- struct all_info *all = dev_get_drvdata(&dev->dev);
-
- unregister_framebuffer(&all->info);
- fb_dealloc_cmap(&all->info.cmap);
+ struct sbus_bus *sbus;
+ struct sbus_dev *sdev;
- tcx_unmap_regs(all);
-
- kfree(all);
+ if (fb_get_options("tcxfb", NULL))
+ return -ENODEV;
- dev_set_drvdata(&dev->dev, NULL);
+ for_all_sbusdev(sdev, sbus) {
+ if (!strcmp(sdev->prom_name, "SUNW,tcx"))
+ tcx_init_one(sdev);
+ }
return 0;
}
-static struct of_device_id tcx_match[] = {
- {
- .name = "SUNW,tcx",
- },
- {},
-};
-MODULE_DEVICE_TABLE(of, tcx_match);
-
-static struct of_platform_driver tcx_driver = {
- .name = "tcx",
- .match_table = tcx_match,
- .probe = tcx_probe,
- .remove = __devexit_p(tcx_remove),
-};
-
-int __init tcx_init(void)
+void __exit tcx_exit(void)
{
- if (fb_get_options("tcxfb", NULL))
- return -ENODEV;
+ struct list_head *pos, *tmp;
- return of_register_driver(&tcx_driver, &of_bus_type);
+ list_for_each_safe(pos, tmp, &tcx_list) {
+ struct all_info *all = list_entry(pos, typeof(*all), list);
+
+ unregister_framebuffer(&all->info);
+ fb_dealloc_cmap(&all->info.cmap);
+ kfree(all);
+ }
}
-void __exit tcx_exit(void)
+int __init
+tcx_setup(char *arg)
{
- of_unregister_driver(&tcx_driver);
+ /* No cmdline options yet... */
+ return 0;
}
module_init(tcx_init);
+
+#ifdef MODULE
module_exit(tcx_exit);
+#endif
MODULE_DESCRIPTION("framebuffer driver for TCX chipsets");
-MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
-MODULE_VERSION("2.0");
+MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
MODULE_LICENSE("GPL");