/* Returns the frequency of the external oscillator clock connected to the SYS_XTAL_IN pin, or 0 if it cannot be determined.  */
unsigned int mpc52xx_get_xtal_freq(struct device_node *node)
/* Returns the frequency of the external oscillator clock connected to the SYS_XTAL_IN pin, or 0 if it cannot be determined.  */
unsigned int mpc52xx_get_xtal_freq(struct device_node *node)
{
	u32 val;
	unsigned int freq;
	if (!mpc52xx_cdm)
		return 0;
	freq = mpc5xxx_get_bus_frequency(node);
	if (!freq)
		return 0;
	if (in_8(&mpc52xx_cdm->ipb_clk_sel) & 0x1)
		freq *= 2;
	val  = in_be32(&mpc52xx_cdm->rstcfg);
	if (val & (1 << 5))
		freq *= 8;
	else
		freq *= 4;
	if (val & (1 << 6))
		freq /= 12;
	else
		freq /= 16;
	return freq;
}