int __init sun3fb_init(void) { extern int con_is_present(void); unsigned long addr; char p4id; if (!con_is_present()) return -ENODEV; #ifdef CONFIG_SUN3 switch(*(romvec->pv_fbtype)) { case FBTYPE_SUN2BW: addr = 0xfe20000; return sun3fb_init_fb(FBTYPE_SUN2BW, addr); case FBTYPE_SUN3COLOR: case FBTYPE_SUN4COLOR: if(idprom->id_machtype != (SM_SUN3|SM_3_60)) { printk("sun3fb: cgthree/four only supported on 3/60\n"); return -ENODEV; } addr = CGFOUR_OBMEM_ADDR; return sun3fb_init_fb(*(romvec->pv_fbtype), addr); default: printk("sun3fb: unsupported framebuffer\n"); return -ENODEV; } #else addr = SUN3X_VIDEO_BASE; p4id = *(char *)SUN3X_VIDEO_P4ID; p4id = (p4id == 0x45) ? p4id : (p4id & 0xf0); switch (p4id) { case 0x00: return sun3fb_init_fb(FBTYPE_SUN2BW, addr); #if 0 /* not yet */ case 0x40: return sun3fb_init_fb(FBTYPE_SUN4COLOR, addr); break; case 0x45: return sun3fb_init_fb(FBTYPE_SUN8COLOR, addr); break; #endif case 0x60: return sun3fb_init_fb(FBTYPE_SUNFAST_COLOR, addr); } #endif return -ENODEV; }
int __init igafb_init(void) { struct pci_dev *pdev; struct fb_info_iga *info; unsigned long addr; extern int con_is_present(void); int iga2000 = 0; /* Do not attach when we have a serial console. */ if (!con_is_present()) return -ENXIO; pdev = pci_find_device(PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682, 0); if (pdev == NULL) { /* * XXX We tried to use cyber2000fb.c for IGS 2000. * But it does not initialize the chip in JavaStation-E, alas. */ pdev = pci_find_device(PCI_VENDOR_ID_INTERG, 0x2000, 0); if(pdev == NULL) { return -ENXIO; } iga2000 = 1; } info = kmalloc(sizeof(struct fb_info_iga), GFP_ATOMIC); if (!info) { printk("igafb_init: can't alloc fb_info_iga\n"); return -ENOMEM; } memset(info, 0, sizeof(struct fb_info_iga)); if ((addr = pdev->resource[0].start) == 0) { printk("igafb_init: no memory start\n"); kfree(info); return -ENXIO; } if ((info->frame_buffer = ioremap(addr, 1024*1024*2)) == 0) { printk("igafb_init: can't remap %lx[2M]\n", addr); kfree(info); return -ENXIO; } info->frame_buffer_phys = addr & PCI_BASE_ADDRESS_MEM_MASK; #ifdef __sparc__ /* * The following is sparc specific and this is why: * * IGS2000 has its I/O memory mapped and we want * to generate memory cycles on PCI, e.g. do ioremap(), * then readb/writeb() as in Documentation/IO-mapping.txt. * * IGS1682 is more traditional, it responds to PCI I/O * cycles, so we want to access it with inb()/outb(). * * On sparc, PCIC converts CPU memory access within * phys window 0x3000xxxx into PCI I/O cycles. Therefore * we may use readb/writeb to access them with IGS1682. * * We do not take io_base_phys from resource[n].start * on IGS1682 because that chip is BROKEN. It does not * have a base register for I/O. We just "know" what its * I/O addresses are. */ if (iga2000) { info->io_base_phys = info->frame_buffer_phys | 0x00800000; } else { info->io_base_phys = 0x30000000; /* XXX */ } if ((info->io_base = (int) ioremap(info->io_base_phys, 0x1000)) == 0) { printk("igafb_init: can't remap %lx[4K]\n", info->io_base_phys); iounmap((void *)info->frame_buffer); kfree(info); return -ENXIO; } /* * Figure mmap addresses from PCI config space. * We need two regions: for video memory and for I/O ports. * Later one can add region for video coprocessor registers. * However, mmap routine loops until size != 0, so we put * one additional region with size == 0. */ info->mmap_map = kmalloc(4 * sizeof(*info->mmap_map), GFP_ATOMIC); if (!info->mmap_map) { printk("igafb_init: can't alloc mmap_map\n"); iounmap((void *)info->io_base); iounmap(info->frame_buffer); kfree(info); return -ENOMEM; } memset(info->mmap_map, 0, 4 * sizeof(*info->mmap_map)); /* * Set default vmode and cmode from PROM properties. */ { struct pcidev_cookie *cookie = pdev->sysdata; int node = cookie->prom_node; int width = prom_getintdefault(node, "width", 1024); int height = prom_getintdefault(node, "height", 768); int depth = prom_getintdefault(node, "depth", 8); switch (width) { case 1024: if (height == 768) default_var = default_var_1024x768; break; case 1152: if (height == 900) default_var = default_var_1152x900; break; case 1280: if (height == 1024) default_var = default_var_1280x1024; break; default: break; } switch (depth) { case 8: default_var.bits_per_pixel = 8; break; case 16: default_var.bits_per_pixel = 16; break; case 24: default_var.bits_per_pixel = 24; break; case 32: default_var.bits_per_pixel = 32; break; default: break; } } #endif if (!iga_init(info)) { iounmap((void *)info->io_base); iounmap(info->frame_buffer); if (info->mmap_map) kfree(info->mmap_map); kfree(info); } #ifdef __sparc__ /* * Add /dev/fb mmap values. */ /* First region is for video memory */ info->mmap_map[0].voff = 0x0; info->mmap_map[0].poff = info->frame_buffer_phys & PAGE_MASK; info->mmap_map[0].size = info->total_vram & PAGE_MASK; info->mmap_map[0].prot_mask = SRMMU_CACHE; info->mmap_map[0].prot_flag = SRMMU_WRITE; /* Second region is for I/O ports */ info->mmap_map[1].voff = info->frame_buffer_phys & PAGE_MASK; info->mmap_map[1].poff = info->io_base_phys & PAGE_MASK; info->mmap_map[1].size = PAGE_SIZE * 2; /* X wants 2 pages */ info->mmap_map[1].prot_mask = SRMMU_CACHE; info->mmap_map[1].prot_flag = SRMMU_WRITE; #endif /* __sparc__ */ return 0; }