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