epson1355fb.c 18 KB

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