leo.c 15 KB

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