blob: ca2c54ce508e678ee8deaafa63016c9bae783948 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/slab.h>
52#include <linux/delay.h>
53#include <linux/fb.h>
54#include <linux/init.h>
55#include <linux/ioport.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010056#include <linux/platform_device.h>
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#include <asm/types.h>
59#include <asm/io.h>
60#include <asm/uaccess.h>
61
62#include <video/epson1355.h>
63
64struct epson1355_par {
65 unsigned long reg_addr;
66};
67
68/* ------------------------------------------------------------------------- */
69
70#ifdef CONFIG_SUPERH
71
72static inline u8 epson1355_read_reg(int index)
73{
74 return ctrl_inb(par.reg_addr + index);
75}
76
77static inline void epson1355_write_reg(u8 data, int index)
78{
79 ctrl_outb(data, par.reg_addr + index);
80}
81
82#elif defined(CONFIG_ARM)
83
84# ifdef CONFIG_ARCH_CEIVA
85# include <asm/arch/hardware.h>
86# define EPSON1355FB_BASE_PHYS (CEIVA_PHYS_SED1355)
87# endif
88
89static inline u8 epson1355_read_reg(struct epson1355_par *par, int index)
90{
91 return __raw_readb(par->reg_addr + index);
92}
93
94static inline void epson1355_write_reg(struct epson1355_par *par, u8 data, int index)
95{
96 __raw_writeb(data, par->reg_addr + index);
97}
98
99#else
100# error "no architecture-specific epson1355_{read,write}_reg"
101#endif
102
103#ifndef EPSON1355FB_BASE_PHYS
104# error "EPSON1355FB_BASE_PHYS is not defined"
105#endif
106
107#define EPSON1355FB_REGS_OFS (0)
108#define EPSON1355FB_REGS_PHYS (EPSON1355FB_BASE_PHYS + EPSON1355FB_REGS_OFS)
109#define EPSON1355FB_REGS_LEN (64)
110
111#define EPSON1355FB_FB_OFS (0x00200000)
112#define EPSON1355FB_FB_PHYS (EPSON1355FB_BASE_PHYS + EPSON1355FB_FB_OFS)
113#define EPSON1355FB_FB_LEN (2 * 1024 * 1024)
114
115/* ------------------------------------------------------------------------- */
116
117static inline u16 epson1355_read_reg16(struct epson1355_par *par, int index)
118{
119 u8 lo = epson1355_read_reg(par, index);
120 u8 hi = epson1355_read_reg(par, index + 1);
121
122 return (hi << 8) | lo;
123}
124
125static inline void epson1355_write_reg16(struct epson1355_par *par, u16 data, int index)
126{
127 u8 lo = data & 0xff;
128 u8 hi = (data >> 8) & 0xff;
129
130 epson1355_write_reg(par, lo, index);
131 epson1355_write_reg(par, hi, index + 1);
132}
133
134static inline u32 epson1355_read_reg20(struct epson1355_par *par, int index)
135{
136 u8 b0 = epson1355_read_reg(par, index);
137 u8 b1 = epson1355_read_reg(par, index + 1);
138 u8 b2 = epson1355_read_reg(par, index + 2);
139
140 return (b2 & 0x0f) << 16 | (b1 << 8) | b0;
141}
142
143static inline void epson1355_write_reg20(struct epson1355_par *par, u32 data, int index)
144{
145 u8 b0 = data & 0xff;
146 u8 b1 = (data >> 8) & 0xff;
147 u8 b2 = (data >> 16) & 0x0f;
148
149 epson1355_write_reg(par, b0, index);
150 epson1355_write_reg(par, b1, index + 1);
151 epson1355_write_reg(par, b2, index + 2);
152}
153
154/* ------------------------------------------------------------------------- */
155
156static void set_lut(struct epson1355_par *par, u8 index, u8 r, u8 g, u8 b)
157{
158 epson1355_write_reg(par, index, REG_LUT_ADDR);
159 epson1355_write_reg(par, r, REG_LUT_DATA);
160 epson1355_write_reg(par, g, REG_LUT_DATA);
161 epson1355_write_reg(par, b, REG_LUT_DATA);
162}
163
164
165/**
166 * epson1355fb_setcolreg - sets a color register.
167 * @regno: Which register in the CLUT we are programming
168 * @red: The red value which can be up to 16 bits wide
169 * @green: The green value which can be up to 16 bits wide
170 * @blue: The blue value which can be up to 16 bits wide.
171 * @transp: If supported the alpha value which can be up to 16 bits wide.
172 * @info: frame buffer info structure
173 *
174 * Returns negative errno on error, or zero on success.
175 */
176static int epson1355fb_setcolreg(unsigned regno, unsigned r, unsigned g,
177 unsigned b, unsigned transp,
178 struct fb_info *info)
179{
180 struct epson1355_par *par = info->par;
181
182 if (info->var.grayscale)
183 r = g = b = (19595 * r + 38470 * g + 7471 * b) >> 16;
184
185 switch (info->fix.visual) {
186 case FB_VISUAL_TRUECOLOR:
187 if (regno >= 16)
188 return -EINVAL;
189
190 ((u32 *) info->pseudo_palette)[regno] =
191 (r & 0xf800) | (g & 0xfc00) >> 5 | (b & 0xf800) >> 11;
192
193 break;
194 case FB_VISUAL_PSEUDOCOLOR:
195 if (regno >= 256)
196 return -EINVAL;
197
198 set_lut(par, regno, r >> 8, g >> 8, b >> 8);
199
200 break;
201 default:
202 return -ENOSYS;
203 }
204 return 0;
205}
206
207/* ------------------------------------------------------------------------- */
208
209/**
210 * epson1355fb_pan_display - Pans the display.
211 * @var: frame buffer variable screen structure
212 * @info: frame buffer structure that represents a single frame buffer
213 *
214 * Pan (or wrap, depending on the `vmode' field) the display using the
215 * `xoffset' and `yoffset' fields of the `var' structure.
216 * If the values don't fit, return -EINVAL.
217 *
218 * Returns negative errno on error, or zero on success.
219 */
220static int epson1355fb_pan_display(struct fb_var_screeninfo *var,
221 struct fb_info *info)
222{
223 struct epson1355_par *par = info->par;
224 u32 start;
225
226 if (var->xoffset != 0) /* not yet ... */
227 return -EINVAL;
228
229 if (var->yoffset + info->var.yres > info->var.yres_virtual)
230 return -EINVAL;
231
232 start = (info->fix.line_length >> 1) * var->yoffset;
233
234 epson1355_write_reg20(par, start, REG_SCRN1_DISP_START_ADDR0);
235
236 return 0;
237}
238
239/* ------------------------------------------------------------------------- */
240
241static void lcd_enable(struct epson1355_par *par, int enable)
242{
243 u8 mode = epson1355_read_reg(par, REG_DISPLAY_MODE);
244
245 if (enable)
246 mode |= 1;
247 else
248 mode &= ~1;
249
250 epson1355_write_reg(par, mode, REG_DISPLAY_MODE);
251}
252
253#if defined(CONFIG_ARCH_CEIVA)
254static void backlight_enable(int enable)
255{
256 /* ### this should be protected by a spinlock ... */
257 u8 pddr = clps_readb(PDDR);
258 if (enable)
259 pddr |= (1 << 5);
260 else
261 pddr &= ~(1 << 5);
262 clps_writeb(pddr, PDDR);
263}
264#else
265static void backlight_enable(int enable)
266{
267}
268#endif
269
270
271/**
272 * epson1355fb_blank - blanks the display.
273 * @blank_mode: the blank mode we want.
274 * @info: frame buffer structure that represents a single frame buffer
275 *
276 * Blank the screen if blank_mode != 0, else unblank. Return 0 if
277 * blanking succeeded, != 0 if un-/blanking failed due to e.g. a
278 * video mode which doesn't support it. Implements VESA suspend
279 * and powerdown modes on hardware that supports disabling hsync/vsync:
280 * blank_mode == 2: suspend vsync
281 * blank_mode == 3: suspend hsync
282 * blank_mode == 4: powerdown
283 *
284 * Returns negative errno on error, or zero on success.
285 *
286 */
287static int epson1355fb_blank(int blank_mode, struct fb_info *info)
288{
289 struct epson1355_par *par = info->par;
290
291 switch (blank_mode) {
292 case FB_BLANK_UNBLANKING:
293 case FB_BLANK_NORMAL:
294 lcd_enable(par, 1);
295 backlight_enable(1);
296 break;
297 case FB_BLANK_VSYNC_SUSPEND:
298 case FB_BLANK_HSYNC_SUSPEND:
299 backlight_enable(0);
300 break;
301 case FB_BLANK_POWERDOWN:
302 backlight_enable(0);
303 lcd_enable(par, 0);
304 break;
305 default:
306 return -EINVAL;
307 }
308
309 /* let fbcon do a soft blank for us */
310 return (blank_mode == FB_BLANK_NORMAL) ? 1 : 0;
311}
312
313/* ------------------------------------------------------------------------- */
314
315/*
316 * We can't use the cfb generic routines, as we have to limit
317 * ourselves to 16-bit or 8-bit loads and stores to this 16-bit
318 * chip.
319 */
320
321static inline void epson1355fb_fb_writel(unsigned long v, unsigned long *a)
322{
323 u16 *p = (u16 *) a;
324 u16 l = v & 0xffff;
325 u16 h = v >> 16;
326
327 fb_writew(l, p);
328 fb_writew(h, p + 1);
329}
330
331static inline unsigned long epson1355fb_fb_readl(const unsigned long *a)
332{
333 const u16 *p = (u16 *) a;
334 u16 l = fb_readw(p);
335 u16 h = fb_readw(p + 1);
336
337 return (h << 16) | l;
338}
339
340#define FB_READL epson1355fb_fb_readl
341#define FB_WRITEL epson1355fb_fb_writel
342
343/* ------------------------------------------------------------------------- */
344
345static inline unsigned long copy_from_user16(void *to, const void *from,
346 unsigned long n)
347{
348 u16 *dst = (u16 *) to;
349 u16 *src = (u16 *) from;
350
351 if (!access_ok(VERIFY_READ, from, n))
352 return n;
353
354 while (n > 1) {
355 u16 v;
356 if (__get_user(v, src))
357 return n;
358
359 fb_writew(v, dst);
360
361 src++, dst++;
362 n -= 2;
363 }
364
365 if (n) {
366 u8 v;
367
368 if (__get_user(v, ((u8 *) src)))
369 return n;
370
371 fb_writeb(v, dst);
372 }
373 return 0;
374}
375
376static inline unsigned long copy_to_user16(void *to, const void *from,
377 unsigned long n)
378{
379 u16 *dst = (u16 *) to;
380 u16 *src = (u16 *) from;
381
382 if (!access_ok(VERIFY_WRITE, to, n))
383 return n;
384
385 while (n > 1) {
386 u16 v = fb_readw(src);
387
388 if (__put_user(v, dst))
389 return n;
390
391 src++, dst++;
392 n -= 2;
393 }
394
395 if (n) {
396 u8 v = fb_readb(src);
397
398 if (__put_user(v, ((u8 *) dst)))
399 return n;
400 }
401 return 0;
402}
403
404
405static ssize_t
Antonino A. Daplas3f9b0882007-05-08 00:39:02 -0700406epson1355fb_read(struct fb_info *info, char *buf, size_t count, loff_t * ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 unsigned long p = *ppos;
409
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 if (p >= info->fix.smem_len)
411 return 0;
412 if (count >= info->fix.smem_len)
413 count = info->fix.smem_len;
414 if (count + p > info->fix.smem_len)
415 count = info->fix.smem_len - p;
416
417 if (count) {
418 char *base_addr;
419
420 base_addr = info->screen_base;
421 count -= copy_to_user16(buf, base_addr + p, count);
422 if (!count)
423 return -EFAULT;
424 *ppos += count;
425 }
426 return count;
427}
428
429static ssize_t
Antonino A. Daplas3f9b0882007-05-08 00:39:02 -0700430epson1355fb_write(struct fb_info *info, const char *buf,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 size_t count, loff_t * ppos)
432{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 unsigned long p = *ppos;
434 int err;
435
436 /* from fbmem.c except for our own copy_*_user */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 if (p > info->fix.smem_len)
438 return -ENOSPC;
439 if (count >= info->fix.smem_len)
440 count = info->fix.smem_len;
441 err = 0;
442 if (count + p > info->fix.smem_len) {
443 count = info->fix.smem_len - p;
444 err = -ENOSPC;
445 }
446
447 if (count) {
448 char *base_addr;
449
450 base_addr = info->screen_base;
451 count -= copy_from_user16(base_addr + p, buf, count);
452 *ppos += count;
453 err = -EFAULT;
454 }
455 if (count)
456 return count;
457 return err;
458}
459
460/* ------------------------------------------------------------------------- */
461
462static struct fb_ops epson1355fb_fbops = {
463 .owner = THIS_MODULE,
464 .fb_setcolreg = epson1355fb_setcolreg,
465 .fb_pan_display = epson1355fb_pan_display,
466 .fb_blank = epson1355fb_blank,
467 .fb_fillrect = cfb_fillrect,
468 .fb_copyarea = cfb_copyarea,
469 .fb_imageblit = cfb_imageblit,
470 .fb_read = epson1355fb_read,
471 .fb_write = epson1355fb_write,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472};
473
474/* ------------------------------------------------------------------------- */
475
476static __init unsigned int get_fb_size(struct fb_info *info)
477{
478 unsigned int size = 2 * 1024 * 1024;
479 char *p = info->screen_base;
480
481 /* the 512k framebuffer is aliased at start + 0x80000 * n */
482 fb_writeb(1, p);
483 fb_writeb(0, p + 0x80000);
484 if (!fb_readb(p))
485 size = 512 * 1024;
486
487 fb_writeb(0, p);
488
489 return size;
490}
491
492static int epson1355_width_tab[2][4] __initdata =
493 { {4, 8, 16, -1}, {9, 12, 16, -1} };
494static int epson1355_bpp_tab[8] __initdata = { 1, 2, 4, 8, 15, 16 };
495
496static void __init fetch_hw_state(struct fb_info *info, struct epson1355_par *par)
497{
498 struct fb_var_screeninfo *var = &info->var;
499 struct fb_fix_screeninfo *fix = &info->fix;
500 u8 panel, display;
501 u16 offset;
502 u32 xres, yres;
503 u32 xres_virtual, yres_virtual;
504 int bpp, lcd_bpp;
505 int is_color, is_dual, is_tft;
506 int lcd_enabled, crt_enabled;
507
508 fix->type = FB_TYPE_PACKED_PIXELS;
509
510 display = epson1355_read_reg(par, REG_DISPLAY_MODE);
511 bpp = epson1355_bpp_tab[(display >> 2) & 7];
512
513 switch (bpp) {
514 case 8:
515 fix->visual = FB_VISUAL_PSEUDOCOLOR;
516 var->bits_per_pixel = 8;
517 var->red.offset = var->green.offset = var->blue.offset = 0;
518 var->red.length = var->green.length = var->blue.length = 8;
519 break;
520 case 16:
521 /* 5-6-5 RGB */
522 fix->visual = FB_VISUAL_TRUECOLOR;
523 var->bits_per_pixel = 16;
524 var->red.offset = 11;
525 var->red.length = 5;
526 var->green.offset = 5;
527 var->green.length = 6;
528 var->blue.offset = 0;
529 var->blue.length = 5;
530 break;
531 default:
532 BUG();
533 }
534 fb_alloc_cmap(&(info->cmap), 256, 0);
535
536 panel = epson1355_read_reg(par, REG_PANEL_TYPE);
537 is_color = (panel & 0x04) != 0;
538 is_dual = (panel & 0x02) != 0;
539 is_tft = (panel & 0x01) != 0;
540 crt_enabled = (display & 0x02) != 0;
541 lcd_enabled = (display & 0x01) != 0;
542 lcd_bpp = epson1355_width_tab[is_tft][(panel >> 4) & 3];
543
544 xres = (epson1355_read_reg(par, REG_HORZ_DISP_WIDTH) + 1) * 8;
545 yres = (epson1355_read_reg16(par, REG_VERT_DISP_HEIGHT0) + 1) *
546 ((is_dual && !crt_enabled) ? 2 : 1);
547 offset = epson1355_read_reg16(par, REG_MEM_ADDR_OFFSET0) & 0x7ff;
548 xres_virtual = offset * 16 / bpp;
549 yres_virtual = fix->smem_len / (offset * 2);
550
551 var->xres = xres;
552 var->yres = yres;
553 var->xres_virtual = xres_virtual;
554 var->yres_virtual = yres_virtual;
555 var->xoffset = var->yoffset = 0;
556
557 fix->line_length = offset * 2;
558
559 fix->xpanstep = 0; /* no pan yet */
560 fix->ypanstep = 1;
561 fix->ywrapstep = 0;
562 fix->accel = FB_ACCEL_NONE;
563
564 var->grayscale = !is_color;
565
566#ifdef DEBUG
567 printk(KERN_INFO
568 "epson1355fb: xres=%d, yres=%d, "
569 "is_color=%d, is_dual=%d, is_tft=%d\n",
570 xres, yres, is_color, is_dual, is_tft);
571 printk(KERN_INFO
572 "epson1355fb: bpp=%d, lcd_bpp=%d, "
573 "crt_enabled=%d, lcd_enabled=%d\n",
574 bpp, lcd_bpp, crt_enabled, lcd_enabled);
575#endif
576}
577
578
579static void clearfb16(struct fb_info *info)
580{
581 u16 *dst = (u16 *) info->screen_base;
582 unsigned long n = info->fix.smem_len;
583
584 while (n > 1) {
585 fb_writew(0, dst);
586 dst++, n -= 2;
587 }
588
589 if (n)
590 fb_writeb(0, dst);
591}
592
Russell King3ae5eae2005-11-09 22:32:44 +0000593static int epson1355fb_remove(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594{
Russell King3ae5eae2005-11-09 22:32:44 +0000595 struct fb_info *info = platform_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 struct epson1355_par *par = info->par;
597
598 backlight_enable(0);
599 if (par) {
600 lcd_enable(par, 0);
601 if (par && par->reg_addr)
602 iounmap((void *) par->reg_addr);
603 }
604
605 if (info) {
606 fb_dealloc_cmap(&info->cmap);
607 if (info->screen_base)
608 iounmap(info->screen_base);
609 framebuffer_release(info);
610 }
611 release_mem_region(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN);
612 release_mem_region(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN);
613 return 0;
614}
615
Russell King3ae5eae2005-11-09 22:32:44 +0000616int __init epson1355fb_probe(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 struct epson1355_par *default_par;
619 struct fb_info *info;
620 u8 revision;
621 int rc = 0;
622
623 if (!request_mem_region(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN, "S1D13505 registers")) {
624 printk(KERN_ERR "epson1355fb: unable to reserve "
625 "registers at 0x%0x\n", EPSON1355FB_REGS_PHYS);
626 rc = -EBUSY;
627 goto bail;
628 }
629
630 if (!request_mem_region(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN,
631 "S1D13505 framebuffer")) {
632 printk(KERN_ERR "epson1355fb: unable to reserve "
633 "framebuffer at 0x%0x\n", EPSON1355FB_FB_PHYS);
634 rc = -EBUSY;
635 goto bail;
636 }
637
638 info = framebuffer_alloc(sizeof(struct epson1355_par) + sizeof(u32) * 256, &dev->dev);
Roland Stigge19f3d3a2007-05-08 00:38:31 -0700639 if (!info) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 rc = -ENOMEM;
641 goto bail;
Roland Stigge19f3d3a2007-05-08 00:38:31 -0700642 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643
644 default_par = info->par;
645 default_par->reg_addr = (unsigned long) ioremap(EPSON1355FB_REGS_PHYS, EPSON1355FB_REGS_LEN);
646 if (!default_par->reg_addr) {
647 printk(KERN_ERR "epson1355fb: unable to map registers\n");
648 rc = -ENOMEM;
649 goto bail;
650 }
651 info->pseudo_palette = (void *)(default_par + 1);
652
653 info->screen_base = ioremap(EPSON1355FB_FB_PHYS, EPSON1355FB_FB_LEN);
654 if (!info->screen_base) {
655 printk(KERN_ERR "epson1355fb: unable to map framebuffer\n");
656 rc = -ENOMEM;
657 goto bail;
658 }
659
660 revision = epson1355_read_reg(default_par, REG_REVISION_CODE);
661 if ((revision >> 2) != 3) {
662 printk(KERN_INFO "epson1355fb: epson1355 not found\n");
663 rc = -ENODEV;
664 goto bail;
665 }
666
667 info->fix.mmio_start = EPSON1355FB_REGS_PHYS;
668 info->fix.mmio_len = EPSON1355FB_REGS_LEN;
669 info->fix.smem_start = EPSON1355FB_FB_PHYS;
670 info->fix.smem_len = get_fb_size(info);
671
672 printk(KERN_INFO "epson1355fb: regs mapped at 0x%lx, fb %d KiB mapped at 0x%p\n",
673 default_par->reg_addr, info->fix.smem_len / 1024, info->screen_base);
674
675 strcpy(info->fix.id, "S1D13505");
676 info->par = default_par;
677 info->fbops = &epson1355fb_fbops;
678 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
679
680 /* we expect the boot loader to have initialized the chip
681 with appropriate parameters from which we can determinte
682 the flavor of lcd panel attached */
683 fetch_hw_state(info, default_par);
684
685 /* turn this puppy on ... */
686 clearfb16(info);
687 backlight_enable(1);
688 lcd_enable(default_par, 1);
689
690 if (register_framebuffer(info) < 0) {
691 rc = -EINVAL;
692 goto bail;
693 }
694 /*
695 * Our driver data.
696 */
Russell King3ae5eae2005-11-09 22:32:44 +0000697 platform_set_drvdata(dev, info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698
699 printk(KERN_INFO "fb%d: %s frame buffer device\n",
700 info->node, info->fix.id);
701
702 return 0;
703
704 bail:
Russell King3ae5eae2005-11-09 22:32:44 +0000705 epson1355fb_remove(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 return rc;
707}
708
Russell King3ae5eae2005-11-09 22:32:44 +0000709static struct platform_driver epson1355fb_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .probe = epson1355fb_probe,
711 .remove = epson1355fb_remove,
Russell King3ae5eae2005-11-09 22:32:44 +0000712 .driver = {
713 .name = "epson1355fb",
714 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715};
716
Antonino A. Daplas673681c2006-06-26 00:26:33 -0700717static struct platform_device *epson1355fb_device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718
719int __init epson1355fb_init(void)
720{
721 int ret = 0;
722
723 if (fb_get_options("epson1355fb", NULL))
724 return -ENODEV;
725
Russell King3ae5eae2005-11-09 22:32:44 +0000726 ret = platform_driver_register(&epson1355fb_driver);
Antonino A. Daplas673681c2006-06-26 00:26:33 -0700727
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 if (!ret) {
Antonino A. Daplas673681c2006-06-26 00:26:33 -0700729 epson1355fb_device = platform_device_alloc("epson1355fb", 0);
730
731 if (epson1355fb_device)
732 ret = platform_device_add(epson1355fb_device);
733 else
734 ret = -ENOMEM;
735
736 if (ret) {
737 platform_device_put(epson1355fb_device);
Russell King3ae5eae2005-11-09 22:32:44 +0000738 platform_driver_unregister(&epson1355fb_driver);
Antonino A. Daplas673681c2006-06-26 00:26:33 -0700739 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 }
Antonino A. Daplas673681c2006-06-26 00:26:33 -0700741
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 return ret;
743}
744
745module_init(epson1355fb_init);
746
747#ifdef MODULE
748static void __exit epson1355fb_exit(void)
749{
Antonino A. Daplas673681c2006-06-26 00:26:33 -0700750 platform_device_unregister(epson1355fb_device);
Russell King3ae5eae2005-11-09 22:32:44 +0000751 platform_driver_unregister(&epson1355fb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752}
753
754/* ------------------------------------------------------------------------- */
755
756module_exit(epson1355fb_exit);
757#endif
758
759MODULE_AUTHOR("Christopher Hoover <ch@hpl.hp.com>");
760MODULE_DESCRIPTION("Framebuffer driver for Epson S1D13505");
761MODULE_LICENSE("GPL");