Add a helper function to get system reference clock

Many devices are clocked from the SoC's platform clock / 2.  Some device nodes
include their own clock-frequency property, while others are dependent on the
SoC's bus-frequency property instead.  To simplify, add a helper function to get
this clock.
This commit is contained in:
jhibbits 2017-04-01 22:29:11 +00:00
parent 4f21cbf86c
commit 28c3245193
2 changed files with 16 additions and 0 deletions

View File

@ -436,3 +436,18 @@ mpc85xx_fix_errata(vm_offset_t va_ccsr)
err:
return;
}
uint32_t
mpc85xx_get_system_clock(void)
{
phandle_t soc;
uint32_t freq;
soc = OF_finddevice("/soc");
freq = 0;
/* freq isn't modified on error. */
OF_getencprop(soc, "bus-frequency", (void *)&freq, sizeof(freq));
return (freq / 2);
}

View File

@ -171,5 +171,6 @@ void mpc85xx_enable_l3_cache(void);
void mpc85xx_fix_errata(vm_offset_t);
void dataloss_erratum_access(vm_offset_t, uint32_t);
int mpc85xx_is_qoriq(void);
uint32_t mpc85xx_get_system_clock(void);
#endif /* _MPC85XX_H_ */