diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-09-22 12:06:15 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-09-27 10:27:32 +0200 |
commit | c9fc3626fd9733df1cde19c6df6f04bdcaf62f05 (patch) | |
tree | dc1715abb264774b80d65a70a337a4477ce7fef6 /arch | |
parent | bc1969658ba10447a1cff7792ce4c2786023663f (diff) | |
download | barebox-c9fc3626fd9733df1cde19c6df6f04bdcaf62f05.tar.gz barebox-c9fc3626fd9733df1cde19c6df6f04bdcaf62f05.tar.xz |
ppc mpc5200: add function to setup bus clocks
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ppc/mach-mpc5xxx/cpu.c | 38 | ||||
-rw-r--r-- | arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h | 3 |
2 files changed, 41 insertions, 0 deletions
diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c index 649f08a87d..d695b9b545 100644 --- a/arch/ppc/mach-mpc5xxx/cpu.c +++ b/arch/ppc/mach-mpc5xxx/cpu.c @@ -33,6 +33,7 @@ #include <asm/io.h> #include <init.h> #include <types.h> +#include <errno.h> #include <mach/clocks.h> #if defined(CONFIG_OF_FLAT_TREE) @@ -132,6 +133,43 @@ unsigned long mpc5200_get_sdram_size(unsigned int cs) return size; } +int mpc5200_setup_bus_clocks(unsigned int ipbdiv, unsigned long pcidiv) +{ + u32 cdmcfg = *(vu_long *)MPC5XXX_CDM_CFG; + + cdmcfg &= ~0x103; + + switch (ipbdiv) { + case 1: + break; + case 2: + cdmcfg |= 0x100; + break; + default: + return -EINVAL; + } + + switch (pcidiv) { + case 1: + if (ipbdiv == 2) + return -EINVAL; + break; + case 2: + if (ipbdiv == 1) + cdmcfg |= 0x1; /* ipb / 2 */ + break; + case 4: + cdmcfg |= 0x2; /* xlb / 4 */ + break; + default: + return -EINVAL; + } + + *(vu_long *)MPC5XXX_CDM_CFG = cdmcfg; + + return 0; +} + struct mpc5200_cs { void *start; void *stop; diff --git a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h index 558f331160..8e95dd0c11 100644 --- a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h +++ b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h @@ -786,6 +786,9 @@ unsigned long mpc5200_get_sdram_size(unsigned int cs); #define MPC5200_BOOTCS 8 void mpc5200_setup_cs(int cs, unsigned long start, unsigned long size, u32 cfg); +/* configure bus speeds. Both dividers are relative to xlb clock */ +int mpc5200_setup_bus_clocks(unsigned int ipbdiv, unsigned long pcidiv); + #endif /* __ASSEMBLY__ */ #endif /* __ASMPPC_MPC5XXX_H */ |