| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* bw2.c: BWTWO frame buffer driver | 
 | 2 |  * | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 3 |  * Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 |  * Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz) | 
 | 5 |  * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx) | 
 | 6 |  * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) | 
 | 7 |  * | 
 | 8 |  * Driver layout based loosely on tgafb.c, see that file for credits. | 
 | 9 |  */ | 
 | 10 |  | 
 | 11 | #include <linux/module.h> | 
 | 12 | #include <linux/kernel.h> | 
 | 13 | #include <linux/errno.h> | 
 | 14 | #include <linux/string.h> | 
 | 15 | #include <linux/slab.h> | 
 | 16 | #include <linux/delay.h> | 
 | 17 | #include <linux/init.h> | 
 | 18 | #include <linux/fb.h> | 
 | 19 | #include <linux/mm.h> | 
 | 20 |  | 
 | 21 | #include <asm/io.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <asm/oplib.h> | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 23 | #include <asm/prom.h> | 
 | 24 | #include <asm/of_device.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/fbio.h> | 
 | 26 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include "sbuslib.h" | 
 | 28 |  | 
 | 29 | /* | 
 | 30 |  * Local functions. | 
 | 31 |  */ | 
 | 32 |  | 
 | 33 | static int bw2_blank(int, struct fb_info *); | 
 | 34 |  | 
| Christoph Hellwig | 216d526 | 2006-01-14 13:21:25 -0800 | [diff] [blame] | 35 | static int bw2_mmap(struct fb_info *, struct vm_area_struct *); | 
| Christoph Hellwig | 67a6680 | 2006-01-14 13:21:25 -0800 | [diff] [blame] | 36 | static int bw2_ioctl(struct fb_info *, unsigned int, unsigned long); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 |  | 
 | 38 | /* | 
 | 39 |  *  Frame buffer operations | 
 | 40 |  */ | 
 | 41 |  | 
 | 42 | static struct fb_ops bw2_ops = { | 
 | 43 | 	.owner			= THIS_MODULE, | 
 | 44 | 	.fb_blank		= bw2_blank, | 
 | 45 | 	.fb_fillrect		= cfb_fillrect, | 
 | 46 | 	.fb_copyarea		= cfb_copyarea, | 
 | 47 | 	.fb_imageblit		= cfb_imageblit, | 
 | 48 | 	.fb_mmap		= bw2_mmap, | 
 | 49 | 	.fb_ioctl		= bw2_ioctl, | 
| Christoph Hellwig | 9ffb83b | 2005-11-12 12:11:12 -0800 | [diff] [blame] | 50 | #ifdef CONFIG_COMPAT | 
 | 51 | 	.fb_compat_ioctl	= sbusfb_compat_ioctl, | 
 | 52 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | }; | 
 | 54 |  | 
 | 55 | /* OBio addresses for the bwtwo registers */ | 
 | 56 | #define BWTWO_REGISTER_OFFSET 0x400000 | 
 | 57 |  | 
 | 58 | struct bt_regs { | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 59 | 	u32 addr; | 
 | 60 | 	u32 color_map; | 
 | 61 | 	u32 control; | 
 | 62 | 	u32 cursor; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | }; | 
 | 64 |  | 
 | 65 | struct bw2_regs { | 
 | 66 | 	struct bt_regs	cmap; | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 67 | 	u8	control; | 
 | 68 | 	u8	status; | 
 | 69 | 	u8	cursor_start; | 
 | 70 | 	u8	cursor_end; | 
 | 71 | 	u8	h_blank_start; | 
 | 72 | 	u8	h_blank_end; | 
 | 73 | 	u8	h_sync_start; | 
 | 74 | 	u8	h_sync_end; | 
 | 75 | 	u8	comp_sync_end; | 
 | 76 | 	u8	v_blank_start_high; | 
 | 77 | 	u8	v_blank_start_low; | 
 | 78 | 	u8	v_blank_end; | 
 | 79 | 	u8	v_sync_start; | 
 | 80 | 	u8	v_sync_end; | 
 | 81 | 	u8	xfer_holdoff_start; | 
 | 82 | 	u8	xfer_holdoff_end; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | }; | 
 | 84 |  | 
 | 85 | /* Status Register Constants */ | 
 | 86 | #define BWTWO_SR_RES_MASK	0x70 | 
 | 87 | #define BWTWO_SR_1600_1280	0x50 | 
 | 88 | #define BWTWO_SR_1152_900_76_A	0x40 | 
 | 89 | #define BWTWO_SR_1152_900_76_B	0x60 | 
 | 90 | #define BWTWO_SR_ID_MASK	0x0f | 
 | 91 | #define BWTWO_SR_ID_MONO	0x02 | 
 | 92 | #define BWTWO_SR_ID_MONO_ECL	0x03 | 
 | 93 | #define BWTWO_SR_ID_MSYNC	0x04 | 
 | 94 | #define BWTWO_SR_ID_NOCONN	0x0a | 
 | 95 |  | 
 | 96 | /* Control Register Constants */ | 
 | 97 | #define BWTWO_CTL_ENABLE_INTS   0x80 | 
 | 98 | #define BWTWO_CTL_ENABLE_VIDEO  0x40 | 
 | 99 | #define BWTWO_CTL_ENABLE_TIMING 0x20 | 
 | 100 | #define BWTWO_CTL_ENABLE_CURCMP 0x10 | 
 | 101 | #define BWTWO_CTL_XTAL_MASK     0x0C | 
 | 102 | #define BWTWO_CTL_DIVISOR_MASK  0x03 | 
 | 103 |  | 
 | 104 | /* Status Register Constants */ | 
 | 105 | #define BWTWO_STAT_PENDING_INT  0x80 | 
 | 106 | #define BWTWO_STAT_MSENSE_MASK  0x70 | 
 | 107 | #define BWTWO_STAT_ID_MASK      0x0f | 
 | 108 |  | 
 | 109 | struct bw2_par { | 
 | 110 | 	spinlock_t		lock; | 
 | 111 | 	struct bw2_regs		__iomem *regs; | 
 | 112 |  | 
 | 113 | 	u32			flags; | 
 | 114 | #define BW2_FLAG_BLANKED	0x00000001 | 
 | 115 |  | 
 | 116 | 	unsigned long		physbase; | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 117 | 	unsigned long		which_io; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | 	unsigned long		fbsize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | }; | 
 | 120 |  | 
 | 121 | /** | 
 | 122 |  *      bw2_blank - Optional function.  Blanks the display. | 
 | 123 |  *      @blank_mode: the blank mode we want. | 
 | 124 |  *      @info: frame buffer structure that represents a single frame buffer | 
 | 125 |  */ | 
 | 126 | static int | 
 | 127 | bw2_blank(int blank, struct fb_info *info) | 
 | 128 | { | 
 | 129 | 	struct bw2_par *par = (struct bw2_par *) info->par; | 
 | 130 | 	struct bw2_regs __iomem *regs = par->regs; | 
 | 131 | 	unsigned long flags; | 
 | 132 | 	u8 val; | 
 | 133 |  | 
 | 134 | 	spin_lock_irqsave(&par->lock, flags); | 
 | 135 |  | 
 | 136 | 	switch (blank) { | 
 | 137 | 	case FB_BLANK_UNBLANK: /* Unblanking */ | 
 | 138 | 		val = sbus_readb(®s->control); | 
 | 139 | 		val |= BWTWO_CTL_ENABLE_VIDEO; | 
 | 140 | 		sbus_writeb(val, ®s->control); | 
 | 141 | 		par->flags &= ~BW2_FLAG_BLANKED; | 
 | 142 | 		break; | 
 | 143 |  | 
 | 144 | 	case FB_BLANK_NORMAL: /* Normal blanking */ | 
 | 145 | 	case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */ | 
 | 146 | 	case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */ | 
 | 147 | 	case FB_BLANK_POWERDOWN: /* Poweroff */ | 
 | 148 | 		val = sbus_readb(®s->control); | 
 | 149 | 		val &= ~BWTWO_CTL_ENABLE_VIDEO; | 
 | 150 | 		sbus_writeb(val, ®s->control); | 
 | 151 | 		par->flags |= BW2_FLAG_BLANKED; | 
 | 152 | 		break; | 
 | 153 | 	} | 
 | 154 |  | 
 | 155 | 	spin_unlock_irqrestore(&par->lock, flags); | 
 | 156 |  | 
 | 157 | 	return 0; | 
 | 158 | } | 
 | 159 |  | 
 | 160 | static struct sbus_mmap_map bw2_mmap_map[] = { | 
 | 161 | 	{ | 
 | 162 | 		.size = SBUS_MMAP_FBSIZE(1) | 
 | 163 | 	}, | 
 | 164 | 	{ .size = 0 } | 
 | 165 | }; | 
 | 166 |  | 
| Christoph Hellwig | 216d526 | 2006-01-14 13:21:25 -0800 | [diff] [blame] | 167 | static int bw2_mmap(struct fb_info *info, struct vm_area_struct *vma) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | { | 
 | 169 | 	struct bw2_par *par = (struct bw2_par *)info->par; | 
 | 170 |  | 
 | 171 | 	return sbusfb_mmap_helper(bw2_mmap_map, | 
 | 172 | 				  par->physbase, par->fbsize, | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 173 | 				  par->which_io, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | 				  vma); | 
 | 175 | } | 
 | 176 |  | 
| Christoph Hellwig | 67a6680 | 2006-01-14 13:21:25 -0800 | [diff] [blame] | 177 | static int bw2_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | { | 
 | 179 | 	struct bw2_par *par = (struct bw2_par *) info->par; | 
 | 180 |  | 
 | 181 | 	return sbusfb_ioctl_helper(cmd, arg, info, | 
 | 182 | 				   FBTYPE_SUN2BW, 1, par->fbsize); | 
 | 183 | } | 
 | 184 |  | 
 | 185 | /* | 
 | 186 |  *  Initialisation | 
 | 187 |  */ | 
 | 188 |  | 
 | 189 | static void | 
 | 190 | bw2_init_fix(struct fb_info *info, int linebytes) | 
 | 191 | { | 
 | 192 | 	strlcpy(info->fix.id, "bwtwo", sizeof(info->fix.id)); | 
 | 193 |  | 
 | 194 | 	info->fix.type = FB_TYPE_PACKED_PIXELS; | 
 | 195 | 	info->fix.visual = FB_VISUAL_MONO01; | 
 | 196 |  | 
 | 197 | 	info->fix.line_length = linebytes; | 
 | 198 |  | 
 | 199 | 	info->fix.accel = FB_ACCEL_SUN_BWTWO; | 
 | 200 | } | 
 | 201 |  | 
 | 202 | static u8 bw2regs_1600[] __initdata = { | 
 | 203 | 	0x14, 0x8b,	0x15, 0x28,	0x16, 0x03,	0x17, 0x13, | 
 | 204 | 	0x18, 0x7b,	0x19, 0x05,	0x1a, 0x34,	0x1b, 0x2e, | 
 | 205 | 	0x1c, 0x00,	0x1d, 0x0a,	0x1e, 0xff,	0x1f, 0x01, | 
 | 206 | 	0x10, 0x21,	0 | 
 | 207 | }; | 
 | 208 |  | 
 | 209 | static u8 bw2regs_ecl[] __initdata = { | 
 | 210 | 	0x14, 0x65,	0x15, 0x1e,	0x16, 0x04,	0x17, 0x0c, | 
 | 211 | 	0x18, 0x5e,	0x19, 0x03,	0x1a, 0xa7,	0x1b, 0x23, | 
 | 212 | 	0x1c, 0x00,	0x1d, 0x08,	0x1e, 0xff,	0x1f, 0x01, | 
 | 213 | 	0x10, 0x20,	0 | 
 | 214 | }; | 
 | 215 |  | 
 | 216 | static u8 bw2regs_analog[] __initdata = { | 
 | 217 | 	0x14, 0xbb,	0x15, 0x2b,	0x16, 0x03,	0x17, 0x13, | 
 | 218 | 	0x18, 0xb0,	0x19, 0x03,	0x1a, 0xa6,	0x1b, 0x22, | 
 | 219 | 	0x1c, 0x01,	0x1d, 0x05,	0x1e, 0xff,	0x1f, 0x01, | 
 | 220 | 	0x10, 0x20,	0 | 
 | 221 | }; | 
 | 222 |  | 
 | 223 | static u8 bw2regs_76hz[] __initdata = { | 
 | 224 | 	0x14, 0xb7,	0x15, 0x27,	0x16, 0x03,	0x17, 0x0f, | 
 | 225 | 	0x18, 0xae,	0x19, 0x03,	0x1a, 0xae,	0x1b, 0x2a, | 
 | 226 | 	0x1c, 0x01,	0x1d, 0x09,	0x1e, 0xff,	0x1f, 0x01, | 
 | 227 | 	0x10, 0x24,	0 | 
 | 228 | }; | 
 | 229 |  | 
 | 230 | static u8 bw2regs_66hz[] __initdata = { | 
 | 231 | 	0x14, 0xbb,	0x15, 0x2b,	0x16, 0x04,	0x17, 0x14, | 
 | 232 | 	0x18, 0xae,	0x19, 0x03,	0x1a, 0xa8,	0x1b, 0x24, | 
 | 233 | 	0x1c, 0x01,	0x1d, 0x05,	0x1e, 0xff,	0x1f, 0x01, | 
 | 234 | 	0x10, 0x20,	0 | 
 | 235 | }; | 
 | 236 |  | 
 | 237 | static void bw2_do_default_mode(struct bw2_par *par, struct fb_info *info, | 
 | 238 | 				int *linebytes) | 
 | 239 | { | 
 | 240 | 	u8 status, mon; | 
 | 241 | 	u8 *p; | 
 | 242 |  | 
 | 243 | 	status = sbus_readb(&par->regs->status); | 
 | 244 | 	mon = status & BWTWO_SR_RES_MASK; | 
 | 245 | 	switch (status & BWTWO_SR_ID_MASK) { | 
 | 246 | 	case BWTWO_SR_ID_MONO_ECL: | 
 | 247 | 		if (mon == BWTWO_SR_1600_1280) { | 
 | 248 | 			p = bw2regs_1600; | 
 | 249 | 			info->var.xres = info->var.xres_virtual = 1600; | 
 | 250 | 			info->var.yres = info->var.yres_virtual = 1280; | 
 | 251 | 			*linebytes = 1600 / 8; | 
 | 252 | 		} else | 
 | 253 | 			p = bw2regs_ecl; | 
 | 254 | 		break; | 
 | 255 |  | 
 | 256 | 	case BWTWO_SR_ID_MONO: | 
 | 257 | 		p = bw2regs_analog; | 
 | 258 | 		break; | 
 | 259 |  | 
 | 260 | 	case BWTWO_SR_ID_MSYNC: | 
 | 261 | 		if (mon == BWTWO_SR_1152_900_76_A || | 
 | 262 | 		    mon == BWTWO_SR_1152_900_76_B) | 
 | 263 | 			p = bw2regs_76hz; | 
 | 264 | 		else | 
 | 265 | 			p = bw2regs_66hz; | 
 | 266 | 		break; | 
 | 267 |  | 
 | 268 | 	case BWTWO_SR_ID_NOCONN: | 
 | 269 | 		return; | 
 | 270 |  | 
 | 271 | 	default: | 
 | 272 | 		prom_printf("bw2: can't handle SR %02x\n", | 
 | 273 | 			    status); | 
 | 274 | 		prom_halt(); | 
 | 275 | 	} | 
 | 276 | 	for ( ; *p; p += 2) { | 
 | 277 | 		u8 __iomem *regp = &((u8 __iomem *)par->regs)[p[0]]; | 
 | 278 | 		sbus_writeb(p[1], regp); | 
 | 279 | 	} | 
 | 280 | } | 
 | 281 |  | 
 | 282 | struct all_info { | 
 | 283 | 	struct fb_info info; | 
 | 284 | 	struct bw2_par par; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 287 | static int __devinit bw2_init_one(struct of_device *op) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 289 | 	struct device_node *dp = op->node; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | 	struct all_info *all; | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 291 | 	int linebytes, err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 293 | 	all = kzalloc(sizeof(*all), GFP_KERNEL); | 
 | 294 | 	if (!all) | 
 | 295 | 		return -ENOMEM; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 |  | 
 | 297 | 	spin_lock_init(&all->par.lock); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 299 | 	all->par.physbase = op->resource[0].start; | 
 | 300 | 	all->par.which_io = op->resource[0].flags & IORESOURCE_BITS; | 
 | 301 |  | 
 | 302 | 	sbusfb_fill_var(&all->info.var, dp->node, 1); | 
 | 303 | 	linebytes = of_getintprop_default(dp, "linebytes", | 
 | 304 | 					  all->info.var.xres); | 
 | 305 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | 	all->info.var.red.length = all->info.var.green.length = | 
 | 307 | 		all->info.var.blue.length = all->info.var.bits_per_pixel; | 
 | 308 | 	all->info.var.red.offset = all->info.var.green.offset = | 
 | 309 | 		all->info.var.blue.offset = 0; | 
 | 310 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 311 | 	all->par.regs = of_ioremap(&op->resource[0], BWTWO_REGISTER_OFFSET, | 
 | 312 | 				   sizeof(struct bw2_regs), "bw2 regs"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 314 | 	if (!of_find_property(dp, "width", NULL)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | 		bw2_do_default_mode(&all->par, &all->info, &linebytes); | 
 | 316 |  | 
 | 317 | 	all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); | 
 | 318 |  | 
 | 319 | 	all->info.flags = FBINFO_DEFAULT; | 
 | 320 | 	all->info.fbops = &bw2_ops; | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 321 |  | 
 | 322 | 	all->info.screen_base = | 
 | 323 | 		sbus_ioremap(&op->resource[0], 0, all->par.fbsize, "bw2 ram"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | 	all->info.par = &all->par; | 
 | 325 |  | 
 | 326 | 	bw2_blank(0, &all->info); | 
 | 327 |  | 
 | 328 | 	bw2_init_fix(&all->info, linebytes); | 
 | 329 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 330 | 	err= register_framebuffer(&all->info); | 
 | 331 | 	if (err < 0) { | 
 | 332 | 		of_iounmap(all->par.regs, sizeof(struct bw2_regs)); | 
 | 333 | 		of_iounmap(all->info.screen_base, all->par.fbsize); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | 		kfree(all); | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 335 | 		return err; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | 	} | 
 | 337 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 338 | 	dev_set_drvdata(&op->dev, all); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 340 | 	printk("%s: bwtwo at %lx:%lx\n", | 
 | 341 | 	       dp->full_name, | 
 | 342 | 	       all->par.which_io, all->par.physbase); | 
 | 343 |  | 
 | 344 | 	return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | } | 
 | 346 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 347 | static int __devinit bw2_probe(struct of_device *dev, const struct of_device_id *match) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | { | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 349 | 	struct of_device *op = to_of_device(&dev->dev); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 351 | 	return bw2_init_one(op); | 
 | 352 | } | 
 | 353 |  | 
 | 354 | static int __devexit bw2_remove(struct of_device *dev) | 
 | 355 | { | 
 | 356 | 	struct all_info *all = dev_get_drvdata(&dev->dev); | 
 | 357 |  | 
 | 358 | 	unregister_framebuffer(&all->info); | 
 | 359 |  | 
 | 360 | 	of_iounmap(all->par.regs, sizeof(struct bw2_regs)); | 
 | 361 | 	of_iounmap(all->info.screen_base, all->par.fbsize); | 
 | 362 |  | 
 | 363 | 	kfree(all); | 
 | 364 |  | 
 | 365 | 	dev_set_drvdata(&dev->dev, NULL); | 
 | 366 |  | 
 | 367 | 	return 0; | 
 | 368 | } | 
 | 369 |  | 
 | 370 | static struct of_device_id bw2_match[] = { | 
 | 371 | 	{ | 
 | 372 | 		.name = "bwtwo", | 
 | 373 | 	}, | 
 | 374 | 	{}, | 
 | 375 | }; | 
 | 376 | MODULE_DEVICE_TABLE(of, bw2_match); | 
 | 377 |  | 
 | 378 | static struct of_platform_driver bw2_driver = { | 
 | 379 | 	.name		= "bw2", | 
 | 380 | 	.match_table	= bw2_match, | 
 | 381 | 	.probe		= bw2_probe, | 
 | 382 | 	.remove		= __devexit_p(bw2_remove), | 
 | 383 | }; | 
 | 384 |  | 
 | 385 | static int __init bw2_init(void) | 
 | 386 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | 	if (fb_get_options("bw2fb", NULL)) | 
 | 388 | 		return -ENODEV; | 
 | 389 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 390 | 	return of_register_driver(&bw2_driver, &of_bus_type); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } | 
 | 392 |  | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 393 | static void __exit bw2_exit(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | { | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 395 | 	return of_unregister_driver(&bw2_driver); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | } | 
 | 397 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 |  | 
 | 399 | module_init(bw2_init); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | module_exit(bw2_exit); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 |  | 
 | 402 | MODULE_DESCRIPTION("framebuffer driver for BWTWO chipsets"); | 
| David S. Miller | 50312ce | 2006-06-29 14:35:52 -0700 | [diff] [blame] | 403 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | 
 | 404 | MODULE_VERSION("2.0"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | MODULE_LICENSE("GPL"); |