vserver 1.9.3
[linux-2.6.git] / drivers / video / epson1355fb.c
1 /*
2  * linux/drivers/video/epson1355fb.c -- Epson S1D13505 frame buffer for 2.5.
3  *
4  * Epson Research S1D13505 Embedded RAMDAC LCD/CRT Controller
5  *   (previously known as SED1355)
6  *
7  * Cf. http://www.erd.epson.com/vdc/html/S1D13505.html
8  *
9  *
10  * Copyright (C) Hewlett-Packard Company.  All rights reserved.
11  *
12  * Written by Christopher Hoover <ch@hpl.hp.com>
13  *
14  * Adapted from:
15  *
16  *  linux/drivers/video/skeletonfb.c
17  *  Modified to new api Jan 2001 by James Simmons (jsimmons@infradead.org)
18  *  Created 28 Dec 1997 by Geert Uytterhoeven
19  *
20  *  linux/drivers/video/epson1355fb.c (2.4 driver)
21  *  Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
22  *
23  * This file is subject to the terms and conditions of the GNU General Public
24  * License. See the file COPYING in the main directory of this archive for
25  * more details.
26  *
27  *
28  * Noteworthy Issues
29  * -----------------
30  *
31  * This driver is complicated by the fact that this is a 16-bit chip
32  * and, on at least one platform (ceiva), we can only do 16-bit reads
33  * and writes to the framebuffer.  We hide this from user space
34  * except in the case of mmap().
35  *
36  *
37  * To Do
38  * -----
39  *
40  * - Test 8-bit pseudocolor mode
41  * - Allow setting bpp, virtual resolution
42  * - Implement horizontal panning
43  * - (maybe) Implement hardware cursor
44  */
45
46 #include <linux/module.h>
47 #include <linux/kernel.h>
48 #include <linux/errno.h>
49 #include <linux/string.h>
50 #include <linux/mm.h>
51 #include <linux/tty.h>
52 #include <linux/slab.h>
53 #include <linux/delay.h>
54 #include <linux/fb.h>
55 #include <linux/init.h>
56 #include <linux/ioport.h>
57 #include <asm/types.h>
58 #include <asm/io.h>
59 #include <asm/uaccess.h>
60
61 #include <video/epson1355.h>
62
63 struct epson1355_par {
64         unsigned long reg_addr;
65 };
66
67 /* ------------------------------------------------------------------------- */
68
69 #ifdef CONFIG_SUPERH
70
71 static inline u8 epson1355_read_reg(int index)
72 {
73         return ctrl_inb(par.reg_addr + index);
74 }
75
76 static inline void epson1355_write_reg(u8 data, int index)
77 {
78         ctrl_outb(data, par.reg_addr + index);
79 }
80
81 #elif defined(CONFIG_ARM)
82
83 # ifdef CONFIG_ARCH_CEIVA
84 #  include <asm/arch/hardware.h>
85 #  define EPSON1355FB_BASE_PHYS (CEIVA_PHYS_SED1355)
86 # endif
87
88 static inline u8 epson1355_read_reg(struct epson1355_par *par, int index)
89 {
90         return __raw_readb(par->reg_addr + index);
91 }
92
93 static inline void epson1355_write_reg(struct epson1355_par *par, u8 data, int index)
94 {
95         __raw_writeb(data, par->reg_addr + index);
96 }
97
98 #else
99 # error "no architecture-specific epson1355_{read,write}_reg"
100 #endif
101
102 #ifndef EPSON1355FB_BASE_PHYS
103 # error  "EPSON1355FB_BASE_PHYS is not defined"
104 #endif
105
106 #define EPSON1355FB_REGS_OFS    (0)
107 #define EPSON1355FB_REGS_PHYS   (EPSON1355FB_BASE_PHYS + EPSON1355FB_REGS_OFS)
108 #define EPSON1355FB_REGS_LEN    (64)
109
110 #define EPSON1355FB_FB_OFS      (0x00200000)
111 #define EPSON1355FB_FB_PHYS     (EPSON1355FB_BASE_PHYS + EPSON1355FB_FB_OFS)
112 #define EPSON1355FB_FB_LEN      (2 * 1024 * 1024)
113
114 /* ------------------------------------------------------------------------- */
115
116 static inline u16 epson1355_read_reg16(struct epson1355_par *par, int index)
117 {
118         u8 lo = epson1355_read_reg(par, index);
119         u8 hi = epson1355_read_reg(par, index + 1);
120
121         return (hi << 8) | lo;
122 }
123
124 static inline void epson1355_write_reg16(struct epson1355_par *par, u16 data, int index)
125 {
126         u8 lo = data & 0xff;
127         u8 hi = (data >> 8) & 0xff;
128
129         epson1355_write_reg(par, lo, index);
130         epson1355_write_reg(par, hi, index + 1);
131 }
132
133 static inline u32 epson1355_read_reg20(struct epson1355_par *par, int index)
134 {
135         u8 b0 = epson1355_read_reg(par, index);
136         u8 b1 = epson1355_read_reg(par, index + 1);
137         u8 b2 = epson1355_read_reg(par, index + 2);
138
139         return (b2 & 0x0f) << 16 | (b1 << 8) | b0;
140 }
141
142 static inline void epson1355_write_reg20(struct epson1355_par *par, u32 data, int index)
143 {
144         u8 b0 = data & 0xff;
145         u8 b1 = (data >> 8) & 0xff;
146         u8 b2 = (data >> 16) & 0x0f;
147
148         epson1355_write_reg(par, b0, index);
149         epson1355_write_reg(par, b1, index + 1);
150         epson1355_write_reg(par, b2, index + 2);
151 }
152
153 /* ------------------------------------------------------------------------- */
154
155 static void set_lut(struct epson1355_par *par, u8 index, u8 r, u8 g, u8 b)
156 {
157         epson1355_write_reg(par, index, REG_LUT_ADDR);
158         epson1355_write_reg(par, r, REG_LUT_DATA);
159         epson1355_write_reg(par, g, REG_LUT_DATA);
160         epson1355_write_reg(par, b, REG_LUT_DATA);
161 }
162
163
164 /**
165  *      epson1355fb_setcolreg - sets a color register.
166  *      @regno: Which register in the CLUT we are programming
167  *      @red: The red value which can be up to 16 bits wide
168  *      @green: The green value which can be up to 16 bits wide
169  *      @blue:  The blue value which can be up to 16 bits wide.
170  *      @transp: If supported the alpha value which can be up to 16 bits wide.
171  *      @info: frame buffer info structure
172  *
173  *      Returns negative errno on error, or zero on success.
174  */
175 static int epson1355fb_setcolreg(unsigned regno, unsigned r, unsigned g,
176                                  unsigned b, unsigned transp,
177                                  struct fb_info *info)
178 {
179         struct epson1355_par *par = info->par;
180
181         if (info->var.grayscale)
182                 r = g = b = (19595 * r + 38470 * g + 7471 * b) >> 16;
183
184         switch (info->fix.visual) {
185         case FB_VISUAL_TRUECOLOR:
186                 if (regno >= 16)
187                         return -EINVAL;
188
189                 ((u32 *) info->pseudo_palette)[regno] =
190                     (r & 0xf800) | (g & 0xfc00) >> 5 | (b & 0xf800) >> 11;
191
192                 break;
193         case FB_VISUAL_PSEUDOCOLOR:
194                 if (regno >= 256)
195                         return -EINVAL;
196
197                 set_lut(par, regno, r >> 8, g >> 8, b >> 8);
198
199                 break;
200         default:
201                 return -ENOSYS;
202         }
203         return 0;
204 }
205
206 /* ------------------------------------------------------------------------- */
207
208 /**
209  *      epson1355fb_pan_display - Pans the display.
210  *      @var: frame buffer variable screen structure
211  *      @info: frame buffer structure that represents a single frame buffer
212  *
213  *      Pan (or wrap, depending on the `vmode' field) the display using the
214  *      `xoffset' and `yoffset' fields of the `var' structure.
215  *      If the values don't fit, return -EINVAL.
216  *
217  *      Returns negative errno on error, or zero on success.
218  */
219 static int epson1355fb_pan_display(struct fb_var_screeninfo *var,
220                                    struct fb_info *info)
221 {
222         struct epson1355_par *par = info->par;
223         u32 start;
224
225         if (var->xoffset != 0)  /* not yet ... */
226                 return -EINVAL;
227
228         if (var->yoffset + info->var.yres > info->var.yres_virtual)
229                 return -EINVAL;
230
231         start = (info->fix.line_length >> 1) * var->yoffset;
232
233         epson1355_write_reg20(par, start, REG_SCRN1_DISP_START_ADDR0);
234
235         return 0;
236 }
237
238 /* ------------------------------------------------------------------------- */
239
240 static void lcd_enable(struct epson1355_par *par, int enable)
241 {
242         u8 mode = epson1355_read_reg(par, REG_DISPLAY_MODE);
243
244         if (enable)
245                 mode |= 1;
246         else
247                 mode &= ~1;
248
249         epson1355_write_reg(par, mode, REG_DISPLAY_MODE);
250 }
251
252 #if defined(CONFIG_ARCH_CEIVA)
253 static void backlight_enable(int enable)
254 {
255         /* ### this should be protected by a spinlock ... */
256         u8 pddr = clps_readb(PDDR);
257         if (enable)
258                 pddr |= (1 << 5);
259         else
260                 pddr &= ~(1 << 5);
261         clps_writeb(pddr, PDDR);
262 }
263 #else
264 static void backlight_enable(int enable)
265 {
266 }
267 #endif
268
269
270 /**
271  *      epson1355fb_blank - blanks the display.
272  *      @blank_mode: the blank mode we want.
273  *      @info: frame buffer structure that represents a single frame buffer
274  *
275  *      Blank the screen if blank_mode != 0, else unblank. Return 0 if
276  *      blanking succeeded, != 0 if un-/blanking failed due to e.g. a
277  *      video mode which doesn't support it. Implements VESA suspend
278  *      and powerdown modes on hardware that supports disabling hsync/vsync:
279  *      blank_mode == 2: suspend vsync
280  *      blank_mode == 3: suspend hsync
281  *      blank_mode == 4: powerdown
282  *
283  *      Returns negative errno on error, or zero on success.
284  *
285  */
286 static int epson1355fb_blank(int blank_mode, struct fb_info *info)
287 {
288         struct epson1355_par *par = info->par;
289
290         switch (blank_mode) {
291         case VESA_NO_BLANKING:
292                 lcd_enable(par, 1);
293                 backlight_enable(1);
294                 break;
295         case VESA_VSYNC_SUSPEND:
296         case VESA_HSYNC_SUSPEND:
297                 backlight_enable(0);
298                 break;
299         case VESA_POWERDOWN:
300                 backlight_enable(0);
301                 lcd_enable(par, 0);
302                 break;
303         default:
304                 return -EINVAL;
305         }
306         return 0;
307 }
308
309 /* ------------------------------------------------------------------------- */
310
311 /*
312  * We can't use the cfb generic routines, as we have to limit
313  * ourselves to 16-bit or 8-bit loads and stores to this 16-bit
314  * chip.
315  */
316
317 static inline void epson1355fb_fb_writel(unsigned long v, unsigned long *a)
318 {
319         u16 *p = (u16 *) a;
320         u16 l = v & 0xffff;
321         u16 h = v >> 16;
322
323         fb_writew(l, p);
324         fb_writew(h, p + 1);
325 }
326
327 static inline unsigned long epson1355fb_fb_readl(const unsigned long *a)
328 {
329         const u16 *p = (u16 *) a;
330         u16 l = fb_readw(p);
331         u16 h = fb_readw(p + 1);
332
333         return (h << 16) | l;
334 }
335
336 #define FB_READL epson1355fb_fb_readl
337 #define FB_WRITEL epson1355fb_fb_writel
338
339 /* ------------------------------------------------------------------------- */
340
341 static inline unsigned long copy_from_user16(void *to, const void *from,
342                                              unsigned long n)
343 {
344         u16 *dst = (u16 *) to;
345         u16 *src = (u16 *) from;
346
347         if (!access_ok(VERIFY_READ, from, n))
348                 return n;
349
350         while (n > 1) {
351                 u16 v;
352                 if (__get_user(v, src))
353                         return n;
354
355                 fb_writew(v, dst);
356
357                 src++, dst++;
358                 n -= 2;
359         }
360
361         if (n) {
362                 u8 v;
363
364                 if (__get_user(v, ((u8 *) src)))
365                         return n;
366
367                 fb_writeb(v, dst);
368         }
369         return 0;
370 }
371
372 static inline unsigned long copy_to_user16(void *to, const void *from,
373                                            unsigned long n)
374 {
375         u16 *dst = (u16 *) to;
376         u16 *src = (u16 *) from;
377
378         if (!access_ok(VERIFY_WRITE, to, n))
379                 return n;
380
381         while (n > 1) {
382                 u16 v = fb_readw(src);
383
384                 if (__put_user(v, dst))
385                         return n;
386
387                 src++, dst++;
388                 n -= 2;
389         }
390
391         if (n) {
392                 u8 v = fb_readb(src);
393
394                 if (__put_user(v, ((u8 *) dst)))
395                         return n;
396         }
397         return 0;
398 }
399
400
401 static ssize_t
402 epson1355fb_read(struct file *file, char *buf, size_t count, loff_t * ppos)
403 {
404         struct inode *inode = file->f_dentry->d_inode;
405         int fbidx = iminor(inode);
406         struct fb_info *info = registered_fb[fbidx];
407         unsigned long p = *ppos;
408
409         /* from fbmem.c except for our own copy_*_user */
410         if (!info || !info->screen_base)
411                 return -ENODEV;
412
413         if (p >= info->fix.smem_len)
414                 return 0;
415         if (count >= info->fix.smem_len)
416                 count = info->fix.smem_len;
417         if (count + p > info->fix.smem_len)
418                 count = info->fix.smem_len - p;
419
420         if (count) {
421                 char *base_addr;
422
423                 base_addr = info->screen_base;
424                 count -= copy_to_user16(buf, base_addr + p, count);
425                 if (!count)
426                         return -EFAULT;
427                 *ppos += count;
428         }
429         return count;
430 }
431
432 static ssize_t
433 epson1355fb_write(struct file *file, const char *buf,
434                   size_t count, loff_t * ppos)
435 {
436         struct inode *inode = file->f_dentry->d_inode;
437         int fbidx = iminor(inode);
438         struct fb_info *info = registered_fb[fbidx];
439         unsigned long p = *ppos;
440         int err;
441
442         /* from fbmem.c except for our own copy_*_user */
443         if (!info || !info->screen_base)
444                 return -ENODEV;
445
446         /* from fbmem.c except for our own copy_*_user */
447         if (p > info->fix.smem_len)
448                 return -ENOSPC;
449         if (count >= info->fix.smem_len)
450                 count = info->fix.smem_len;
451         err = 0;
452         if (count + p > info->fix.smem_len) {
453                 count = info->fix.smem_len - p;
454                 err = -ENOSPC;
455         }
456
457         if (count) {
458                 char *base_addr;
459
460                 base_addr = info->screen_base;
461                 count -= copy_from_user16(base_addr + p, buf, count);
462                 *ppos += count;
463                 err = -EFAULT;
464         }
465         if (count)
466                 return count;
467         return err;
468 }
469
470 /* ------------------------------------------------------------------------- */
471
472 static struct fb_ops epson1355fb_fbops = {
473         .owner          = THIS_MODULE,
474         .fb_setcolreg   = epson1355fb_setcolreg,
475         .fb_pan_display = epson1355fb_pan_display,
476         .fb_blank       = epson1355fb_blank,
477         .fb_fillrect    = cfb_fillrect,
478         .fb_copyarea    = cfb_copyarea,
479         .fb_imageblit   = cfb_imageblit,
480         .fb_read        = epson1355fb_read,
481         .fb_write       = epson1355fb_write,
482         .fb_cursor      = soft_cursor,
483 };
484
485 /* ------------------------------------------------------------------------- */
486
487 static __init unsigned int get_fb_size(struct fb_info *info)
488 {
489         unsigned int size = 2 * 1024 * 1024;
490         char *p = info->screen_base;
491
492         /* the 512k framebuffer is aliased at start + 0x80000 * n */
493         fb_writeb(1, p);
494         fb_writeb(0, p + 0x80000);
495         if (!fb_readb(p))
496                 size = 512 * 1024;
497
498         fb_writeb(0, p);
499
500         return size;
501 }
502
503 static int epson1355_width_tab[2][4] __initdata =
504     { {4, 8, 16, -1}, {9, 12, 16, -1} };
505 static int epson1355_bpp_tab[8] __initdata = { 1, 2, 4, 8, 15, 16 };
506
507 static void __init fetch_hw_state(struct fb_info *info, struct epson1355_par *par)
508 {
509         struct fb_var_screeninfo *var = &info->var;
510         struct fb_fix_screeninfo *fix = &info->fix;
511         u8 panel, display;
512         u16 offset;
513         u32 xres, yres;
514         u32 xres_virtual, yres_virtual;
515         int bpp, lcd_bpp;
516         int is_color, is_dual, is_tft;
517         int lcd_enabled, crt_enabled;
518
519         fix->type = FB_TYPE_PACKED_PIXELS;
520
521         display = epson1355_read_reg(par, REG_DISPLAY_MODE);
522         bpp = epson1355_bpp_tab[(display >> 2) & 7];
523
524         switch (bpp) {
525         case 8:
526                 fix->visual = FB_VISUAL_PSEUDOCOLOR;
527                 var->bits_per_pixel = 8;
528                 var->red.offset = var->green.offset = var->blue.offset = 0;
529                 var->red.length = var->green.length = var->blue.length = 8;
530                 break;
531         case 16:
532                 /* 5-6-5 RGB */
533                 fix->visual = FB_VISUAL_TRUECOLOR;
534                 var->bits_per_pixel = 16;
535                 var->red.offset = 11;
536                 var->red.length = 5;
537                 var->green.offset = 5;
538                 var->green.length = 6;
539                 var->blue.offset = 0;
540                 var->blue.length = 5;
541                 break;
542         default:
543                 BUG();
544         }
545         fb_alloc_cmap(&(info->cmap), 256, 0);
546
547         panel = epson1355_read_reg(par, REG_PANEL_TYPE);
548         is_color = (panel & 0x04) != 0;
549         is_dual = (panel & 0x02) != 0;
550         is_tft = (panel & 0x01) != 0;
551         crt_enabled = (display & 0x02) != 0;
552         lcd_enabled = (display & 0x01) != 0;
553         lcd_bpp = epson1355_width_tab[is_tft][(panel >> 4) & 3];
554
555         xres = (epson1355_read_reg(par, REG_HORZ_DISP_WIDTH) + 1) * 8;
556         yres = (epson1355_read_reg16(par, REG_VERT_DISP_HEIGHT0) + 1) *
557             ((is_dual && !crt_enabled) ? 2 : 1);
558         offset = epson1355_read_reg16(par, REG_MEM_ADDR_OFFSET0) & 0x7ff;
559         xres_virtual = offset * 16 / bpp;
560         yres_virtual = fix->smem_len / (offset * 2);
561
562         var->xres = xres;
563         var->yres = yres;
564         var->xres_virtual = xres_virtual;
565         var->yres_virtual = yres_virtual;
566         var->xoffset = var->yoffset = 0;
567
568         fix->line_length = offset * 2;
569
570         fix->xpanstep = 0;      /* no pan yet */
571         fix->ypanstep = 1;
572         fix->ywrapstep = 0;
573         fix->accel = FB_ACCEL_NONE;
574
575         var->grayscale = !is_color;
576
577 #ifdef DEBUG
578         printk(KERN_INFO
579                "epson1355fb: xres=%d, yres=%d, "
580                "is_color=%d, is_dual=%d, is_tft=%d\n",
581                xres, yres, is_color, is_dual, is_tft);
582         printk(KERN_INFO
583                "epson1355fb: bpp=%d, lcd_bpp=%d, "
584                "crt_enabled=%d, lcd_enabled=%d\n",
585                bpp, lcd_bpp, crt_enabled, lcd_enabled);
586 #endif
587 }
588
589
590 static void clearfb16(struct fb_info *info)
591 {
592         u16 *dst = (u16 *) info->screen_base;
593         unsigned long n = info->fix.smem_len;
594
595         while (n > 1) {
596                 fb_writew(0, dst);
597                 dst++, n -= 2;
598         }
599
600         if (n)
601                 fb_writeb(0, dst);
602 }
603
604 static void epson1355fb_platform_release(struct device *device)
605 {
606 }
607
608 static int epson1355fb_remove(struct device *device)
609 {
610         struct fb_info *info = dev_get_drvdata(device);
611         struct epson1355_par *par = info->par;
612
613         backlight_enable(0);
614         if (par) {
615                 lcd_enable(par, 0);
616                 if (par && par->reg_addr)
617                         iounmap((void *) par->reg_addr);
618         }
619
620         if (info) {
621                 fb_dealloc_cmap(&info->cmap);
622                 if (info->screen_base)
623                         iounmap(info->screen_base);
624                 framebuffer_release(info);
625         }
626         release_mem_region(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN);
627         release_mem_region(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN);
628         return 0;
629 }
630
631 int __init epson1355fb_probe(struct device *device)
632 {
633         struct platform_device *dev = to_platform_device(device);
634         struct epson1355_par *default_par;
635         struct fb_info *info;
636         u8 revision;
637         int rc = 0;
638
639         if (!request_mem_region(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN, "S1D13505 registers")) {
640                 printk(KERN_ERR "epson1355fb: unable to reserve "
641                        "registers at 0x%0x\n", EPSON1355FB_REGS_PHYS);
642                 rc = -EBUSY;
643                 goto bail;
644         }
645
646         if (!request_mem_region(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN,
647                                 "S1D13505 framebuffer")) {
648                 printk(KERN_ERR "epson1355fb: unable to reserve "
649                        "framebuffer at 0x%0x\n", EPSON1355FB_FB_PHYS);
650                 rc = -EBUSY;
651                 goto bail;
652         }
653
654         info = framebuffer_alloc(sizeof(struct epson1355_par) + sizeof(u32) * 256, &dev->dev);
655         if (!info)
656                 rc = -ENOMEM;
657                 goto bail;
658
659         default_par = info->par;
660         default_par->reg_addr = (unsigned long) ioremap(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN);
661         if (!default_par->reg_addr) {
662                 printk(KERN_ERR "epson1355fb: unable to map registers\n");
663                 rc = -ENOMEM;
664                 goto bail;
665         }
666         info->pseudo_palette = (void *)(default_par + 1);
667
668         info->screen_base = ioremap(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN);
669         if (!info->screen_base) {
670                 printk(KERN_ERR "epson1355fb: unable to map framebuffer\n");
671                 rc = -ENOMEM;
672                 goto bail;
673         }
674
675         revision = epson1355_read_reg(default_par, REG_REVISION_CODE);
676         if ((revision >> 2) != 3) {
677                 printk(KERN_INFO "epson1355fb: epson1355 not found\n");
678                 rc = -ENODEV;
679                 goto bail;
680         }
681
682         info->fix.mmio_start = EPSON1355FB_REGS_PHYS;
683         info->fix.mmio_len = EPSON1355FB_REGS_LEN;
684         info->fix.smem_start = EPSON1355FB_FB_PHYS;
685         info->fix.smem_len = get_fb_size(info);
686
687         printk(KERN_INFO "epson1355fb: regs mapped at 0x%lx, fb %d KiB mapped at 0x%p\n",
688                default_par->reg_addr, info->fix.smem_len / 1024, info->screen_base);
689
690         strcpy(info->fix.id, "S1D13505");
691         info->par = default_par;
692         info->fbops = &epson1355fb_fbops;
693         info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
694
695         /* we expect the boot loader to have initialized the chip
696            with appropriate parameters from which we can determinte
697            the flavor of lcd panel attached */
698         fetch_hw_state(info, default_par);
699
700         /* turn this puppy on ... */
701         clearfb16(info);
702         backlight_enable(1);
703         lcd_enable(default_par, 1);
704
705         if (register_framebuffer(info) < 0) {
706                 rc = -EINVAL;
707                 goto bail;
708         }
709         /*
710          * Our driver data.
711          */
712         dev_set_drvdata(&dev->dev, info);
713
714         printk(KERN_INFO "fb%d: %s frame buffer device\n",
715                info->node, info->fix.id);
716
717         return 0;
718
719       bail:
720         epson1355fb_remove(device);
721         return rc;
722 }
723
724 static struct device_driver epson1355fb_driver = {
725         .name   = "epson1355fb",
726         .bus    = &platform_bus_type,
727         .probe  = epson1355fb_probe,
728         .remove = epson1355fb_remove,
729 };
730
731 static struct platform_device epson1355fb_device = {
732         .name   = "epson1355fb",
733         .id     = 0,
734         .dev    = {
735                 .release = epson1355fb_platform_release,
736         }
737 };
738
739 int __init epson1355fb_init(void)
740 {
741         int ret = 0;
742
743         if (fb_get_options("epson1355fb", NULL))
744                 return -ENODEV;
745
746         ret = driver_register(&epson1355fb_driver);
747         if (!ret) {
748                 ret = platform_device_register(&epson1355fb_device);
749                 if (ret)
750                         driver_unregister(&epson1355fb_driver);
751         }
752         return ret;
753 }
754
755 module_init(epson1355fb_init);
756         
757 #ifdef MODULE
758 static void __exit epson1355fb_exit(void)
759 {
760         platform_device_unregister(&epson1355fb_device);
761         driver_unregister(&epson1355fb_driver);
762 }
763
764 /* ------------------------------------------------------------------------- */
765
766 module_exit(epson1355fb_exit);
767 #endif
768
769 MODULE_AUTHOR("Christopher Hoover <ch@hpl.hp.com>");
770 MODULE_DESCRIPTION("Framebuffer driver for Epson S1D13505");
771 MODULE_LICENSE("GPL");