leo.c 15 KB

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