From 8f5d468721ef3931e4c6f9c6555348f26acdec19 Mon Sep 17 00:00:00 2001 From: "Hadli, Manjunath" Date: Mon, 6 Feb 2012 00:30:44 +0000 Subject: [PATCH] davinci: add support for printing clock frequency add support for printing various clock frequency info found in SOC such as ARM core frequency, DSP core frequency and DDR frequency as part of bdinfo command. Signed-off-by: Manjunath Hadli Cc: Tom Rini --- arch/arm/cpu/arm926ejs/davinci/cpu.c | 32 ++++++++++++++++++++++++++ arch/arm/include/asm/u-boot.h | 3 +++ arch/arm/lib/board.c | 10 +++++++- common/cmd_bdinfo.c | 9 ++++++++ include/common.h | 1 + include/configs/cam_enc_4xx.h | 4 ++++ include/configs/da830evm.h | 4 ++++ include/configs/da850evm.h | 4 ++++ include/configs/davinci_dm355evm.h | 4 ++++ include/configs/davinci_dm355leopard.h | 4 ++++ include/configs/davinci_dm365evm.h | 4 ++++ include/configs/davinci_dm6467Tevm.h | 4 ++++ include/configs/davinci_dm6467evm.h | 4 ++++ include/configs/davinci_dvevm.h | 5 ++++ include/configs/davinci_schmoogie.h | 4 ++++ include/configs/davinci_sffsdr.h | 4 ++++ include/configs/davinci_sonata.h | 4 ++++ include/configs/ea20.h | 4 ++++ include/configs/enbw_cmc.h | 4 ++++ include/configs/hawkboard.h | 4 ++++ 20 files changed, 115 insertions(+), 1 deletion(-) diff --git a/arch/arm/cpu/arm926ejs/davinci/cpu.c b/arch/arm/cpu/arm926ejs/davinci/cpu.c index 173555522..b3c9fb7b6 100644 --- a/arch/arm/cpu/arm926ejs/davinci/cpu.c +++ b/arch/arm/cpu/arm926ejs/davinci/cpu.c @@ -25,6 +25,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + /* offsets from PLL controller base */ #define PLLC_PLLCTL 0x100 #define PLLC_PLLM 0x110 @@ -187,6 +189,36 @@ unsigned int davinci_clk_get(unsigned int div) #endif #endif /* !CONFIG_SOC_DA8XX */ +int set_cpu_clk_info(void) +{ +#ifdef CONFIG_SOC_DA8XX + gd->bd->bi_arm_freq = clk_get(DAVINCI_ARM_CLKID) / 1000000; + /* DDR PHY uses an x2 input clock */ + gd->bd->bi_ddr_freq = clk_get(0x10001) / 1000000; +#else + + unsigned int pllbase = DAVINCI_PLL_CNTRL0_BASE; +#if defined(CONFIG_SOC_DM365) + pllbase = DAVINCI_PLL_CNTRL1_BASE; +#endif + gd->bd->bi_arm_freq = pll_sysclk_mhz(pllbase, ARM_PLLDIV); + +#ifdef DSP_PLLDIV + gd->bd->bi_dsp_freq = + pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, DSP_PLLDIV); +#else + gd->bd->bi_dsp_freq = 0; +#endif + + pllbase = DAVINCI_PLL_CNTRL1_BASE; +#if defined(CONFIG_SOC_DM365) + pllbase = DAVINCI_PLL_CNTRL0_BASE; +#endif + gd->bd->bi_ddr_freq = pll_sysclk_mhz(pllbase, DDR_PLLDIV) / 2; +#endif + return 0; +} + /* * Initializes on-chip ethernet controllers. * to override, implement board_eth_init() diff --git a/arch/arm/include/asm/u-boot.h b/arch/arm/include/asm/u-boot.h index f30b9fc96..20e165393 100644 --- a/arch/arm/include/asm/u-boot.h +++ b/arch/arm/include/asm/u-boot.h @@ -41,6 +41,9 @@ typedef struct bd_info { unsigned long bi_ip_addr; /* IP Address */ ulong bi_arch_number; /* unique id for this board */ ulong bi_boot_params; /* where this board expects params */ + unsigned long bi_arm_freq; /* arm frequency */ + unsigned long bi_dsp_freq; /* dsp core frequency */ + unsigned long bi_ddr_freq; /* ddr frequency */ struct /* RAM configuration */ { ulong start; diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 3d7827407..500e2164c 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -463,7 +463,15 @@ void board_init_r(gd_t *id, ulong dest_addr) debug("monitor flash len: %08lX\n", monitor_flash_len); board_init(); /* Setup chipselects */ - + /* + * TODO: printing of the clock inforamtion of the board is now + * implemented as part of bdinfo command. Currently only support for + * davinci SOC's is added. Remove this check once all the board + * implement this. + */ +#ifdef CONFIG_CLOCKS + set_cpu_clk_info(); /* Setup clock information */ +#endif #ifdef CONFIG_SERIAL_MULTI serial_initialize(); #endif diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 97f29456f..5359a4785 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -370,6 +370,15 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num("irq_sp", gd->irq_sp); /* irq stack pointer */ print_num("sp start ", gd->start_addr_sp); print_num("FB base ", gd->fb_base); + /* + * TODO: Currently only support for davinci SOC's is added. + * Remove this check once all the board implement this. + */ +#ifdef CONFIG_CLOCKS + printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq); + printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq); + printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq); +#endif return 0; } diff --git a/include/common.h b/include/common.h index 7a9b3a238..a2c6b27d4 100644 --- a/include/common.h +++ b/include/common.h @@ -285,6 +285,7 @@ int last_stage_init(void); extern ulong monitor_flash_len; int mac_read_from_eeprom(void); extern u8 _binary_dt_dtb_start[]; /* embedded device tree blob */ +int set_cpu_clk_info(void); /* * Called when console output is requested before the console is available. diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h index bca9841a1..79a8611f8 100644 --- a/include/configs/cam_enc_4xx.h +++ b/include/configs/cam_enc_4xx.h @@ -121,6 +121,10 @@ #define CONFIG_CMD_PING #define CONFIG_CMD_SAVES +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifdef CONFIG_MMC #define CONFIG_DOS_PARTITION #define CONFIG_CMD_EXT2 diff --git a/include/configs/da830evm.h b/include/configs/da830evm.h index e8c021262..4532e4f4f 100644 --- a/include/configs/da830evm.h +++ b/include/configs/da830evm.h @@ -203,6 +203,10 @@ #undef CONFIG_CMD_FPGA #undef CONFIG_CMD_SETGETDCR +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifndef CONFIG_DRIVER_TI_EMAC #undef CONFIG_CMD_NET #undef CONFIG_CMD_DHCP diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 220890dfd..f32bd34ad 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -269,6 +269,10 @@ #define CONFIG_CMD_SAVES #define CONFIG_CMD_MEMORY +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifndef CONFIG_DRIVER_TI_EMAC #undef CONFIG_CMD_NET #undef CONFIG_CMD_DHCP diff --git a/include/configs/davinci_dm355evm.h b/include/configs/davinci_dm355evm.h index 8578730ba..42caf1e42 100644 --- a/include/configs/davinci_dm355evm.h +++ b/include/configs/davinci_dm355evm.h @@ -98,6 +98,10 @@ #define CONFIG_CMD_PING #define CONFIG_CMD_SAVES +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifdef CONFIG_MMC #define CONFIG_DOS_PARTITION #define CONFIG_CMD_EXT2 diff --git a/include/configs/davinci_dm355leopard.h b/include/configs/davinci_dm355leopard.h index 803e8578f..b05cfbaa8 100644 --- a/include/configs/davinci_dm355leopard.h +++ b/include/configs/davinci_dm355leopard.h @@ -83,6 +83,10 @@ #define CONFIG_CMD_PING #define CONFIG_CMD_SAVES +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifdef CONFIG_NAND_DAVINCI #define CONFIG_CMD_MTDPARTS #define CONFIG_MTD_PARTITIONS diff --git a/include/configs/davinci_dm365evm.h b/include/configs/davinci_dm365evm.h index cb6ed24a8..a75bce675 100644 --- a/include/configs/davinci_dm365evm.h +++ b/include/configs/davinci_dm365evm.h @@ -142,6 +142,10 @@ #define CONFIG_CMD_PING #define CONFIG_CMD_SAVES +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifdef CONFIG_MMC #define CONFIG_DOS_PARTITION #define CONFIG_CMD_EXT2 diff --git a/include/configs/davinci_dm6467Tevm.h b/include/configs/davinci_dm6467Tevm.h index f7c994eba..0cbdec868 100644 --- a/include/configs/davinci_dm6467Tevm.h +++ b/include/configs/davinci_dm6467Tevm.h @@ -152,6 +152,10 @@ extern unsigned int davinci_arm_clk_get(void); #define CONFIG_CMD_NAND #endif +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #define CONFIG_MAX_RAM_BANK_SIZE (256 << 20) /* 256 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 diff --git a/include/configs/davinci_dm6467evm.h b/include/configs/davinci_dm6467evm.h index ddfd3ed39..e0fe6b5c2 100644 --- a/include/configs/davinci_dm6467evm.h +++ b/include/configs/davinci_dm6467evm.h @@ -150,6 +150,10 @@ extern unsigned int davinci_arm_clk_get(void); #define CONFIG_CMD_NAND #endif +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #define CONFIG_MAX_RAM_BANK_SIZE (256 << 20) /* 256 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 diff --git a/include/configs/davinci_dvevm.h b/include/configs/davinci_dvevm.h index a2aa3c3fc..310d5770d 100644 --- a/include/configs/davinci_dvevm.h +++ b/include/configs/davinci_dvevm.h @@ -199,6 +199,11 @@ #define CONFIG_CMD_SAVES #define CONFIG_CMD_EEPROM #undef CONFIG_CMD_BDI + +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #undef CONFIG_CMD_FPGA #undef CONFIG_CMD_SETGETDCR #ifdef CONFIG_SYS_USE_NAND diff --git a/include/configs/davinci_schmoogie.h b/include/configs/davinci_schmoogie.h index e0a8ee9a9..949174a16 100644 --- a/include/configs/davinci_schmoogie.h +++ b/include/configs/davinci_schmoogie.h @@ -148,6 +148,10 @@ #undef CONFIG_CMD_FLASH #undef CONFIG_CMD_IMLS +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #define CONFIG_MAX_RAM_BANK_SIZE (256 << 20) /* 256 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 diff --git a/include/configs/davinci_sffsdr.h b/include/configs/davinci_sffsdr.h index a2da65a76..c931ede85 100644 --- a/include/configs/davinci_sffsdr.h +++ b/include/configs/davinci_sffsdr.h @@ -141,6 +141,10 @@ #undef CONFIG_CMD_FLASH #undef CONFIG_CMD_IMLS +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #define CONFIG_MAX_RAM_BANK_SIZE (256 << 20) /* 256 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 diff --git a/include/configs/davinci_sonata.h b/include/configs/davinci_sonata.h index db4796624..854099b2a 100644 --- a/include/configs/davinci_sonata.h +++ b/include/configs/davinci_sonata.h @@ -199,6 +199,10 @@ #error "Either CONFIG_SYS_USE_NAND or CONFIG_SYS_USE_NOR _MUST_ be defined !!!" #endif +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #define CONFIG_MAX_RAM_BANK_SIZE (256 << 20) /* 256 MB */ #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 diff --git a/include/configs/ea20.h b/include/configs/ea20.h index cc0f5b05c..b4610d947 100644 --- a/include/configs/ea20.h +++ b/include/configs/ea20.h @@ -168,6 +168,10 @@ #define CONFIG_CMD_MEMORY #define CONFIG_CMD_I2C +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifndef CONFIG_DRIVER_TI_EMAC #undef CONFIG_CMD_NET #undef CONFIG_CMD_DHCP diff --git a/include/configs/enbw_cmc.h b/include/configs/enbw_cmc.h index 9cffaee11..9fd6a4f18 100644 --- a/include/configs/enbw_cmc.h +++ b/include/configs/enbw_cmc.h @@ -269,6 +269,10 @@ #define CONFIG_CMD_MEMORY #define CONFIG_CMD_CACHE +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifndef CONFIG_DRIVER_TI_EMAC #undef CONFIG_CMD_NET #undef CONFIG_CMD_DHCP diff --git a/include/configs/hawkboard.h b/include/configs/hawkboard.h index fa214941a..21f7b9b7e 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -185,6 +185,10 @@ #define CONFIG_CMD_SAVES #define CONFIG_CMD_MEMORY +#ifdef CONFIG_CMD_BDI +#define CONFIG_CLOCKS +#endif + #ifdef CONFIG_SYS_USE_NAND #undef CONFIG_CMD_FLASH #undef CONFIG_CMD_IMLS