leo.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /* leo.c: LEO frame buffer driver
  2. *
  3. * Copyright (C) 2003, 2006 David S. Miller (davem@davemloft.net)
  4. * Copyright (C) 1996-1999 Jakub Jelinek (jj@ultra.linux.cz)
  5. * Copyright (C) 1997 Michal Rehacek (Michal.Rehacek@st.mff.cuni.cz)
  6. *
  7. * Driver layout based loosely on tgafb.c, see that file for credits.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/kernel.h>
  11. #include <linux/errno.h>
  12. #include <linux/string.h>
  13. #include <linux/slab.h>
  14. #include <linux/delay.h>
  15. #include <linux/init.h>
  16. #include <linux/fb.h>
  17. #include <linux/mm.h>
  18. #include <linux/of_device.h>
  19. #include <linux/io.h>
  20. #include <asm/fbio.h>
  21. #include "sbuslib.h"
  22. /*
  23. * Local functions.
  24. */
  25. static int leo_setcolreg(unsigned, unsigned, unsigned, unsigned,
  26. unsigned, struct fb_info *);
  27. static int leo_blank(int, struct fb_info *);
  28. static int leo_mmap(struct fb_info *, struct vm_area_struct *);
  29. static int leo_ioctl(struct fb_info *, unsigned int, unsigned long);
  30. static int leo_pan_display(struct fb_var_screeninfo *, struct fb_info *);
  31. /*
  32. * Frame buffer operations
  33. */
  34. static struct fb_ops leo_ops = {
  35. .owner = THIS_MODULE,
  36. .fb_setcolreg = leo_setcolreg,
  37. .fb_blank = leo_blank,
  38. .fb_pan_display = leo_pan_display,
  39. .fb_fillrect = cfb_fillrect,
  40. .fb_copyarea = cfb_copyarea,
  41. .fb_imageblit = cfb_imageblit,
  42. .fb_mmap = leo_mmap,
  43. .fb_ioctl = leo_ioctl,
  44. #ifdef CONFIG_COMPAT
  45. .fb_compat_ioctl = sbusfb_compat_ioctl,
  46. #endif
  47. };
  48. #define LEO_OFF_LC_SS0_KRN 0x00200000UL
  49. #define LEO_OFF_LC_SS0_USR 0x00201000UL
  50. #define LEO_OFF_LC_SS1_KRN 0x01200000UL
  51. #define LEO_OFF_LC_SS1_USR 0x01201000UL
  52. #define LEO_OFF_LD_SS0 0x00400000UL
  53. #define LEO_OFF_LD_SS1 0x01400000UL
  54. #define LEO_OFF_LD_GBL 0x00401000UL
  55. #define LEO_OFF_LX_KRN 0x00600000UL
  56. #define LEO_OFF_LX_CURSOR 0x00601000UL
  57. #define LEO_OFF_SS0 0x00800000UL
  58. #define LEO_OFF_SS1 0x01800000UL
  59. #define LEO_OFF_UNK 0x00602000UL
  60. #define LEO_OFF_UNK2 0x00000000UL
  61. #define LEO_CUR_ENABLE 0x00000080
  62. #define LEO_CUR_UPDATE 0x00000030
  63. #define LEO_CUR_PROGRESS 0x00000006
  64. #define LEO_CUR_UPDATECMAP 0x00000003
  65. #define LEO_CUR_TYPE_MASK 0x00000000
  66. #define LEO_CUR_TYPE_IMAGE 0x00000020
  67. #define LEO_CUR_TYPE_CMAP 0x00000050
  68. struct leo_cursor {
  69. u8 xxx0[16];
  70. u32 cur_type;
  71. u32 cur_misc;
  72. u32 cur_cursxy;
  73. u32 cur_data;
  74. };
  75. #define LEO_KRN_TYPE_CLUT0 0x00001000
  76. #define LEO_KRN_TYPE_CLUT1 0x00001001
  77. #define LEO_KRN_TYPE_CLUT2 0x00001002
  78. #define LEO_KRN_TYPE_WID 0x00001003
  79. #define LEO_KRN_TYPE_UNK 0x00001006
  80. #define LEO_KRN_TYPE_VIDEO 0x00002003
  81. #define LEO_KRN_TYPE_CLUTDATA 0x00004000
  82. #define LEO_KRN_CSR_ENABLE 0x00000008
  83. #define LEO_KRN_CSR_PROGRESS 0x00000004
  84. #define LEO_KRN_CSR_UNK 0x00000002
  85. #define LEO_KRN_CSR_UNK2 0x00000001
  86. struct leo_lx_krn {
  87. u32 krn_type;
  88. u32 krn_csr;
  89. u32 krn_value;
  90. };
  91. struct leo_lc_ss0_krn {
  92. u32 misc;
  93. u8 xxx0[0x800-4];
  94. u32 rev;
  95. };
  96. struct leo_lc_ss0_usr {
  97. u32 csr;
  98. u32 addrspace;
  99. u32 fontmsk;
  100. u32 fontt;
  101. u32 extent;
  102. u32 src;
  103. u32 dst;
  104. u32 copy;
  105. u32 fill;
  106. };
  107. struct leo_lc_ss1_krn {
  108. u8 unknown;
  109. };
  110. struct leo_lc_ss1_usr {
  111. u8 unknown;
  112. };
  113. struct leo_ld_ss0 {
  114. u8 xxx0[0xe00];
  115. u32 csr;
  116. u32 wid;
  117. u32 wmask;
  118. u32 widclip;
  119. u32 vclipmin;
  120. u32 vclipmax;
  121. u32 pickmin; /* SS1 only */
  122. u32 pickmax; /* SS1 only */
  123. u32 fg;
  124. u32 bg;
  125. u32 src; /* Copy/Scroll (SS0 only) */
  126. u32 dst; /* Copy/Scroll/Fill (SS0 only) */
  127. u32 extent; /* Copy/Scroll/Fill size (SS0 only) */
  128. u32 xxx1[3];
  129. u32 setsem; /* SS1 only */
  130. u32 clrsem; /* SS1 only */
  131. u32 clrpick; /* SS1 only */
  132. u32 clrdat; /* SS1 only */
  133. u32 alpha; /* SS1 only */
  134. u8 xxx2[0x2c];
  135. u32 winbg;
  136. u32 planemask;
  137. u32 rop;
  138. u32 z;
  139. u32 dczf; /* SS1 only */
  140. u32 dczb; /* SS1 only */
  141. u32 dcs; /* SS1 only */
  142. u32 dczs; /* SS1 only */
  143. u32 pickfb; /* SS1 only */
  144. u32 pickbb; /* SS1 only */
  145. u32 dcfc; /* SS1 only */
  146. u32 forcecol; /* SS1 only */
  147. u32 door[8]; /* SS1 only */
  148. u32 pick[5]; /* SS1 only */
  149. };
  150. #define LEO_SS1_MISC_ENABLE 0x00000001
  151. #define LEO_SS1_MISC_STEREO 0x00000002
  152. struct leo_ld_ss1 {
  153. u8 xxx0[0xef4];
  154. u32 ss1_misc;
  155. };
  156. struct leo_ld_gbl {
  157. u8 unknown;
  158. };
  159. struct leo_par {
  160. spinlock_t lock;
  161. struct leo_lx_krn __iomem *lx_krn;
  162. struct leo_lc_ss0_usr __iomem *lc_ss0_usr;
  163. struct leo_ld_ss0 __iomem *ld_ss0;
  164. struct leo_ld_ss1 __iomem *ld_ss1;
  165. struct leo_cursor __iomem *cursor;
  166. u32 extent;
  167. u32 clut_data[256];
  168. u32 flags;
  169. #define LEO_FLAG_BLANKED 0x00000001
  170. unsigned long physbase;
  171. unsigned long which_io;
  172. unsigned long fbsize;
  173. };
  174. static void leo_wait(struct leo_lx_krn __iomem *lx_krn)
  175. {
  176. int i;
  177. for (i = 0;
  178. (sbus_readl(&lx_krn->krn_csr) & LEO_KRN_CSR_PROGRESS) &&
  179. i < 300000;
  180. i++)
  181. udelay(1); /* Busy wait at most 0.3 sec */
  182. return;
  183. }
  184. static void leo_switch_from_graph(struct fb_info *info)
  185. {
  186. struct leo_par *par = (struct leo_par *) info->par;
  187. struct leo_ld_ss0 __iomem *ss = par->ld_ss0;
  188. struct leo_cursor __iomem *cursor = par->cursor;
  189. unsigned long flags;
  190. u32 val;
  191. spin_lock_irqsave(&par->lock, flags);
  192. par->extent = ((info->var.xres - 1) |
  193. ((info->var.yres - 1) << 16));
  194. sbus_writel(0xffffffff, &ss->wid);
  195. sbus_writel(0xffff, &ss->wmask);
  196. sbus_writel(0, &ss->vclipmin);
  197. sbus_writel(par->extent, &ss->vclipmax);
  198. sbus_writel(0, &ss->fg);
  199. sbus_writel(0xff000000, &ss->planemask);
  200. sbus_writel(0x310850, &ss->rop);
  201. sbus_writel(0, &ss->widclip);
  202. sbus_writel((info->var.xres-1) | ((info->var.yres-1) << 11),
  203. &par->lc_ss0_usr->extent);
  204. sbus_writel(4, &par->lc_ss0_usr->addrspace);
  205. sbus_writel(0x80000000, &par->lc_ss0_usr->fill);
  206. sbus_writel(0, &par->lc_ss0_usr->fontt);
  207. do {
  208. val = sbus_readl(&par->lc_ss0_usr->csr);
  209. } while (val & 0x20000000);
  210. /* setup screen buffer for cfb_* functions */
  211. sbus_writel(1, &ss->wid);
  212. sbus_writel(0x00ffffff, &ss->planemask);
  213. sbus_writel(0x310b90, &ss->rop);
  214. sbus_writel(0, &par->lc_ss0_usr->addrspace);
  215. /* hide cursor */
  216. sbus_writel(sbus_readl(&cursor->cur_misc) & ~LEO_CUR_ENABLE, &cursor->cur_misc);
  217. spin_unlock_irqrestore(&par->lock, flags);
  218. }
  219. static int leo_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
  220. {
  221. /* We just use this to catch switches out of
  222. * graphics mode.
  223. */
  224. leo_switch_from_graph(info);
  225. if (var->xoffset || var->yoffset || var->vmode)
  226. return -EINVAL;
  227. return 0;
  228. }
  229. /**
  230. * leo_setcolreg - Optional function. Sets a color register.
  231. * @regno: boolean, 0 copy local, 1 get_user() function
  232. * @red: frame buffer colormap structure
  233. * @green: The green value which can be up to 16 bits wide
  234. * @blue: The blue value which can be up to 16 bits wide.
  235. * @transp: If supported the alpha value which can be up to 16 bits wide.
  236. * @info: frame buffer info structure
  237. */
  238. static int leo_setcolreg(unsigned regno,
  239. unsigned red, unsigned green, unsigned blue,
  240. unsigned transp, struct fb_info *info)
  241. {
  242. struct leo_par *par = (struct leo_par *) info->par;
  243. struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
  244. unsigned long flags;
  245. u32 val;
  246. int i;
  247. if (regno >= 256)
  248. return 1;
  249. red >>= 8;
  250. green >>= 8;
  251. blue >>= 8;
  252. par->clut_data[regno] = red | (green << 8) | (blue << 16);
  253. spin_lock_irqsave(&par->lock, flags);
  254. leo_wait(lx_krn);
  255. sbus_writel(LEO_KRN_TYPE_CLUTDATA, &lx_krn->krn_type);
  256. for (i = 0; i < 256; i++)
  257. sbus_writel(par->clut_data[i], &lx_krn->krn_value);
  258. sbus_writel(LEO_KRN_TYPE_CLUT0, &lx_krn->krn_type);
  259. val = sbus_readl(&lx_krn->krn_csr);
  260. val |= (LEO_KRN_CSR_UNK | LEO_KRN_CSR_UNK2);
  261. sbus_writel(val, &lx_krn->krn_csr);
  262. spin_unlock_irqrestore(&par->lock, flags);
  263. return 0;
  264. }
  265. /**
  266. * leo_blank - Optional function. Blanks the display.
  267. * @blank_mode: the blank mode we want.
  268. * @info: frame buffer structure that represents a single frame buffer
  269. */
  270. static int leo_blank(int blank, struct fb_info *info)
  271. {
  272. struct leo_par *par = (struct leo_par *) info->par;
  273. struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
  274. unsigned long flags;
  275. u32 val;
  276. spin_lock_irqsave(&par->lock, flags);
  277. switch (blank) {
  278. case FB_BLANK_UNBLANK: /* Unblanking */
  279. val = sbus_readl(&lx_krn->krn_csr);
  280. val |= LEO_KRN_CSR_ENABLE;
  281. sbus_writel(val, &lx_krn->krn_csr);
  282. par->flags &= ~LEO_FLAG_BLANKED;
  283. break;
  284. case FB_BLANK_NORMAL: /* Normal blanking */
  285. case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
  286. case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
  287. case FB_BLANK_POWERDOWN: /* Poweroff */
  288. val = sbus_readl(&lx_krn->krn_csr);
  289. val &= ~LEO_KRN_CSR_ENABLE;
  290. sbus_writel(val, &lx_krn->krn_csr);
  291. par->flags |= LEO_FLAG_BLANKED;
  292. break;
  293. }
  294. spin_unlock_irqrestore(&par->lock, flags);
  295. return 0;
  296. }
  297. static struct sbus_mmap_map leo_mmap_map[] = {
  298. {
  299. .voff = LEO_SS0_MAP,
  300. .poff = LEO_OFF_SS0,
  301. .size = 0x800000
  302. },
  303. {
  304. .voff = LEO_LC_SS0_USR_MAP,
  305. .poff = LEO_OFF_LC_SS0_USR,
  306. .size = 0x1000
  307. },
  308. {
  309. .voff = LEO_LD_SS0_MAP,
  310. .poff = LEO_OFF_LD_SS0,
  311. .size = 0x1000
  312. },
  313. {
  314. .voff = LEO_LX_CURSOR_MAP,
  315. .poff = LEO_OFF_LX_CURSOR,
  316. .size = 0x1000
  317. },
  318. {
  319. .voff = LEO_SS1_MAP,
  320. .poff = LEO_OFF_SS1,
  321. .size = 0x800000
  322. },
  323. {
  324. .voff = LEO_LC_SS1_USR_MAP,
  325. .poff = LEO_OFF_LC_SS1_USR,
  326. .size = 0x1000
  327. },
  328. {
  329. .voff = LEO_LD_SS1_MAP,
  330. .poff = LEO_OFF_LD_SS1,
  331. .size = 0x1000
  332. },
  333. {
  334. .voff = LEO_UNK_MAP,
  335. .poff = LEO_OFF_UNK,
  336. .size = 0x1000
  337. },
  338. {
  339. .voff = LEO_LX_KRN_MAP,
  340. .poff = LEO_OFF_LX_KRN,
  341. .size = 0x1000
  342. },
  343. {
  344. .voff = LEO_LC_SS0_KRN_MAP,
  345. .poff = LEO_OFF_LC_SS0_KRN,
  346. .size = 0x1000
  347. },
  348. {
  349. .voff = LEO_LC_SS1_KRN_MAP,
  350. .poff = LEO_OFF_LC_SS1_KRN,
  351. .size = 0x1000
  352. },
  353. {
  354. .voff = LEO_LD_GBL_MAP,
  355. .poff = LEO_OFF_LD_GBL,
  356. .size = 0x1000
  357. },
  358. {
  359. .voff = LEO_UNK2_MAP,
  360. .poff = LEO_OFF_UNK2,
  361. .size = 0x100000
  362. },
  363. { .size = 0 }
  364. };
  365. static int leo_mmap(struct fb_info *info, struct vm_area_struct *vma)
  366. {
  367. struct leo_par *par = (struct leo_par *)info->par;
  368. return sbusfb_mmap_helper(leo_mmap_map,
  369. par->physbase, par->fbsize,
  370. par->which_io, vma);
  371. }
  372. static int leo_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
  373. {
  374. struct leo_par *par = (struct leo_par *) info->par;
  375. return sbusfb_ioctl_helper(cmd, arg, info,
  376. FBTYPE_SUNLEO, 32, par->fbsize);
  377. }
  378. /*
  379. * Initialisation
  380. */
  381. static void
  382. leo_init_fix(struct fb_info *info, struct device_node *dp)
  383. {
  384. strlcpy(info->fix.id, dp->name, sizeof(info->fix.id));
  385. info->fix.type = FB_TYPE_PACKED_PIXELS;
  386. info->fix.visual = FB_VISUAL_TRUECOLOR;
  387. info->fix.line_length = 8192;
  388. info->fix.accel = FB_ACCEL_SUN_LEO;
  389. }
  390. static void leo_wid_put(struct fb_info *info, struct fb_wid_list *wl)
  391. {
  392. struct leo_par *par = (struct leo_par *) info->par;
  393. struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
  394. struct fb_wid_item *wi;
  395. unsigned long flags;
  396. u32 val;
  397. int i, j;
  398. spin_lock_irqsave(&par->lock, flags);
  399. leo_wait(lx_krn);
  400. for (i = 0, wi = wl->wl_list; i < wl->wl_count; i++, wi++) {
  401. switch (wi->wi_type) {
  402. case FB_WID_DBL_8:
  403. j = (wi->wi_index & 0xf) + 0x40;
  404. break;
  405. case FB_WID_DBL_24:
  406. j = wi->wi_index & 0x3f;
  407. break;
  408. default:
  409. continue;
  410. };
  411. sbus_writel(0x5800 + j, &lx_krn->krn_type);
  412. sbus_writel(wi->wi_values[0], &lx_krn->krn_value);
  413. }
  414. sbus_writel(LEO_KRN_TYPE_WID, &lx_krn->krn_type);
  415. val = sbus_readl(&lx_krn->krn_csr);
  416. val |= (LEO_KRN_CSR_UNK | LEO_KRN_CSR_UNK2);
  417. sbus_writel(val, &lx_krn->krn_csr);
  418. spin_unlock_irqrestore(&par->lock, flags);
  419. }
  420. static void leo_init_wids(struct fb_info *info)
  421. {
  422. struct fb_wid_item wi;
  423. struct fb_wid_list wl;
  424. wl.wl_count = 1;
  425. wl.wl_list = &wi;
  426. wi.wi_type = FB_WID_DBL_8;
  427. wi.wi_index = 0;
  428. wi.wi_values [0] = 0x2c0;
  429. leo_wid_put(info, &wl);
  430. wi.wi_index = 1;
  431. wi.wi_values [0] = 0x30;
  432. leo_wid_put(info, &wl);
  433. wi.wi_index = 2;
  434. wi.wi_values [0] = 0x20;
  435. leo_wid_put(info, &wl);
  436. wi.wi_type = FB_WID_DBL_24;
  437. wi.wi_index = 1;
  438. wi.wi_values [0] = 0x30;
  439. leo_wid_put(info, &wl);
  440. }
  441. static void leo_init_hw(struct fb_info *info)
  442. {
  443. struct leo_par *par = (struct leo_par *) info->par;
  444. u32 val;
  445. val = sbus_readl(&par->ld_ss1->ss1_misc);
  446. val |= LEO_SS1_MISC_ENABLE;
  447. sbus_writel(val, &par->ld_ss1->ss1_misc);
  448. leo_switch_from_graph(info);
  449. }
  450. static void leo_fixup_var_rgb(struct fb_var_screeninfo *var)
  451. {
  452. var->red.offset = 0;
  453. var->red.length = 8;
  454. var->green.offset = 8;
  455. var->green.length = 8;
  456. var->blue.offset = 16;
  457. var->blue.length = 8;
  458. var->transp.offset = 0;
  459. var->transp.length = 0;
  460. }
  461. static void leo_unmap_regs(struct of_device *op, struct fb_info *info,
  462. struct leo_par *par)
  463. {
  464. if (par->lc_ss0_usr)
  465. of_iounmap(&op->resource[0], par->lc_ss0_usr, 0x1000);
  466. if (par->ld_ss0)
  467. of_iounmap(&op->resource[0], par->ld_ss0, 0x1000);
  468. if (par->ld_ss1)
  469. of_iounmap(&op->resource[0], par->ld_ss1, 0x1000);
  470. if (par->lx_krn)
  471. of_iounmap(&op->resource[0], par->lx_krn, 0x1000);
  472. if (par->cursor)
  473. of_iounmap(&op->resource[0],
  474. par->cursor, sizeof(struct leo_cursor));
  475. if (info->screen_base)
  476. of_iounmap(&op->resource[0], info->screen_base, 0x800000);
  477. }
  478. static int __devinit leo_probe(struct of_device *op,
  479. const struct of_device_id *match)
  480. {
  481. struct device_node *dp = op->node;
  482. struct fb_info *info;
  483. struct leo_par *par;
  484. int linebytes, err;
  485. info = framebuffer_alloc(sizeof(struct leo_par), &op->dev);
  486. err = -ENOMEM;
  487. if (!info)
  488. goto out_err;
  489. par = info->par;
  490. spin_lock_init(&par->lock);
  491. par->physbase = op->resource[0].start;
  492. par->which_io = op->resource[0].flags & IORESOURCE_BITS;
  493. sbusfb_fill_var(&info->var, dp, 32);
  494. leo_fixup_var_rgb(&info->var);
  495. linebytes = of_getintprop_default(dp, "linebytes",
  496. info->var.xres);
  497. par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
  498. par->lc_ss0_usr =
  499. of_ioremap(&op->resource[0], LEO_OFF_LC_SS0_USR,
  500. 0x1000, "leolc ss0usr");
  501. par->ld_ss0 =
  502. of_ioremap(&op->resource[0], LEO_OFF_LD_SS0,
  503. 0x1000, "leold ss0");
  504. par->ld_ss1 =
  505. of_ioremap(&op->resource[0], LEO_OFF_LD_SS1,
  506. 0x1000, "leold ss1");
  507. par->lx_krn =
  508. of_ioremap(&op->resource[0], LEO_OFF_LX_KRN,
  509. 0x1000, "leolx krn");
  510. par->cursor =
  511. of_ioremap(&op->resource[0], LEO_OFF_LX_CURSOR,
  512. sizeof(struct leo_cursor), "leolx cursor");
  513. info->screen_base =
  514. of_ioremap(&op->resource[0], LEO_OFF_SS0,
  515. 0x800000, "leo ram");
  516. if (!par->lc_ss0_usr ||
  517. !par->ld_ss0 ||
  518. !par->ld_ss1 ||
  519. !par->lx_krn ||
  520. !par->cursor ||
  521. !info->screen_base)
  522. goto out_unmap_regs;
  523. info->flags = FBINFO_DEFAULT;
  524. info->fbops = &leo_ops;
  525. info->pseudo_palette = par->clut_data;
  526. leo_init_wids(info);
  527. leo_init_hw(info);
  528. leo_blank(FB_BLANK_UNBLANK, info);
  529. if (fb_alloc_cmap(&info->cmap, 256, 0))
  530. goto out_unmap_regs;
  531. leo_init_fix(info, dp);
  532. err = register_framebuffer(info);
  533. if (err < 0)
  534. goto out_dealloc_cmap;
  535. dev_set_drvdata(&op->dev, info);
  536. printk(KERN_INFO "%s: leo at %lx:%lx\n",
  537. dp->full_name,
  538. par->which_io, par->physbase);
  539. return 0;
  540. out_dealloc_cmap:
  541. fb_dealloc_cmap(&info->cmap);
  542. out_unmap_regs:
  543. leo_unmap_regs(op, info, par);
  544. framebuffer_release(info);
  545. out_err:
  546. return err;
  547. }
  548. static int __devexit leo_remove(struct of_device *op)
  549. {
  550. struct fb_info *info = dev_get_drvdata(&op->dev);
  551. struct leo_par *par = info->par;
  552. unregister_framebuffer(info);
  553. fb_dealloc_cmap(&info->cmap);
  554. leo_unmap_regs(op, info, par);
  555. framebuffer_release(info);
  556. dev_set_drvdata(&op->dev, NULL);
  557. return 0;
  558. }
  559. static const struct of_device_id leo_match[] = {
  560. {
  561. .name = "SUNW,leo",
  562. },
  563. {},
  564. };
  565. MODULE_DEVICE_TABLE(of, leo_match);
  566. static struct of_platform_driver leo_driver = {
  567. .name = "leo",
  568. .match_table = leo_match,
  569. .probe = leo_probe,
  570. .remove = __devexit_p(leo_remove),
  571. };
  572. static int __init leo_init(void)
  573. {
  574. if (fb_get_options("leofb", NULL))
  575. return -ENODEV;
  576. return of_register_driver(&leo_driver, &of_bus_type);
  577. }
  578. static void __exit leo_exit(void)
  579. {
  580. of_unregister_driver(&leo_driver);
  581. }
  582. module_init(leo_init);
  583. module_exit(leo_exit);
  584. MODULE_DESCRIPTION("framebuffer driver for LEO chipsets");
  585. MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
  586. MODULE_VERSION("2.0");
  587. MODULE_LICENSE("GPL");