/* Window Size Used with the Base register to set the address window size and location. Must be programmed from LSB to MSB as sequence of ones followed by sequence of zeros. The number of ones specifies the size of the window in 64 KByte granularity (e.g., a value of 0x00FF specifies 256 = 16 MByte). NOTE: A value of 0x0 specifies 64-KByte size.  */
unsigned int kw_winctrl_calcsize(unsigned int sizeval)
/* Window Size Used with the Base register to set the address window size and location. Must be programmed from LSB to MSB as sequence of ones followed by sequence of zeros. The number of ones specifies the size of the window in 64 KByte granularity (e.g., a value of 0x00FF specifies 256 = 16 MByte). NOTE: A value of 0x0 specifies 64-KByte size.  */
unsigned int kw_winctrl_calcsize(unsigned int sizeval)
{
	int i;
	unsigned int j = 0;
	u32 val = sizeval >> 1;
	for (i = 0; val > 0x10000; i++) {
		j |= (1 << i);
		val = val >> 1;
	}
	return (0x0000ffff & j);
}