/* Write 16 or 32 bits depending on the current size of the counter. Counters 4, 5, 6 & 7 are always 16 bit.  */
void ps3_write_ctr(u32 cpu, u32 ctr, u32 val)
/* Write 16 or 32 bits depending on the current size of the counter. Counters 4, 5, 6 & 7 are always 16 bit.  */
void ps3_write_ctr(u32 cpu, u32 ctr, u32 val)
{
	u32 phys_ctr;
	u32 phys_val;
	phys_ctr = ctr & (NR_PHYS_CTRS - 1);
	if (ps3_get_ctr_size(cpu, phys_ctr) == 16) {
		phys_val = ps3_read_phys_ctr(cpu, phys_ctr);
		if (ctr < NR_PHYS_CTRS)
			val = (val << 16) | (phys_val & 0xffff);
		else
			val = (val & 0xffff) | (phys_val & 0xffff0000);
	}
	ps3_write_phys_ctr(cpu, phys_ctr, val);
}