leo.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* leo.c: LEO frame buffer driver
  3. *
  4. * Copyright (C) 2003, 2006 David S. Miller ([email protected])
  5. * Copyright (C) 1996-1999 Jakub Jelinek ([email protected])
  6. * Copyright (C) 1997 Michal Rehacek ([email protected])
  7. *
  8. * Driver layout based loosely on tgafb.c, see that file for credits.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/string.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 const 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 which_io;
  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. static void leo_switch_from_graph(struct fb_info *info)
  183. {
  184. struct leo_par *par = (struct leo_par *) info->par;
  185. struct leo_ld_ss0 __iomem *ss = par->ld_ss0;
  186. struct leo_cursor __iomem *cursor = par->cursor;
  187. unsigned long flags;
  188. u32 val;
  189. spin_lock_irqsave(&par->lock, flags);
  190. par->extent = ((info->var.xres - 1) |
  191. ((info->var.yres - 1) << 16));
  192. sbus_writel(0xffffffff, &ss->wid);
  193. sbus_writel(0xffff, &ss->wmask);
  194. sbus_writel(0, &ss->vclipmin);
  195. sbus_writel(par->extent, &ss->vclipmax);
  196. sbus_writel(0, &ss->fg);
  197. sbus_writel(0xff000000, &ss->planemask);
  198. sbus_writel(0x310850, &ss->rop);
  199. sbus_writel(0, &ss->widclip);
  200. sbus_writel((info->var.xres-1) | ((info->var.yres-1) << 11),
  201. &par->lc_ss0_usr->extent);
  202. sbus_writel(4, &par->lc_ss0_usr->addrspace);
  203. sbus_writel(0x80000000, &par->lc_ss0_usr->fill);
  204. sbus_writel(0, &par->lc_ss0_usr->fontt);
  205. do {
  206. val = sbus_readl(&par->lc_ss0_usr->csr);
  207. } while (val & 0x20000000);
  208. /* setup screen buffer for cfb_* functions */
  209. sbus_writel(1, &ss->wid);
  210. sbus_writel(0x00ffffff, &ss->planemask);
  211. sbus_writel(0x310b90, &ss->rop);
  212. sbus_writel(0, &par->lc_ss0_usr->addrspace);
  213. /* hide cursor */
  214. sbus_writel(sbus_readl(&cursor->cur_misc) & ~LEO_CUR_ENABLE, &cursor->cur_misc);
  215. spin_unlock_irqrestore(&par->lock, flags);
  216. }
  217. static int leo_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
  218. {
  219. /* We just use this to catch switches out of
  220. * graphics mode.
  221. */
  222. leo_switch_from_graph(info);
  223. if (var->xoffset || var->yoffset || var->vmode)
  224. return -EINVAL;
  225. return 0;
  226. }
  227. /**
  228. * leo_setcolreg - Optional function. Sets a color register.
  229. * @regno: boolean, 0 copy local, 1 get_user() function
  230. * @red: frame buffer colormap structure
  231. * @green: The green value which can be up to 16 bits wide
  232. * @blue: The blue value which can be up to 16 bits wide.
  233. * @transp: If supported the alpha value which can be up to 16 bits wide.
  234. * @info: frame buffer info structure
  235. */
  236. static int leo_setcolreg(unsigned regno,
  237. unsigned red, unsigned green, unsigned blue,
  238. unsigned transp, struct fb_info *info)
  239. {
  240. struct leo_par *par = (struct leo_par *) info->par;
  241. struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
  242. unsigned long flags;
  243. u32 val;
  244. int i;
  245. if (regno >= 256)
  246. return 1;
  247. red >>= 8;
  248. green >>= 8;
  249. blue >>= 8;
  250. par->clut_data[regno] = red | (green << 8) | (blue << 16);
  251. spin_lock_irqsave(&par->lock, flags);
  252. leo_wait(lx_krn);
  253. sbus_writel(LEO_KRN_TYPE_CLUTDATA, &lx_krn->krn_type);
  254. for (i = 0; i < 256; i++)
  255. sbus_writel(par->clut_data[i], &lx_krn->krn_value);
  256. sbus_writel(LEO_KRN_TYPE_CLUT0, &lx_krn->krn_type);
  257. val = sbus_readl(&lx_krn->krn_csr);
  258. val |= (LEO_KRN_CSR_UNK | LEO_KRN_CSR_UNK2);
  259. sbus_writel(val, &lx_krn->krn_csr);
  260. spin_unlock_irqrestore(&par->lock, flags);
  261. return 0;
  262. }
  263. /**
  264. * leo_blank - Optional function. Blanks the display.
  265. * @blank: the blank mode we want.
  266. * @info: frame buffer structure that represents a single frame buffer
  267. */
  268. static int leo_blank(int blank, struct fb_info *info)
  269. {
  270. struct leo_par *par = (struct leo_par *) info->par;
  271. struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
  272. unsigned long flags;
  273. u32 val;
  274. spin_lock_irqsave(&par->lock, flags);
  275. switch (blank) {
  276. case FB_BLANK_UNBLANK: /* Unblanking */
  277. val = sbus_readl(&lx_krn->krn_csr);
  278. val |= LEO_KRN_CSR_ENABLE;
  279. sbus_writel(val, &lx_krn->krn_csr);
  280. par->flags &= ~LEO_FLAG_BLANKED;
  281. break;
  282. case FB_BLANK_NORMAL: /* Normal blanking */
  283. case FB_BLANK_VSYNC_SUSPEND: /* VESA blank (vsync off) */
  284. case FB_BLANK_HSYNC_SUSPEND: /* VESA blank (hsync off) */
  285. case FB_BLANK_POWERDOWN: /* Poweroff */
  286. val = sbus_readl(&lx_krn->krn_csr);
  287. val &= ~LEO_KRN_CSR_ENABLE;
  288. sbus_writel(val, &lx_krn->krn_csr);
  289. par->flags |= LEO_FLAG_BLANKED;
  290. break;
  291. }
  292. spin_unlock_irqrestore(&par->lock, flags);
  293. return 0;
  294. }
  295. static struct sbus_mmap_map leo_mmap_map[] = {
  296. {
  297. .voff = LEO_SS0_MAP,
  298. .poff = LEO_OFF_SS0,
  299. .size = 0x800000
  300. },
  301. {
  302. .voff = LEO_LC_SS0_USR_MAP,
  303. .poff = LEO_OFF_LC_SS0_USR,
  304. .size = 0x1000
  305. },
  306. {
  307. .voff = LEO_LD_SS0_MAP,
  308. .poff = LEO_OFF_LD_SS0,
  309. .size = 0x1000
  310. },
  311. {
  312. .voff = LEO_LX_CURSOR_MAP,
  313. .poff = LEO_OFF_LX_CURSOR,
  314. .size = 0x1000
  315. },
  316. {
  317. .voff = LEO_SS1_MAP,
  318. .poff = LEO_OFF_SS1,
  319. .size = 0x800000
  320. },
  321. {
  322. .voff = LEO_LC_SS1_USR_MAP,
  323. .poff = LEO_OFF_LC_SS1_USR,
  324. .size = 0x1000
  325. },
  326. {
  327. .voff = LEO_LD_SS1_MAP,
  328. .poff = LEO_OFF_LD_SS1,
  329. .size = 0x1000
  330. },
  331. {
  332. .voff = LEO_UNK_MAP,
  333. .poff = LEO_OFF_UNK,
  334. .size = 0x1000
  335. },
  336. {
  337. .voff = LEO_LX_KRN_MAP,
  338. .poff = LEO_OFF_LX_KRN,
  339. .size = 0x1000
  340. },
  341. {
  342. .voff = LEO_LC_SS0_KRN_MAP,
  343. .poff = LEO_OFF_LC_SS0_KRN,
  344. .size = 0x1000
  345. },
  346. {
  347. .voff = LEO_LC_SS1_KRN_MAP,
  348. .poff = LEO_OFF_LC_SS1_KRN,
  349. .size = 0x1000
  350. },
  351. {
  352. .voff = LEO_LD_GBL_MAP,
  353. .poff = LEO_OFF_LD_GBL,
  354. .size = 0x1000
  355. },
  356. {
  357. .voff = LEO_UNK2_MAP,
  358. .poff = LEO_OFF_UNK2,
  359. .size = 0x100000
  360. },
  361. { .size = 0 }
  362. };
  363. static int leo_mmap(struct fb_info *info, struct vm_area_struct *vma)
  364. {
  365. struct leo_par *par = (struct leo_par *)info->par;
  366. return sbusfb_mmap_helper(leo_mmap_map,
  367. info->fix.smem_start, info->fix.smem_len,
  368. par->which_io, vma);
  369. }
  370. static int leo_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
  371. {
  372. return sbusfb_ioctl_helper(cmd, arg, info,
  373. FBTYPE_SUNLEO, 32, info->fix.smem_len);
  374. }
  375. /*
  376. * Initialisation
  377. */
  378. static void
  379. leo_init_fix(struct fb_info *info, struct device_node *dp)
  380. {
  381. snprintf(info->fix.id, sizeof(info->fix.id), "%pOFn", dp);
  382. info->fix.type = FB_TYPE_PACKED_PIXELS;
  383. info->fix.visual = FB_VISUAL_TRUECOLOR;
  384. info->fix.line_length = 8192;
  385. info->fix.accel = FB_ACCEL_SUN_LEO;
  386. }
  387. static void leo_wid_put(struct fb_info *info, struct fb_wid_list *wl)
  388. {
  389. struct leo_par *par = (struct leo_par *) info->par;
  390. struct leo_lx_krn __iomem *lx_krn = par->lx_krn;
  391. struct fb_wid_item *wi;
  392. unsigned long flags;
  393. u32 val;
  394. int i, j;
  395. spin_lock_irqsave(&par->lock, flags);
  396. leo_wait(lx_krn);
  397. for (i = 0, wi = wl->wl_list; i < wl->wl_count; i++, wi++) {
  398. switch (wi->wi_type) {
  399. case FB_WID_DBL_8:
  400. j = (wi->wi_index & 0xf) + 0x40;
  401. break;
  402. case FB_WID_DBL_24:
  403. j = wi->wi_index & 0x3f;
  404. break;
  405. default:
  406. continue;
  407. }
  408. sbus_writel(0x5800 + j, &lx_krn->krn_type);
  409. sbus_writel(wi->wi_values[0], &lx_krn->krn_value);
  410. }
  411. sbus_writel(LEO_KRN_TYPE_WID, &lx_krn->krn_type);
  412. val = sbus_readl(&lx_krn->krn_csr);
  413. val |= (LEO_KRN_CSR_UNK | LEO_KRN_CSR_UNK2);
  414. sbus_writel(val, &lx_krn->krn_csr);
  415. spin_unlock_irqrestore(&par->lock, flags);
  416. }
  417. static void leo_init_wids(struct fb_info *info)
  418. {
  419. struct fb_wid_item wi;
  420. struct fb_wid_list wl;
  421. wl.wl_count = 1;
  422. wl.wl_list = &wi;
  423. wi.wi_type = FB_WID_DBL_8;
  424. wi.wi_index = 0;
  425. wi.wi_values [0] = 0x2c0;
  426. leo_wid_put(info, &wl);
  427. wi.wi_index = 1;
  428. wi.wi_values [0] = 0x30;
  429. leo_wid_put(info, &wl);
  430. wi.wi_index = 2;
  431. wi.wi_values [0] = 0x20;
  432. leo_wid_put(info, &wl);
  433. wi.wi_type = FB_WID_DBL_24;
  434. wi.wi_index = 1;
  435. wi.wi_values [0] = 0x30;
  436. leo_wid_put(info, &wl);
  437. }
  438. static void leo_init_hw(struct fb_info *info)
  439. {
  440. struct leo_par *par = (struct leo_par *) info->par;
  441. u32 val;
  442. val = sbus_readl(&par->ld_ss1->ss1_misc);
  443. val |= LEO_SS1_MISC_ENABLE;
  444. sbus_writel(val, &par->ld_ss1->ss1_misc);
  445. leo_switch_from_graph(info);
  446. }
  447. static void leo_fixup_var_rgb(struct fb_var_screeninfo *var)
  448. {
  449. var->red.offset = 0;
  450. var->red.length = 8;
  451. var->green.offset = 8;
  452. var->green.length = 8;
  453. var->blue.offset = 16;
  454. var->blue.length = 8;
  455. var->transp.offset = 0;
  456. var->transp.length = 0;
  457. }
  458. static void leo_unmap_regs(struct platform_device *op, struct fb_info *info,
  459. struct leo_par *par)
  460. {
  461. if (par->lc_ss0_usr)
  462. of_iounmap(&op->resource[0], par->lc_ss0_usr, 0x1000);
  463. if (par->ld_ss0)
  464. of_iounmap(&op->resource[0], par->ld_ss0, 0x1000);
  465. if (par->ld_ss1)
  466. of_iounmap(&op->resource[0], par->ld_ss1, 0x1000);
  467. if (par->lx_krn)
  468. of_iounmap(&op->resource[0], par->lx_krn, 0x1000);
  469. if (par->cursor)
  470. of_iounmap(&op->resource[0],
  471. par->cursor, sizeof(struct leo_cursor));
  472. if (info->screen_base)
  473. of_iounmap(&op->resource[0], info->screen_base, 0x800000);
  474. }
  475. static int leo_probe(struct platform_device *op)
  476. {
  477. struct device_node *dp = op->dev.of_node;
  478. struct fb_info *info;
  479. struct leo_par *par;
  480. int linebytes, err;
  481. info = framebuffer_alloc(sizeof(struct leo_par), &op->dev);
  482. err = -ENOMEM;
  483. if (!info)
  484. goto out_err;
  485. par = info->par;
  486. spin_lock_init(&par->lock);
  487. info->fix.smem_start = op->resource[0].start;
  488. par->which_io = op->resource[0].flags & IORESOURCE_BITS;
  489. sbusfb_fill_var(&info->var, dp, 32);
  490. leo_fixup_var_rgb(&info->var);
  491. linebytes = of_getintprop_default(dp, "linebytes",
  492. info->var.xres);
  493. info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres);
  494. par->lc_ss0_usr =
  495. of_ioremap(&op->resource[0], LEO_OFF_LC_SS0_USR,
  496. 0x1000, "leolc ss0usr");
  497. par->ld_ss0 =
  498. of_ioremap(&op->resource[0], LEO_OFF_LD_SS0,
  499. 0x1000, "leold ss0");
  500. par->ld_ss1 =
  501. of_ioremap(&op->resource[0], LEO_OFF_LD_SS1,
  502. 0x1000, "leold ss1");
  503. par->lx_krn =
  504. of_ioremap(&op->resource[0], LEO_OFF_LX_KRN,
  505. 0x1000, "leolx krn");
  506. par->cursor =
  507. of_ioremap(&op->resource[0], LEO_OFF_LX_CURSOR,
  508. sizeof(struct leo_cursor), "leolx cursor");
  509. info->screen_base =
  510. of_ioremap(&op->resource[0], LEO_OFF_SS0,
  511. 0x800000, "leo ram");
  512. if (!par->lc_ss0_usr ||
  513. !par->ld_ss0 ||
  514. !par->ld_ss1 ||
  515. !par->lx_krn ||
  516. !par->cursor ||
  517. !info->screen_base)
  518. goto out_unmap_regs;
  519. info->flags = FBINFO_DEFAULT;
  520. info->fbops = &leo_ops;
  521. info->pseudo_palette = par->clut_data;
  522. leo_init_wids(info);
  523. leo_init_hw(info);
  524. leo_blank(FB_BLANK_UNBLANK, info);
  525. if (fb_alloc_cmap(&info->cmap, 256, 0))
  526. goto out_unmap_regs;
  527. leo_init_fix(info, dp);
  528. err = register_framebuffer(info);
  529. if (err < 0)
  530. goto out_dealloc_cmap;
  531. dev_set_drvdata(&op->dev, info);
  532. printk(KERN_INFO "%pOF: leo at %lx:%lx\n",
  533. dp,
  534. par->which_io, info->fix.smem_start);
  535. return 0;
  536. out_dealloc_cmap:
  537. fb_dealloc_cmap(&info->cmap);
  538. out_unmap_regs:
  539. leo_unmap_regs(op, info, par);
  540. framebuffer_release(info);
  541. out_err:
  542. return err;
  543. }
  544. static int leo_remove(struct platform_device *op)
  545. {
  546. struct fb_info *info = dev_get_drvdata(&op->dev);
  547. struct leo_par *par = info->par;
  548. unregister_framebuffer(info);
  549. fb_dealloc_cmap(&info->cmap);
  550. leo_unmap_regs(op, info, par);
  551. framebuffer_release(info);
  552. return 0;
  553. }
  554. static const struct of_device_id leo_match[] = {
  555. {
  556. .name = "SUNW,leo",
  557. },
  558. {},
  559. };
  560. MODULE_DEVICE_TABLE(of, leo_match);
  561. static struct platform_driver leo_driver = {
  562. .driver = {
  563. .name = "leo",
  564. .of_match_table = leo_match,
  565. },
  566. .probe = leo_probe,
  567. .remove = leo_remove,
  568. };
  569. static int __init leo_init(void)
  570. {
  571. if (fb_get_options("leofb", NULL))
  572. return -ENODEV;
  573. return platform_driver_register(&leo_driver);
  574. }
  575. static void __exit leo_exit(void)
  576. {
  577. platform_driver_unregister(&leo_driver);
  578. }
  579. module_init(leo_init);
  580. module_exit(leo_exit);
  581. MODULE_DESCRIPTION("framebuffer driver for LEO chipsets");
  582. MODULE_AUTHOR("David S. Miller <[email protected]>");
  583. MODULE_VERSION("2.0");
  584. MODULE_LICENSE("GPL");