From c9fc3626fd9733df1cde19c6df6f04bdcaf62f05 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 22 Sep 2011 12:06:15 +0200 Subject: ppc mpc5200: add function to setup bus clocks Signed-off-by: Sascha Hauer --- arch/ppc/mach-mpc5xxx/cpu.c | 38 ++++++++++++++++++++++++++++ arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h | 3 +++ 2 files changed, 41 insertions(+) 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 #include #include +#include #include #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 */ -- cgit v1.2.3