#ifdef CONFIG_PMAC_PBOOK 
#ifdef CONFIG_PM 
int __init dmasound_awacs_init(void){	struct device_node *io = NULL, *info = NULL;	int vol, res;	if (_machine != _MACH_Pmac)		return -ENODEV;	awacs_subframe = 0;	awacs_revision = 0;	hw_can_byteswap = 1 ; /* most can */	/* look for models we need to handle specially */	set_model() ;	/* find the OF node that tells us about the dbdma stuff	*/	io = get_snd_io_node();	if (io == NULL) {#ifdef DEBUG_DMASOUNDprintk("dmasound_pmac: couldn't find sound io OF node\n");#endif		return -ENODEV ;	}	/* find the OF node that tells us about the sound sub-system	 * this doesn't exist on pre-davbus machines (earlier than 9500)	*/	if (awacs_revision != AWACS_AWACS) { /* set for pre-davbus */		info = get_snd_info_node(io) ;		if (info == NULL){#ifdef DEBUG_DMASOUNDprintk("dmasound_pmac: couldn't find 'sound' OF node\n");#endif			return -ENODEV ;		}	}	awacs_revision = get_codec_type(info) ;	if (awacs_revision == 0) {#ifdef DEBUG_DMASOUNDprintk("dmasound_pmac: couldn't find a Codec we can handle\n");#endif		return -ENODEV ; /* we don't know this type of h/w */	}	/* set up perch, ziva, SRS or whatever else we have as sound	 *  expansion.	*/	get_expansion_type();	/* we've now got enough information to make up the audio topology.	 * we will map the sound part of mac-io now so that we can probe for	 * other info if necessary (early AWACS we want to read chip ids)	 */	if (io->n_addrs < 3 || io->n_intrs < 3) {		/* OK - maybe we need to use the 'awacs' node (on earlier		 * machines).		*/		if (awacs_node) {			io = awacs_node ;			if (io->n_addrs < 3 || io->n_intrs < 3) {				printk("dmasound_pmac: can't use %s"					" (%d addrs, %d intrs)\n",		      		 io->full_name, io->n_addrs, io->n_intrs);				return -ENODEV;			}		} else {			printk("dmasound_pmac: can't use %s (%d addrs, %d intrs)\n",		 	      io->full_name, io->n_addrs, io->n_intrs);		}	}	if (!request_OF_resource(io, 0, NULL)) {		printk(KERN_ERR "dmasound: can't request IO resource !\n");		return -ENODEV;	}	if (!request_OF_resource(io, 1, " (tx dma)")) {		release_OF_resource(io, 0);		printk(KERN_ERR "dmasound: can't request TX DMA resource !\n");		return -ENODEV;	}	if (!request_OF_resource(io, 2, " (rx dma)")) {		release_OF_resource(io, 0);		release_OF_resource(io, 1);		printk(KERN_ERR "dmasound: can't request RX DMA resource !\n");		return -ENODEV;	}	/* all OF versions I've seen use this value */	if (i2s_node)		i2s = ioremap(io->addrs[0].address, 0x1000);	else		awacs = ioremap(io->addrs[0].address, 0x1000);	awacs_txdma = ioremap(io->addrs[1].address, 0x100);	awacs_rxdma = ioremap(io->addrs[2].address, 0x100);	/* first of all make sure that the chip is powered up....*/	pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1);	if (awacs_revision == AWACS_SCREAMER && awacs)		awacs_recalibrate();	awacs_irq = io->intrs[0].line;	awacs_tx_irq = io->intrs[1].line;	awacs_rx_irq = io->intrs[2].line;	/* Hack for legacy crap that will be killed someday */	awacs_node = io;	/* if we have an awacs or screamer - probe the chip to make	 * sure we have the right revision.	*/	if (awacs_revision <= AWACS_SCREAMER){		uint32_t temp, rev, mfg ;		/* find out the awacs revision from the chip */		temp = in_le32(&awacs->codec_stat);		rev = (temp >> 12) & 0xf;		mfg = (temp >>  8) & 0xf;#ifdef DEBUG_DMASOUNDprintk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);#endif		if (rev >= AWACS_SCREAMER)			awacs_revision = AWACS_SCREAMER ;		else			awacs_revision = rev ;	}	dmasound.mach = machPMac;	/* find out other bits & pieces from OF, these may be present	   only on some models ... so be careful.	*/	/* in the absence of a frame rates property we will use the defaults	*/	if (info) {		unsigned int *prop, l;		sound_device_id = 0;		/* device ID appears post g3 b&w */		prop = (unsigned int *)get_property(info, "device-id", NULL);		if (prop != 0)			sound_device_id = *prop;		/* look for a property saying what sample rates		   are available */		prop = (unsigned int *)get_property(info, "sample-rates", &l);		if (prop == 0)			prop = (unsigned int *) get_property				(info, "output-frame-rates", &l);		/* if it's there use it to set up frame rates */		init_frame_rates(prop, l) ;	}	if (awacs)		out_le32(&awacs->control, 0x11); /* set everything quiesent */	set_hw_byteswap(io) ; /* figure out if the h/w can do it */#ifdef CONFIG_NVRAM	/* get default volume from nvram */	vol = ((pmac_xpram_read( 8 ) & 7 ) << 1 );#else	vol = 0;#endif	/* set up tracking values */	spk_vol = vol * 100 ;	spk_vol /= 7 ; /* get set value to a percentage */	spk_vol |= (spk_vol << 8) ; /* equal left & right */ 	line_vol = passthru_vol = spk_vol ;	/* fill regs that are shared between AWACS & Burgundy */	awacs_reg[2] = vol + (vol << 6);	awacs_reg[4] = vol + (vol << 6);	awacs_reg[5] = vol + (vol << 6); /* screamer has loopthru vol control */	awacs_reg[6] = 0; /* maybe should be vol << 3 for PCMCIA speaker */	awacs_reg[7] = 0;	awacs_reg[0] = MASK_MUX_CD;	awacs_reg[1] = MASK_LOOPTHRU;	/* FIXME: Only machines with external SRS module need MASK_PAROUT */	if (has_perch || sound_device_id == 0x5	    || /*sound_device_id == 0x8 ||*/ sound_device_id == 0xb)		awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1;	switch (awacs_revision) {		case AWACS_TUMBLER:                        tas_register_driver(&tas3001c_hooks);			tas_init(I2C_DRIVERID_TAS3001C, I2C_DRIVERNAME_TAS3001C);			tas_dmasound_init();			tas_post_init();			break ;		case AWACS_SNAPPER:                        tas_register_driver(&tas3004_hooks);			tas_init(I2C_DRIVERID_TAS3004,I2C_DRIVERNAME_TAS3004);			tas_dmasound_init();			tas_post_init();			break;		case AWACS_DACA:			daca_init();			break;			case AWACS_BURGUNDY:			awacs_burgundy_init();			break ;		case AWACS_SCREAMER:		case AWACS_AWACS:		default:			load_awacs();			break ;	}	/* enable/set-up external modules - when we know how */	if (has_perch)		awacs_enable_amp(100 * 0x101);	/* Reset dbdma channels */	out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16);	while (in_le32(&awacs_txdma->status) & RUN)		udelay(1);	out_le32(&awacs_rxdma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16);	while (in_le32(&awacs_rxdma->status) & RUN)		udelay(1);	/* Initialize beep stuff */	if ((res=setup_beep()))		return res ;#ifdef CONFIG_PMAC_PBOOK	pmu_register_sleep_notifier(&awacs_sleep_notifier);#endif /* CONFIG_PMAC_PBOOK */	/* Powerbooks have odd ways of enabling inputs such as	   an expansion-bay CD or sound from an internal modem	   or a PC-card modem. */	if (is_pbook_3X00) {		/*		 * Enable CD and PC-card sound inputs.		 * This is done by reading from address		 * f301a000, + 0x10 to enable the expansion-bay		 * CD sound input, + 0x80 to enable the PC-card		 * sound input.  The 0x100 enables the SCSI bus		 * terminator power.		 */		latch_base = ioremap (0xf301a000, 0x1000);		in_8(latch_base + 0x190);	} else if (is_pbook_g3) {		struct device_node* mio;		macio_base = NULL;		for (mio = io->parent; mio; mio = mio->parent) {			if (strcmp(mio->name, "mac-io") == 0			    && mio->n_addrs > 0) {				macio_base = ioremap(mio->addrs[0].address, 0x40);				break;			}		}		/*		 * Enable CD sound input.		 * The relevant bits for writing to this byte are 0x8f.		 * I haven't found out what the 0x80 bit does.		 * For the 0xf bits, writing 3 or 7 enables the CD		 * input, any other value disables it.  Values		 * 1, 3, 5, 7 enable the microphone.  Values 0, 2,		 * 4, 6, 8 - f enable the input from the modem.		 *  -- paulus.		 */		if (macio_base)			out_8(macio_base + 0x37, 3);	}	if (hw_can_byteswap) 		dmasound.mach.hardware_afmts = (AFMT_S16_BE | AFMT_S16_LE) ; 	else		dmasound.mach.hardware_afmts = AFMT_S16_BE ;	/* shut out chips that do output only.	 * may need to extend this to machines which have no inputs - even tho'	 * they use screamer - IIRC one of the powerbooks is like this.	 */	if (awacs_revision != AWACS_DACA) {		dmasound.mach.capabilities = DSP_CAP_DUPLEX ;		dmasound.mach.record = PMacRecord ;	}	dmasound.mach.default_hard = def_hard ;	dmasound.mach.default_soft = def_soft ;	switch (awacs_revision) {		case AWACS_BURGUNDY:			sprintf(awacs_name, "PowerMac Burgundy ") ;			break ;		case AWACS_DACA:			sprintf(awacs_name, "PowerMac DACA ") ;			break ;		case AWACS_TUMBLER:			sprintf(awacs_name, "PowerMac Tumbler ") ;			break ;		case AWACS_SNAPPER:			sprintf(awacs_name, "PowerMac Snapper ") ;			break ;		case AWACS_SCREAMER:			sprintf(awacs_name, "PowerMac Screamer ") ;			break ;		case AWACS_AWACS:		default:			sprintf(awacs_name, "PowerMac AWACS rev %d ", awacs_revision) ;			break ;	}	/*	 * XXX: we should handle errors here, but that would mean	 * rewriting the whole init code.  later..	 */	input_register_device(&awacs_beep_dev);	return dmasound_init();}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/8c8709334cec803368a432a33e0f2e116d48fe07/dmasound_awacs.c/clean/sound/oss/dmasound/dmasound_awacs.c