leo.c 15 KB

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