leo.c 15 KB

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