cg14.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /* cg14.c: CGFOURTEEN frame buffer driver
  2. *
  3. * Copyright (C) 2003 David S. Miller (davem@redhat.com)
  4. * Copyright (C) 1996,1998 Jakub Jelinek (jj@ultra.linux.cz)
  5. * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx)
  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 cg14_setcolreg(unsigned, unsigned, unsigned, unsigned,
  27. unsigned, struct fb_info *);
  28. static int cg14_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
  29. static int cg14_ioctl(struct inode *, struct file *, unsigned int,
  30. unsigned long, struct fb_info *);
  31. static int cg14_pan_display(struct fb_var_screeninfo *, struct fb_info *);
  32. /*
  33. * Frame buffer operations
  34. */
  35. static struct fb_ops cg14_ops = {
  36. .owner = THIS_MODULE,
  37. .fb_setcolreg = cg14_setcolreg,
  38. .fb_pan_display = cg14_pan_display,
  39. .fb_fillrect = cfb_fillrect,
  40. .fb_copyarea = cfb_copyarea,
  41. .fb_imageblit = cfb_imageblit,
  42. .fb_mmap = cg14_mmap,
  43. .fb_ioctl = cg14_ioctl,
  44. .fb_cursor = soft_cursor,
  45. };
  46. #define CG14_MCR_INTENABLE_SHIFT 7
  47. #define CG14_MCR_INTENABLE_MASK 0x80
  48. #define CG14_MCR_VIDENABLE_SHIFT 6
  49. #define CG14_MCR_VIDENABLE_MASK 0x40
  50. #define CG14_MCR_PIXMODE_SHIFT 4
  51. #define CG14_MCR_PIXMODE_MASK 0x30
  52. #define CG14_MCR_TMR_SHIFT 2
  53. #define CG14_MCR_TMR_MASK 0x0c
  54. #define CG14_MCR_TMENABLE_SHIFT 1
  55. #define CG14_MCR_TMENABLE_MASK 0x02
  56. #define CG14_MCR_RESET_SHIFT 0
  57. #define CG14_MCR_RESET_MASK 0x01
  58. #define CG14_REV_REVISION_SHIFT 4
  59. #define CG14_REV_REVISION_MASK 0xf0
  60. #define CG14_REV_IMPL_SHIFT 0
  61. #define CG14_REV_IMPL_MASK 0x0f
  62. #define CG14_VBR_FRAMEBASE_SHIFT 12
  63. #define CG14_VBR_FRAMEBASE_MASK 0x00fff000
  64. #define CG14_VMCR1_SETUP_SHIFT 0
  65. #define CG14_VMCR1_SETUP_MASK 0x000001ff
  66. #define CG14_VMCR1_VCONFIG_SHIFT 9
  67. #define CG14_VMCR1_VCONFIG_MASK 0x00000e00
  68. #define CG14_VMCR2_REFRESH_SHIFT 0
  69. #define CG14_VMCR2_REFRESH_MASK 0x00000001
  70. #define CG14_VMCR2_TESTROWCNT_SHIFT 1
  71. #define CG14_VMCR2_TESTROWCNT_MASK 0x00000002
  72. #define CG14_VMCR2_FBCONFIG_SHIFT 2
  73. #define CG14_VMCR2_FBCONFIG_MASK 0x0000000c
  74. #define CG14_VCR_REFRESHREQ_SHIFT 0
  75. #define CG14_VCR_REFRESHREQ_MASK 0x000003ff
  76. #define CG14_VCR1_REFRESHENA_SHIFT 10
  77. #define CG14_VCR1_REFRESHENA_MASK 0x00000400
  78. #define CG14_VCA_CAD_SHIFT 0
  79. #define CG14_VCA_CAD_MASK 0x000003ff
  80. #define CG14_VCA_VERS_SHIFT 10
  81. #define CG14_VCA_VERS_MASK 0x00000c00
  82. #define CG14_VCA_RAMSPEED_SHIFT 12
  83. #define CG14_VCA_RAMSPEED_MASK 0x00001000
  84. #define CG14_VCA_8MB_SHIFT 13
  85. #define CG14_VCA_8MB_MASK 0x00002000
  86. #define CG14_MCR_PIXMODE_8 0
  87. #define CG14_MCR_PIXMODE_16 2
  88. #define CG14_MCR_PIXMODE_32 3
  89. struct cg14_regs{
  90. volatile u8 mcr; /* Master Control Reg */
  91. volatile u8 ppr; /* Packed Pixel Reg */
  92. volatile u8 tms[2]; /* Test Mode Status Regs */
  93. volatile u8 msr; /* Master Status Reg */
  94. volatile u8 fsr; /* Fault Status Reg */
  95. volatile u8 rev; /* Revision & Impl */
  96. volatile u8 ccr; /* Clock Control Reg */
  97. volatile u32 tmr; /* Test Mode Read Back */
  98. volatile u8 mod; /* Monitor Operation Data Reg */
  99. volatile u8 acr; /* Aux Control */
  100. u8 xxx0[6];
  101. volatile u16 hct; /* Hor Counter */
  102. volatile u16 vct; /* Vert Counter */
  103. volatile u16 hbs; /* Hor Blank Start */
  104. volatile u16 hbc; /* Hor Blank Clear */
  105. volatile u16 hss; /* Hor Sync Start */
  106. volatile u16 hsc; /* Hor Sync Clear */
  107. volatile u16 csc; /* Composite Sync Clear */
  108. volatile u16 vbs; /* Vert Blank Start */
  109. volatile u16 vbc; /* Vert Blank Clear */
  110. volatile u16 vss; /* Vert Sync Start */
  111. volatile u16 vsc; /* Vert Sync Clear */
  112. volatile u16 xcs;
  113. volatile u16 xcc;
  114. volatile u16 fsa; /* Fault Status Address */
  115. volatile u16 adr; /* Address Registers */
  116. u8 xxx1[0xce];
  117. volatile u8 pcg[0x100]; /* Pixel Clock Generator */
  118. volatile u32 vbr; /* Frame Base Row */
  119. volatile u32 vmcr; /* VBC Master Control */
  120. volatile u32 vcr; /* VBC refresh */
  121. volatile u32 vca; /* VBC Config */
  122. };
  123. #define CG14_CCR_ENABLE 0x04
  124. #define CG14_CCR_SELECT 0x02 /* HW/Full screen */
  125. struct cg14_cursor {
  126. volatile u32 cpl0[32]; /* Enable plane 0 */
  127. volatile u32 cpl1[32]; /* Color selection plane */
  128. volatile u8 ccr; /* Cursor Control Reg */
  129. u8 xxx0[3];
  130. volatile u16 cursx; /* Cursor x,y position */
  131. volatile u16 cursy; /* Cursor x,y position */
  132. volatile u32 color0;
  133. volatile u32 color1;
  134. u32 xxx1[0x1bc];
  135. volatile u32 cpl0i[32]; /* Enable plane 0 autoinc */
  136. volatile u32 cpl1i[32]; /* Color selection autoinc */
  137. };
  138. struct cg14_dac {
  139. volatile u8 addr; /* Address Register */
  140. u8 xxx0[255];
  141. volatile u8 glut; /* Gamma table */
  142. u8 xxx1[255];
  143. volatile u8 select; /* Register Select */
  144. u8 xxx2[255];
  145. volatile u8 mode; /* Mode Register */
  146. };
  147. struct cg14_xlut{
  148. volatile u8 x_xlut [256];
  149. volatile u8 x_xlutd [256];
  150. u8 xxx0[0x600];
  151. volatile u8 x_xlut_inc [256];
  152. volatile u8 x_xlutd_inc [256];
  153. };
  154. /* Color look up table (clut) */
  155. /* Each one of these arrays hold the color lookup table (for 256
  156. * colors) for each MDI page (I assume then there should be 4 MDI
  157. * pages, I still wonder what they are. I have seen NeXTStep split
  158. * the screen in four parts, while operating in 24 bits mode. Each
  159. * integer holds 4 values: alpha value (transparency channel, thanks
  160. * go to John Stone (johns@umr.edu) from OpenBSD), red, green and blue
  161. *
  162. * I currently use the clut instead of the Xlut
  163. */
  164. struct cg14_clut {
  165. u32 c_clut [256];
  166. u32 c_clutd [256]; /* i wonder what the 'd' is for */
  167. u32 c_clut_inc [256];
  168. u32 c_clutd_inc [256];
  169. };
  170. #define CG14_MMAP_ENTRIES 16
  171. struct cg14_par {
  172. spinlock_t lock;
  173. struct cg14_regs __iomem *regs;
  174. struct cg14_clut __iomem *clut;
  175. struct cg14_cursor __iomem *cursor;
  176. u32 flags;
  177. #define CG14_FLAG_BLANKED 0x00000001
  178. unsigned long physbase;
  179. unsigned long iospace;
  180. unsigned long fbsize;
  181. struct sbus_mmap_map mmap_map[CG14_MMAP_ENTRIES];
  182. int mode;
  183. int ramsize;
  184. struct sbus_dev *sdev;
  185. struct list_head list;
  186. };
  187. static void __cg14_reset(struct cg14_par *par)
  188. {
  189. struct cg14_regs __iomem *regs = par->regs;
  190. u8 val;
  191. val = sbus_readb(&regs->mcr);
  192. val &= ~(CG14_MCR_PIXMODE_MASK);
  193. sbus_writeb(val, &regs->mcr);
  194. }
  195. static int cg14_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
  196. {
  197. struct cg14_par *par = (struct cg14_par *) info->par;
  198. unsigned long flags;
  199. /* We just use this to catch switches out of
  200. * graphics mode.
  201. */
  202. spin_lock_irqsave(&par->lock, flags);
  203. __cg14_reset(par);
  204. spin_unlock_irqrestore(&par->lock, flags);
  205. if (var->xoffset || var->yoffset || var->vmode)
  206. return -EINVAL;
  207. return 0;
  208. }
  209. /**
  210. * cg14_setcolreg - Optional function. Sets a color register.
  211. * @regno: boolean, 0 copy local, 1 get_user() function
  212. * @red: frame buffer colormap structure
  213. * @green: The green value which can be up to 16 bits wide
  214. * @blue: The blue value which can be up to 16 bits wide.
  215. * @transp: If supported the alpha value which can be up to 16 bits wide.
  216. * @info: frame buffer info structure
  217. */
  218. static int cg14_setcolreg(unsigned regno,
  219. unsigned red, unsigned green, unsigned blue,
  220. unsigned transp, struct fb_info *info)
  221. {
  222. struct cg14_par *par = (struct cg14_par *) info->par;
  223. struct cg14_clut __iomem *clut = par->clut;
  224. unsigned long flags;
  225. u32 val;
  226. if (regno >= 256)
  227. return 1;
  228. red >>= 8;
  229. green >>= 8;
  230. blue >>= 8;
  231. val = (red | (green << 8) | (blue << 16));
  232. spin_lock_irqsave(&par->lock, flags);
  233. sbus_writel(val, &clut->c_clut[regno]);
  234. spin_unlock_irqrestore(&par->lock, flags);
  235. return 0;
  236. }
  237. static int cg14_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma)
  238. {
  239. struct cg14_par *par = (struct cg14_par *) info->par;
  240. return sbusfb_mmap_helper(par->mmap_map,
  241. par->physbase, par->fbsize,
  242. par->iospace, vma);
  243. }
  244. static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
  245. unsigned long arg, struct fb_info *info)
  246. {
  247. struct cg14_par *par = (struct cg14_par *) info->par;
  248. struct cg14_regs __iomem *regs = par->regs;
  249. struct mdi_cfginfo kmdi, __user *mdii;
  250. unsigned long flags;
  251. int cur_mode, mode, ret = 0;
  252. switch (cmd) {
  253. case MDI_RESET:
  254. spin_lock_irqsave(&par->lock, flags);
  255. __cg14_reset(par);
  256. spin_unlock_irqrestore(&par->lock, flags);
  257. break;
  258. case MDI_GET_CFGINFO:
  259. memset(&kmdi, 0, sizeof(kmdi));
  260. spin_lock_irqsave(&par->lock, flags);
  261. kmdi.mdi_type = FBTYPE_MDICOLOR;
  262. kmdi.mdi_height = info->var.yres;
  263. kmdi.mdi_width = info->var.xres;
  264. kmdi.mdi_mode = par->mode;
  265. kmdi.mdi_pixfreq = 72; /* FIXME */
  266. kmdi.mdi_size = par->ramsize;
  267. spin_unlock_irqrestore(&par->lock, flags);
  268. mdii = (struct mdi_cfginfo __user *) arg;
  269. if (copy_to_user(mdii, &kmdi, sizeof(kmdi)))
  270. ret = -EFAULT;
  271. break;
  272. case MDI_SET_PIXELMODE:
  273. if (get_user(mode, (int __user *) arg)) {
  274. ret = -EFAULT;
  275. break;
  276. }
  277. spin_lock_irqsave(&par->lock, flags);
  278. cur_mode = sbus_readb(&regs->mcr);
  279. cur_mode &= ~CG14_MCR_PIXMODE_MASK;
  280. switch(mode) {
  281. case MDI_32_PIX:
  282. cur_mode |= (CG14_MCR_PIXMODE_32 <<
  283. CG14_MCR_PIXMODE_SHIFT);
  284. break;
  285. case MDI_16_PIX:
  286. cur_mode |= (CG14_MCR_PIXMODE_16 <<
  287. CG14_MCR_PIXMODE_SHIFT);
  288. break;
  289. case MDI_8_PIX:
  290. break;
  291. default:
  292. ret = -ENOSYS;
  293. break;
  294. };
  295. if (!ret) {
  296. sbus_writeb(cur_mode, &regs->mcr);
  297. par->mode = mode;
  298. }
  299. spin_unlock_irqrestore(&par->lock, flags);
  300. break;
  301. default:
  302. ret = sbusfb_ioctl_helper(cmd, arg, info,
  303. FBTYPE_MDICOLOR, 8, par->fbsize);
  304. break;
  305. };
  306. return ret;
  307. }
  308. /*
  309. * Initialisation
  310. */
  311. static void cg14_init_fix(struct fb_info *info, int linebytes)
  312. {
  313. struct cg14_par *par = (struct cg14_par *)info->par;
  314. const char *name;
  315. name = "cgfourteen";
  316. if (par->sdev)
  317. name = par->sdev->prom_name;
  318. strlcpy(info->fix.id, name, sizeof(info->fix.id));
  319. info->fix.type = FB_TYPE_PACKED_PIXELS;
  320. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  321. info->fix.line_length = linebytes;
  322. info->fix.accel = FB_ACCEL_SUN_CG14;
  323. }
  324. static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] __initdata = {
  325. {
  326. .voff = CG14_REGS,
  327. .poff = 0x80000000,
  328. .size = 0x1000
  329. },
  330. {
  331. .voff = CG14_XLUT,
  332. .poff = 0x80003000,
  333. .size = 0x1000
  334. },
  335. {
  336. .voff = CG14_CLUT1,
  337. .poff = 0x80004000,
  338. .size = 0x1000
  339. },
  340. {
  341. .voff = CG14_CLUT2,
  342. .poff = 0x80005000,
  343. .size = 0x1000
  344. },
  345. {
  346. .voff = CG14_CLUT3,
  347. .poff = 0x80006000,
  348. .size = 0x1000
  349. },
  350. {
  351. .voff = CG3_MMAP_OFFSET - 0x7000,
  352. .poff = 0x80000000,
  353. .size = 0x7000
  354. },
  355. {
  356. .voff = CG3_MMAP_OFFSET,
  357. .poff = 0x00000000,
  358. .size = SBUS_MMAP_FBSIZE(1)
  359. },
  360. {
  361. .voff = MDI_CURSOR_MAP,
  362. .poff = 0x80001000,
  363. .size = 0x1000
  364. },
  365. {
  366. .voff = MDI_CHUNKY_BGR_MAP,
  367. .poff = 0x01000000,
  368. .size = 0x400000
  369. },
  370. {
  371. .voff = MDI_PLANAR_X16_MAP,
  372. .poff = 0x02000000,
  373. .size = 0x200000
  374. },
  375. {
  376. .voff = MDI_PLANAR_C16_MAP,
  377. .poff = 0x02800000,
  378. .size = 0x200000
  379. },
  380. {
  381. .voff = MDI_PLANAR_X32_MAP,
  382. .poff = 0x03000000,
  383. .size = 0x100000
  384. },
  385. {
  386. .voff = MDI_PLANAR_B32_MAP,
  387. .poff = 0x03400000,
  388. .size = 0x100000
  389. },
  390. {
  391. .voff = MDI_PLANAR_G32_MAP,
  392. .poff = 0x03800000,
  393. .size = 0x100000
  394. },
  395. {
  396. .voff = MDI_PLANAR_R32_MAP,
  397. .poff = 0x03c00000,
  398. .size = 0x100000
  399. },
  400. { .size = 0 }
  401. };
  402. struct all_info {
  403. struct fb_info info;
  404. struct cg14_par par;
  405. struct list_head list;
  406. };
  407. static LIST_HEAD(cg14_list);
  408. static void cg14_init_one(struct sbus_dev *sdev, int node, int parent_node)
  409. {
  410. struct all_info *all;
  411. unsigned long phys, rphys;
  412. u32 bases[6];
  413. int is_8mb, linebytes, i;
  414. if (!sdev) {
  415. if (prom_getproperty(node, "address",
  416. (char *) &bases[0], sizeof(bases)) <= 0
  417. || !bases[0]) {
  418. printk(KERN_ERR "cg14: Device is not mapped.\n");
  419. return;
  420. }
  421. if (__get_iospace(bases[0]) != __get_iospace(bases[1])) {
  422. printk(KERN_ERR "cg14: I/O spaces don't match.\n");
  423. return;
  424. }
  425. }
  426. all = kmalloc(sizeof(*all), GFP_KERNEL);
  427. if (!all) {
  428. printk(KERN_ERR "cg14: Cannot allocate memory.\n");
  429. return;
  430. }
  431. memset(all, 0, sizeof(*all));
  432. INIT_LIST_HEAD(&all->list);
  433. spin_lock_init(&all->par.lock);
  434. sbusfb_fill_var(&all->info.var, node, 8);
  435. all->info.var.red.length = 8;
  436. all->info.var.green.length = 8;
  437. all->info.var.blue.length = 8;
  438. linebytes = prom_getintdefault(node, "linebytes",
  439. all->info.var.xres);
  440. all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
  441. all->par.sdev = sdev;
  442. if (sdev) {
  443. rphys = sdev->reg_addrs[0].phys_addr;
  444. all->par.physbase = phys = sdev->reg_addrs[1].phys_addr;
  445. all->par.iospace = sdev->reg_addrs[0].which_io;
  446. all->par.regs = sbus_ioremap(&sdev->resource[0], 0,
  447. sizeof(struct cg14_regs),
  448. "cg14 regs");
  449. all->par.clut = sbus_ioremap(&sdev->resource[0], CG14_CLUT1,
  450. sizeof(struct cg14_clut),
  451. "cg14 clut");
  452. all->par.cursor = sbus_ioremap(&sdev->resource[0], CG14_CURSORREGS,
  453. sizeof(struct cg14_cursor),
  454. "cg14 cursor");
  455. all->info.screen_base = sbus_ioremap(&sdev->resource[1], 0,
  456. all->par.fbsize, "cg14 ram");
  457. } else {
  458. rphys = __get_phys(bases[0]);
  459. all->par.physbase = phys = __get_phys(bases[1]);
  460. all->par.iospace = __get_iospace(bases[0]);
  461. all->par.regs = (struct cg14_regs __iomem *)(unsigned long)bases[0];
  462. all->par.clut = (struct cg14_clut __iomem *)((unsigned long)bases[0] +
  463. CG14_CLUT1);
  464. all->par.cursor =
  465. (struct cg14_cursor __iomem *)((unsigned long)bases[0] +
  466. CG14_CURSORREGS);
  467. all->info.screen_base = (char __iomem *)(unsigned long)bases[1];
  468. }
  469. prom_getproperty(node, "reg", (char *) &bases[0], sizeof(bases));
  470. is_8mb = (bases[5] == 0x800000);
  471. if (sizeof(all->par.mmap_map) != sizeof(__cg14_mmap_map)) {
  472. extern void __cg14_mmap_sized_wrongly(void);
  473. __cg14_mmap_sized_wrongly();
  474. }
  475. memcpy(&all->par.mmap_map, &__cg14_mmap_map, sizeof(all->par.mmap_map));
  476. for (i = 0; i < CG14_MMAP_ENTRIES; i++) {
  477. struct sbus_mmap_map *map = &all->par.mmap_map[i];
  478. if (!map->size)
  479. break;
  480. if (map->poff & 0x80000000)
  481. map->poff = (map->poff & 0x7fffffff) + rphys - phys;
  482. if (is_8mb &&
  483. map->size >= 0x100000 &&
  484. map->size <= 0x400000)
  485. map->size *= 2;
  486. }
  487. all->par.mode = MDI_8_PIX;
  488. all->par.ramsize = (is_8mb ? 0x800000 : 0x400000);
  489. all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
  490. all->info.fbops = &cg14_ops;
  491. all->info.par = &all->par;
  492. __cg14_reset(&all->par);
  493. if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
  494. printk(KERN_ERR "cg14: Could not allocate color map.\n");
  495. kfree(all);
  496. return;
  497. }
  498. fb_set_cmap(&all->info.cmap, &all->info);
  499. cg14_init_fix(&all->info, linebytes);
  500. if (register_framebuffer(&all->info) < 0) {
  501. printk(KERN_ERR "cg14: Could not register framebuffer.\n");
  502. fb_dealloc_cmap(&all->info.cmap);
  503. kfree(all);
  504. return;
  505. }
  506. list_add(&all->list, &cg14_list);
  507. printk("cg14: cgfourteen at %lx:%lx, %dMB\n",
  508. all->par.iospace, all->par.physbase, all->par.ramsize >> 20);
  509. }
  510. int __init cg14_init(void)
  511. {
  512. struct sbus_bus *sbus;
  513. struct sbus_dev *sdev;
  514. if (fb_get_options("cg14fb", NULL))
  515. return -ENODEV;
  516. #ifdef CONFIG_SPARC32
  517. {
  518. int root, node;
  519. root = prom_getchild(prom_root_node);
  520. root = prom_searchsiblings(root, "obio");
  521. if (root) {
  522. node = prom_searchsiblings(prom_getchild(root),
  523. "cgfourteen");
  524. if (node)
  525. cg14_init_one(NULL, node, root);
  526. }
  527. }
  528. #endif
  529. for_all_sbusdev(sdev, sbus) {
  530. if (!strcmp(sdev->prom_name, "cgfourteen"))
  531. cg14_init_one(sdev, sdev->prom_node, sbus->prom_node);
  532. }
  533. return 0;
  534. }
  535. void __exit cg14_exit(void)
  536. {
  537. struct list_head *pos, *tmp;
  538. list_for_each_safe(pos, tmp, &cg14_list) {
  539. struct all_info *all = list_entry(pos, typeof(*all), list);
  540. unregister_framebuffer(&all->info);
  541. fb_dealloc_cmap(&all->info.cmap);
  542. kfree(all);
  543. }
  544. }
  545. int __init
  546. cg14_setup(char *arg)
  547. {
  548. /* No cmdline options yet... */
  549. return 0;
  550. }
  551. module_init(cg14_init);
  552. #ifdef MODULE
  553. module_exit(cg14_exit);
  554. #endif
  555. MODULE_DESCRIPTION("framebuffer driver for CGfourteen chipsets");
  556. MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
  557. MODULE_LICENSE("GPL");