diff options
author | Wolfgang Grandegger <wg@grandegger.com> | 2009-03-11 11:36:26 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2009-03-11 11:36:26 -0400 |
commit | df8a95f46f8e43a24003abe2efaca8c63c895b54 (patch) | |
tree | cee931917b5bbc3e77d9b3e2ad3145856d8118b8 /arch | |
parent | bb899d49a5d04ae53c787c15c5fb82754d6a0da4 (diff) |
powerpc/5200: add function to return external clock frequency
This patch adds the utility function mpc52xx_get_xtal_freq() to get
the frequency of the external oscillator clock connected to the pin
SYS_XTAL_IN. The MSCAN may us it as clock source. Unfortunately, this
value is not available from the FDT blob, but it can be determined
from the IPB frequency.
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/mpc52xx.h | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/52xx/mpc52xx_common.c | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/mpc52xx.h b/arch/powerpc/include/asm/mpc52xx.h index 81a23932a160..52e049cd9e68 100644 --- a/arch/powerpc/include/asm/mpc52xx.h +++ b/arch/powerpc/include/asm/mpc52xx.h | |||
@@ -273,6 +273,7 @@ extern void mpc5200_setup_xlb_arbiter(void); | |||
273 | extern void mpc52xx_declare_of_platform_devices(void); | 273 | extern void mpc52xx_declare_of_platform_devices(void); |
274 | extern void mpc52xx_map_common_devices(void); | 274 | extern void mpc52xx_map_common_devices(void); |
275 | extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv); | 275 | extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv); |
276 | extern unsigned int mpc52xx_get_xtal_freq(struct device_node *node); | ||
276 | extern void mpc52xx_restart(char *cmd); | 277 | extern void mpc52xx_restart(char *cmd); |
277 | 278 | ||
278 | /* mpc52xx_pic.c */ | 279 | /* mpc52xx_pic.c */ |
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c index e9d2cf632eeb..8e3dd5a0f228 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_common.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c | |||
@@ -206,6 +206,43 @@ int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv) | |||
206 | EXPORT_SYMBOL(mpc52xx_set_psc_clkdiv); | 206 | EXPORT_SYMBOL(mpc52xx_set_psc_clkdiv); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * mpc52xx_get_xtal_freq - Get SYS_XTAL_IN frequency for a device | ||
210 | * | ||
211 | * @node: device node | ||
212 | * | ||
213 | * Returns the frequency of the external oscillator clock connected | ||
214 | * to the SYS_XTAL_IN pin, or 0 if it cannot be determined. | ||
215 | */ | ||
216 | unsigned int mpc52xx_get_xtal_freq(struct device_node *node) | ||
217 | { | ||
218 | u32 val; | ||
219 | unsigned int freq; | ||
220 | |||
221 | if (!mpc52xx_cdm) | ||
222 | return 0; | ||
223 | |||
224 | freq = mpc52xx_find_ipb_freq(node); | ||
225 | if (!freq) | ||
226 | return 0; | ||
227 | |||
228 | if (in_8(&mpc52xx_cdm->ipb_clk_sel) & 0x1) | ||
229 | freq *= 2; | ||
230 | |||
231 | val = in_be32(&mpc52xx_cdm->rstcfg); | ||
232 | if (val & (1 << 5)) | ||
233 | freq *= 8; | ||
234 | else | ||
235 | freq *= 4; | ||
236 | if (val & (1 << 6)) | ||
237 | freq /= 12; | ||
238 | else | ||
239 | freq /= 16; | ||
240 | |||
241 | return freq; | ||
242 | } | ||
243 | EXPORT_SYMBOL(mpc52xx_get_xtal_freq); | ||
244 | |||
245 | /** | ||
209 | * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer | 246 | * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer |
210 | */ | 247 | */ |
211 | void | 248 | void |