kernels/linux-2.4.0/drivers/video/cyber2000fb.c
/*
 * We need to wake up the CyberPro, and make sure its in linear memory
 * mode.  Unfortunately, this is specific to the platform and card that
 * we are running on.
 *
 * On x86 and ARM, should we be initialising the CyberPro first via the
 * IO registers, and then the MMIO registers to catch all cases?  Can we
 * end up in the situation where the chip is in MMIO mode, but not awake
 * on an x86 system?
 *
 * Note that on the NetWinder, the firmware automatically detects the
 * type, width and size, and leaves this in extended registers 0x71 and
 * 0x72 for us.
 */
We need to wake up the CyberPro, and make sure its in linear memory
mode.  Unfortunately, this is specific to the platform and card that
we are running on.

On x86 and ARM, should we be initialising the CyberPro first via the
IO registers, and then the MMIO registers to catch all cases.

Note that on the NetWinder, the firmware automatically detects the
type, width and size, and leaves this in extended registers 0x71 and
0x72 for us.
We need to wake up the CyberPro and make sure its in linear memory mode . Unfortunately this is specific to the platform and card that we are running on . On x86 and ARM should we be initialising the CyberPro first via the IO registers and then the MMIO registers to catch all cases . Note that on the NetWinder the firmware automatically detects the type width and size and leaves this in extended registers 0x71 and 0x72 for us .
static inline void cyberpro_init_hw(struct cfb_info *cfb, int at_boot)
{
	int i;
#ifdef __sparc__
#ifdef __sparc_v9__
#error "You loose, consult DaveM."
#else
	{
		unsigned char *iop;
		iop = ioremap(0x3000000, 0x5000);
		if (iop == NULL) {
			prom_printf("iga5000: cannot map I/O\n");
			return -ENOMEM;
		}
		writeb(0x18, iop + 0x46e8);
		writeb(0x01, iop + 0x102);
		writeb(0x08, iop + 0x46e8);
		writeb(0x33, iop + 0x3ce);
		writeb(0x01, iop + 0x3cf);
		iounmap((void *)iop);
	}
#endif
	if (at_boot) {
		cfb->mclk_mult = cyber2000_grphr(MCLK_MULT);
		cfb->mclk_div  = cyber2000_grphr(MCLK_DIV);
	}
#endif
#ifdef __i386__
	outb(0x18, 0x46e8);
	outb(0x01, 0x102);
	outb(0x08, 0x46e8);
	outb(0x33, 0x3ce);
	outb(0x01, 0x3cf);
	if (at_boot) {
		cfb->mclk_mult = cyber2000_grphr(MCLK_MULT);
		cfb->mclk_div  = cyber2000_grphr(MCLK_DIV);
	}
#endif
#ifdef __arm__
	cyber2000_outb(0x18, 0x46e8);
	cyber2000_outb(0x01, 0x102);
	cyber2000_outb(0x08, 0x46e8);
	cyber2000_outb(0x33, 0x3ce);
	cyber2000_outb(0x01, 0x3cf);
	cfb->mclk_mult = 0xdb;
	cfb->mclk_div  = 0x54;
#endif
	for (i = 0; i < sizeof(igs_regs); i += 2)
		cyber2000_grphw(igs_regs[i], igs_regs[i+1]);
	if (at_boot) {
		cfb->mem_ctl1 = cyber2000_grphr(MEM_CTL1);
		cfb->mem_ctl2 = cyber2000_grphr(MEM_CTL2);
	} else {
		cyber2000_grphw(MEM_CTL1, cfb->mem_ctl1);
		cyber2000_grphw(MEM_CTL2, cfb->mem_ctl2);
	}
	cyber2000_outb(0xba, 0x3ce);
	cyber2000_outb(cyber2000_inb(0x3cf) & 0x80, 0x3cf);
}
static inline void cyberpro_init_hw ( struct cfb_info * cfb , int at_boot ) { int i ; #ifdef __sparc__ #ifdef __sparc_v9__ #error  "You loose, consult DaveM." #else { unsigned char * iop ; iop = ioremap ( 0x3000000 , 0x5000 ) ; if ( iop == NULL ) { prom_printf ( " \n " ) ; return - ENOMEM ; } writeb ( 0x18 , iop + 0x46e8 ) ; writeb ( 0x01 , iop + 0x102 ) ; writeb ( 0x08 , iop + 0x46e8 ) ; writeb ( 0x33 , iop + 0x3ce ) ; writeb ( 0x01 , iop + 0x3cf ) ; iounmap ( ( void * ) iop ) ; } #endif if ( at_boot ) { cfb -> mclk_mult = cyber2000_grphr ( MCLK_MULT ) ; cfb -> mclk_div = cyber2000_grphr ( MCLK_DIV ) ; } #endif #ifdef __i386__ outb ( 0x18 , 0x46e8 ) ; outb ( 0x01 , 0x102 ) ; outb ( 0x08 , 0x46e8 ) ; outb ( 0x33 , 0x3ce ) ; outb ( 0x01 , 0x3cf ) ; if ( at_boot ) { cfb -> mclk_mult = cyber2000_grphr ( MCLK_MULT ) ; cfb -> mclk_div = cyber2000_grphr ( MCLK_DIV ) ; } #endif #ifdef __arm__ cyber2000_outb ( 0x18 , 0x46e8 ) ; cyber2000_outb ( 0x01 , 0x102 ) ; cyber2000_outb ( 0x08 , 0x46e8 ) ; cyber2000_outb ( 0x33 , 0x3ce ) ; cyber2000_outb ( 0x01 , 0x3cf ) ; cfb -> mclk_mult = 0xdb ; cfb -> mclk_div = 0x54 ; #endif for ( i = 0 ; i < sizeof ( igs_regs ) ; i += 2 ) cyber2000_grphw ( igs_regs [ i ] , igs_regs [ i + 1 ] ) ; if ( at_boot ) { cfb -> mem_ctl1 = cyber2000_grphr ( MEM_CTL1 ) ; cfb -> mem_ctl2 = cyber2000_grphr ( MEM_CTL2 ) ; } else { cyber2000_grphw ( MEM_CTL1 , cfb -> mem_ctl1 ) ; cyber2000_grphw ( MEM_CTL2 , cfb -> mem_ctl2 ) ; } cyber2000_outb ( 0xba , 0x3ce ) ; cyber2000_outb ( cyber2000_inb ( 0x3cf ) & 0x80 , 0x3cf ) ; }
We need to wake up the CyberPro, and make sure its in linear memory
 mode.
We need to wake up the CyberPro and make sure its in linear memory mode .
/*
	 * Wake up the CyberPro.
	 */ /*
	 * SPARC does not have an "outb" instruction, so we generate
	 * I/O cycles storing into a reserved memory space at
	 * physical address 0x3000000
	 */ /*
		 * Use mclk from BIOS.  Only read this if we're
		 * initialising this card for the first time.
		 * FIXME: what about hotplug?
		 */ /*
	 * x86 is simple, we just do regular outb's instead of
	 * cyber2000_outb.
	 */ /*
		 * Use mclk from BIOS.  Only read this if we're
		 * initialising this card for the first time.
		 * FIXME: what about hotplug?
		 */ /*
	 * MCLK on the NetWinder is fixed at 75MHz
	 */ /*
	 * Initialise the CyberPro
	 */ /*
		 * get the video RAM size and width from the VGA register.
		 * This should have been already initialised by the BIOS,
		 * but if it's garbage, claim default 1MB VRAM (woody)
		 */ /*
		 * Reprogram the MEM_CTL1 and MEM_CTL2 registers
		 */ /*
	 * Ensure thatwe are using the correct PLL.
	 * (CyberPro 5000's may be programmed to use
	 * an additional set of PLLs.
	 */