while (machine_is_compatible("PowerBook5,2") || machine_is_compatible("PowerBook5,3") || machine_is_compatible("PowerBook6,2") || machine_is_compatible("PowerBook6,3")) { struct device_node *ui2c = of_find_node_by_type(NULL, "i2c"); struct device_node *dt = of_find_node_by_name(NULL, "device-tree"); u8 buffer[9]; u32 *productID; int i, rc, changed = 0;  if (dt == NULL) break; productID = (u32 *)get_property(dt, "pid#", NULL); if (productID == NULL) break; while(ui2c) { struct device_node *p = of_get_parent(ui2c); if (p && !strcmp(p->name, "uni-n")) break; ui2c = of_find_node_by_type(ui2c, "i2c"); } if (ui2c == NULL) break; DBG("Trying to bump clock speed for PID: %08x...\n", *productID); rc = pmac_low_i2c_open(ui2c, 1); if (rc != 0) break; pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined); rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9); DBG("read result: %d,", rc); if (rc != 0) { pmac_low_i2c_close(ui2c); break; } for (i=0; i<9; i++) DBG(" %02x", buffer[i]); DBG("\n");  switch(*productID) { case 0x1182:	/* AlBook 12" rev 2 */ case 0x1183:	/* iBook G4 12" */ buffer[0] = (buffer[0] & 0x8f) | 0x70; buffer[2] = (buffer[2] & 0x7f) | 0x00; buffer[5] = (buffer[5] & 0x80) | 0x31; buffer[6] = (buffer[6] & 0x40) | 0xb0; buffer[7] = (buffer[7] & 0x00) | 0xc0; buffer[8] = (buffer[8] & 0x00) | 0x30; changed = 1; break; case 0x3142:	/* AlBook 15" (ATI M10) */ case 0x3143:	/* AlBook 17" (ATI M10) */ buffer[0] = (buffer[0] & 0xaf) | 0x50; buffer[2] = (buffer[2] & 0x7f) | 0x00; buffer[5] = (buffer[5] & 0x80) | 0x31; buffer[6] = (buffer[6] & 0x40) | 0xb0; buffer[7] = (buffer[7] & 0x00) | 0xd0; buffer[8] = (buffer[8] & 0x00) | 0x30; changed = 1; break; default: DBG("i2c-hwclock: Machine model not handled\n"); break; } if (!changed) { pmac_low_i2c_close(ui2c); break; } pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub); rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9); DBG("write result: %d,", rc); pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined); rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9); DBG("read result: %d,", rc); if (rc != 0) { pmac_low_i2c_close(ui2c); break; } for (i=0; i<9; i++) DBG(" %02x", buffer[i]); pmac_low_i2c_close(ui2c); break; } 
pmac_tweak_clock_spreading(&macio_chips[0], 1); 
set_initial_features(void){	struct device_node* np;	/* That hack appears to be necessary for some StarMax motherboards	 * but I'm not too sure it was audited for side-effects on other	 * ohare based machines...	 * Since I still have difficulties figuring the right way to	 * differenciate them all and since that hack was there for a long	 * time, I'll keep it around	 */	if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) {		struct macio_chip* macio = &macio_chips[0];		MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);	} else if (macio_chips[0].type == macio_ohare) {		struct macio_chip* macio = &macio_chips[0];		MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);	} else if (macio_chips[1].type == macio_ohare) {		struct macio_chip* macio = &macio_chips[1];		MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);	}#ifdef CONFIG_POWER4	if (macio_chips[0].type == macio_keylargo2) {#ifndef CONFIG_SMP		/* On SMP machines running UP, we have the second CPU eating		 * bus cycles. We need to take it off the bus. This is done		 * from pmac_smp for SMP kernels running on one CPU		 */		np = of_find_node_by_type(NULL, "cpu");		if (np != NULL)			np = of_find_node_by_type(np, "cpu");		if (np != NULL) {			g5_phy_disable_cpu1();			of_node_put(np);		}#endif /* CONFIG_SMP */		/* Enable GMAC for now for PCI probing. It will be disabled		 * later on after PCI probe		 */		np = of_find_node_by_name(NULL, "ethernet");		while(np) {			if (device_is_compatible(np, "K2-GMAC"))				g5_gmac_enable(np, 0, 1);			np = of_find_node_by_name(np, "ethernet");		}		/* Enable FW before PCI probe. Will be disabled later on		 * Note: We should have a batter way to check that we are		 * dealing with uninorth internal cell and not a PCI cell		 * on the external PCI. The code below works though.		 */		np = of_find_node_by_name(NULL, "firewire");		while(np) {			if (device_is_compatible(np, "pci106b,5811")) {				macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;				g5_fw_enable(np, 0, 1);			}			np = of_find_node_by_name(np, "firewire");		}	}#else /* CONFIG_POWER4 */	if (macio_chips[0].type == macio_keylargo ||	    macio_chips[0].type == macio_pangea ||	    macio_chips[0].type == macio_intrepid) {		/* Enable GMAC for now for PCI probing. It will be disabled		 * later on after PCI probe		 */		np = of_find_node_by_name(NULL, "ethernet");		while(np) {			if (np->parent			    && device_is_compatible(np->parent, "uni-north")			    && device_is_compatible(np, "gmac"))				core99_gmac_enable(np, 0, 1);			np = of_find_node_by_name(np, "ethernet");		}		/* Enable FW before PCI probe. Will be disabled later on		 * Note: We should have a batter way to check that we are		 * dealing with uninorth internal cell and not a PCI cell		 * on the external PCI. The code below works though.		 */		np = of_find_node_by_name(NULL, "firewire");		while(np) {			if (np->parent			    && device_is_compatible(np->parent, "uni-north")			    && (device_is_compatible(np, "pci106b,18") ||	     		        device_is_compatible(np, "pci106b,30") ||	     		        device_is_compatible(np, "pci11c1,5811"))) {				macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;				core99_firewire_enable(np, 0, 1);			}			np = of_find_node_by_name(np, "firewire");		}		/* Enable ATA-100 before PCI probe. */		np = of_find_node_by_name(NULL, "ata-6");		while(np) {			if (np->parent			    && device_is_compatible(np->parent, "uni-north")			    && device_is_compatible(np, "kauai-ata")) {				core99_ata100_enable(np, 1);			}			np = of_find_node_by_name(np, "ata-6");		}		/* Switch airport off */		np = find_devices("radio");		while(np) {			if (np && np->parent == macio_chips[0].of_node) {				macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON;				core99_airport_enable(np, 0, 0);			}			np = np->next;		}	}	/* On all machines that support sound PM, switch sound off */	if (macio_chips[0].of_node)		pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE,			macio_chips[0].of_node, 0, 0);	/* While on some desktop G3s, we turn it back on */	if (macio_chips[0].of_node && macio_chips[0].type == macio_heathrow		&& (pmac_mb.model_id == PMAC_TYPE_GOSSAMER ||		    pmac_mb.model_id == PMAC_TYPE_SILK)) {		struct macio_chip* macio = &macio_chips[0];		MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);		MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);	}	/* Hack for bumping clock speed on the new PowerBooks and the	 * iBook G4. This implements the "platform-do-clockspreading" OF	 * property. For safety, we also check the product ID in the	 * device-tree to make reasonably sure we won't set wrong values	 * in the clock chip.	 *	 * Of course, ultimately, we have to implement a real parser for	 * the platform-do-* stuff...	 */	while (machine_is_compatible("PowerBook5,2") ||	       machine_is_compatible("PowerBook5,3") ||	       machine_is_compatible("PowerBook6,2") ||	       machine_is_compatible("PowerBook6,3")) {		struct device_node *ui2c = of_find_node_by_type(NULL, "i2c");		struct device_node *dt = of_find_node_by_name(NULL, "device-tree");		u8 buffer[9];		u32 *productID;		int i, rc, changed = 0;				if (dt == NULL)			break;		productID = (u32 *)get_property(dt, "pid#", NULL);		if (productID == NULL)			break;		while(ui2c) {			struct device_node *p = of_get_parent(ui2c);			if (p && !strcmp(p->name, "uni-n"))				break;			ui2c = of_find_node_by_type(ui2c, "i2c");		}		if (ui2c == NULL)			break;		DBG("Trying to bump clock speed for PID: %08x...\n", *productID);		rc = pmac_low_i2c_open(ui2c, 1);		if (rc != 0)			break;		pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);		rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);		DBG("read result: %d,", rc);		if (rc != 0) {			pmac_low_i2c_close(ui2c);			break;		}		for (i=0; i<9; i++)			DBG(" %02x", buffer[i]);		DBG("\n");				switch(*productID) {		case 0x1182:	/* AlBook 12" rev 2 */		case 0x1183:	/* iBook G4 12" */			buffer[0] = (buffer[0] & 0x8f) | 0x70;			buffer[2] = (buffer[2] & 0x7f) | 0x00;			buffer[5] = (buffer[5] & 0x80) | 0x31;			buffer[6] = (buffer[6] & 0x40) | 0xb0;			buffer[7] = (buffer[7] & 0x00) | 0xc0;			buffer[8] = (buffer[8] & 0x00) | 0x30;			changed = 1;			break;		case 0x3142:	/* AlBook 15" (ATI M10) */		case 0x3143:	/* AlBook 17" (ATI M10) */			buffer[0] = (buffer[0] & 0xaf) | 0x50;			buffer[2] = (buffer[2] & 0x7f) | 0x00;			buffer[5] = (buffer[5] & 0x80) | 0x31;			buffer[6] = (buffer[6] & 0x40) | 0xb0;			buffer[7] = (buffer[7] & 0x00) | 0xd0;			buffer[8] = (buffer[8] & 0x00) | 0x30;			changed = 1;			break;		default:			DBG("i2c-hwclock: Machine model not handled\n");			break;		}		if (!changed) {			pmac_low_i2c_close(ui2c);			break;		}		pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_stdsub);		rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_write, 0x80, buffer, 9);		DBG("write result: %d,", rc);		pmac_low_i2c_setmode(ui2c, pmac_low_i2c_mode_combined);		rc = pmac_low_i2c_xfer(ui2c, 0xd2 | pmac_low_i2c_read, 0x80, buffer, 9);		DBG("read result: %d,", rc);		if (rc != 0) {			pmac_low_i2c_close(ui2c);			break;		}		for (i=0; i<9; i++)			DBG(" %02x", buffer[i]);		pmac_low_i2c_close(ui2c);		break;	}#endif /* CONFIG_POWER4 */	/* On all machines, switch modem & serial ports off */	np = find_devices("ch-a");	while(np) {		initial_serial_shutdown(np);		np = np->next;	}	np = find_devices("ch-b");	while(np) {		initial_serial_shutdown(np);		np = np->next;	}}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b20cc8aff258eea5a2339107605ebea949fa6ecf/pmac_feature.c/clean/arch/ppc/platforms/pmac_feature.c