[U-Boot] [PATCH v2 0/2] add support for printing of clock information as part of 'bdinfo' command

This patch series adds support for printing of clock information as part of 'bdinfo' command. Support for printing CPU, DSP core and DDR frequency is added. Also, support for printing frequency info during u-boot initialization is removed as it will delay u-boot coming up.
Changes from previous version: 1: Add support for printing clock information as part of bdinfo command instead of custom command, so that all architectures can have benefit of it.
Manjunath Hadli (2): davinci: remove macro CONFIG_DISPLAY_CPUINFO davinci: add support for printing clock frequency
arch/arm/cpu/arm926ejs/davinci/cpu.c | 76 +++++++++++++------------------ 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 | 5 ++- include/configs/da830evm.h | 4 ++ include/configs/da850evm.h | 4 ++ include/configs/davinci_dm355evm.h | 5 ++- include/configs/davinci_dm355leopard.h | 5 ++- include/configs/davinci_dm365evm.h | 4 ++ include/configs/davinci_dm6467Tevm.h | 5 ++- include/configs/davinci_dm6467evm.h | 5 ++- include/configs/davinci_dvevm.h | 6 ++- include/configs/davinci_schmoogie.h | 5 ++- include/configs/davinci_sffsdr.h | 5 ++- include/configs/davinci_sonata.h | 5 ++- include/configs/ea20.h | 4 ++ include/configs/enbw_cmc.h | 5 ++- include/configs/hawkboard.h | 4 ++ 20 files changed, 115 insertions(+), 55 deletions(-)

remove the macro CONFIG_DISPLAY_CPUINFO as it is no longer required. This is because clock info will be printed as part 'bdinfo' command and also remove support print_cpuinfo() as it will no longer be called.
Signed-off-by: Manjunath Hadli manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com --- arch/arm/cpu/arm926ejs/davinci/cpu.c | 44 -------------------------------- include/configs/cam_enc_4xx.h | 1 - include/configs/davinci_dm355evm.h | 1 - include/configs/davinci_dm355leopard.h | 1 - include/configs/davinci_dm6467Tevm.h | 1 - include/configs/davinci_dm6467evm.h | 1 - include/configs/davinci_dvevm.h | 1 - include/configs/davinci_schmoogie.h | 1 - include/configs/davinci_sffsdr.h | 1 - include/configs/davinci_sonata.h | 1 - include/configs/enbw_cmc.h | 1 - 11 files changed, 0 insertions(+), 54 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/cpu.c b/arch/arm/cpu/arm926ejs/davinci/cpu.c index 9ea9785..1735555 100644 --- a/arch/arm/cpu/arm926ejs/davinci/cpu.c +++ b/arch/arm/cpu/arm926ejs/davinci/cpu.c @@ -115,21 +115,8 @@ int clk_get(enum davinci_clk_ids id) out: return pll_out; } -#ifdef CONFIG_DISPLAY_CPUINFO -int print_cpuinfo(void) -{ - printf("Cores: ARM %d MHz", - clk_get(DAVINCI_ARM_CLKID) / 1000000); - printf("\nDDR: %d MHz\n", - /* DDR PHY uses an x2 input clock */ - clk_get(0x10001) / 1000000); - return 0; -} -#endif #else /* CONFIG_SOC_DA8XX */
-#ifdef CONFIG_DISPLAY_CPUINFO - static unsigned pll_div(volatile void *pllbase, unsigned offset) { u32 div; @@ -185,36 +172,6 @@ static unsigned pll_sysclk_mhz(unsigned pll_addr, unsigned div) return DIV_ROUND_UP(base, 1000 * pll_div(pllbase, div)); }
-int print_cpuinfo(void) -{ - /* REVISIT fetch and display CPU ID and revision information - * too ... that will matter as more revisions appear. - */ -#if defined(CONFIG_SOC_DM365) - printf("Cores: ARM %d MHz", - pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, ARM_PLLDIV)); -#else - printf("Cores: ARM %d MHz", - pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, ARM_PLLDIV)); -#endif - -#ifdef DSP_PLLDIV - printf(", DSP %d MHz", - pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, DSP_PLLDIV)); -#endif - - printf("\nDDR: %d MHz\n", - /* DDR PHY uses an x2 input clock */ -#if defined(CONFIG_SOC_DM365) - pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, DDR_PLLDIV) - / 2); -#else - pll_sysclk_mhz(DAVINCI_PLL_CNTRL1_BASE, DDR_PLLDIV) - / 2); -#endif - return 0; -} - #ifdef DAVINCI_DM6467EVM unsigned int davinci_arm_clk_get() { @@ -228,7 +185,6 @@ unsigned int davinci_clk_get(unsigned int div) return pll_sysclk_mhz(DAVINCI_PLL_CNTRL0_BASE, div) * 1000000; } #endif -#endif /* CONFIG_DISPLAY_CPUINFO */ #endif /* !CONFIG_SOC_DA8XX */
/* diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h index a21d448..419cfd4 100644 --- a/include/configs/cam_enc_4xx.h +++ b/include/configs/cam_enc_4xx.h @@ -257,7 +257,6 @@ #define CONFIG_POST CONFIG_SYS_POST_MEMORY #define _POST_WORD_ADDR 0x0
-#define CONFIG_DISPLAY_CPUINFO #define CONFIG_DISPLAY_BOARDINFO
#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SPL_STACK diff --git a/include/configs/davinci_dm355evm.h b/include/configs/davinci_dm355evm.h index ddf673c..8578730 100644 --- a/include/configs/davinci_dm355evm.h +++ b/include/configs/davinci_dm355evm.h @@ -26,7 +26,6 @@ #define CONFIG_SKIP_LOWLEVEL_INIT /* U-Boot is a 3rd stage loader */ #define CONFIG_SYS_NO_FLASH /* that is, no *NOR* flash */ #define CONFIG_SYS_CONSOLE_INFO_QUIET -#define CONFIG_DISPLAY_CPUINFO
/* SoC Configuration */ #define CONFIG_ARM926EJS /* arm926ejs CPU */ diff --git a/include/configs/davinci_dm355leopard.h b/include/configs/davinci_dm355leopard.h index dfa0a00..eaff66e 100644 --- a/include/configs/davinci_dm355leopard.h +++ b/include/configs/davinci_dm355leopard.h @@ -25,7 +25,6 @@ #define CONFIG_SKIP_LOWLEVEL_INIT /* U-Boot is a 3rd stage loader */ #define CONFIG_SYS_NO_FLASH /* that is, no *NOR* flash */ #define CONFIG_SYS_CONSOLE_INFO_QUIET -#define CONFIG_DISPLAY_CPUINFO
/* SoC Configuration */ #define CONFIG_ARM926EJS /* arm926ejs CPU */ diff --git a/include/configs/davinci_dm6467Tevm.h b/include/configs/davinci_dm6467Tevm.h index b3a4e44..f7c994e 100644 --- a/include/configs/davinci_dm6467Tevm.h +++ b/include/configs/davinci_dm6467Tevm.h @@ -23,7 +23,6 @@ /* Spectrum Digital TMS320DM6467T EVM board */ #define DAVINCI_DM6467EVM #define DAVINCI_DM6467TEVM -#define CONFIG_DISPLAY_CPUINFO #define CONFIG_SYS_USE_NAND #define CONFIG_SYS_NAND_SMALLPAGE
diff --git a/include/configs/davinci_dm6467evm.h b/include/configs/davinci_dm6467evm.h index c9a0cd1..ddfd3ed 100644 --- a/include/configs/davinci_dm6467evm.h +++ b/include/configs/davinci_dm6467evm.h @@ -22,7 +22,6 @@
/* Spectrum Digital TMS320DM6467 EVM board */ #define DAVINCI_DM6467EVM -#define CONFIG_DISPLAY_CPUINFO #define CONFIG_SYS_USE_NAND #define CONFIG_SYS_NAND_SMALLPAGE
diff --git a/include/configs/davinci_dvevm.h b/include/configs/davinci_dvevm.h index c052517..a2aa3c3 100644 --- a/include/configs/davinci_dvevm.h +++ b/include/configs/davinci_dvevm.h @@ -51,7 +51,6 @@ #define DV_EVM #define CONFIG_SYS_NAND_SMALLPAGE #define CONFIG_SYS_USE_NAND -#define CONFIG_DISPLAY_CPUINFO /*===================*/ /* SoC Configuration */ /*===================*/ diff --git a/include/configs/davinci_schmoogie.h b/include/configs/davinci_schmoogie.h index f4ddbea..e0a8ee9 100644 --- a/include/configs/davinci_schmoogie.h +++ b/include/configs/davinci_schmoogie.h @@ -26,7 +26,6 @@ #define SCHMOOGIE #define CONFIG_SYS_NAND_LARGEPAGE #define CONFIG_SYS_USE_NAND -#define CONFIG_DISPLAY_CPUINFO #define MACH_TYPE_SCHMOOGIE 1255 #define CONFIG_MACH_TYPE MACH_TYPE_SCHMOOGIE
diff --git a/include/configs/davinci_sffsdr.h b/include/configs/davinci_sffsdr.h index 0c65391..a2da65a 100644 --- a/include/configs/davinci_sffsdr.h +++ b/include/configs/davinci_sffsdr.h @@ -28,7 +28,6 @@ #define CONFIG_SYS_NAND_LARGEPAGE #define CONFIG_SYS_USE_NAND #define CONFIG_SYS_USE_DSPLINK /* don't power up the DSP. */ -#define CONFIG_DISPLAY_CPUINFO /* SoC Configuration */ #define CONFIG_ARM926EJS /* arm926ejs CPU core */ #define CONFIG_SYS_TIMERBASE 0x01c21400 /* use timer 0 */ diff --git a/include/configs/davinci_sonata.h b/include/configs/davinci_sonata.h index fc4d8ec..db47966 100644 --- a/include/configs/davinci_sonata.h +++ b/include/configs/davinci_sonata.h @@ -51,7 +51,6 @@ #define SONATA_BOARD #define CONFIG_SYS_NAND_SMALLPAGE #define CONFIG_SYS_USE_NOR -#define CONFIG_DISPLAY_CPUINFO #define MACH_TYPE_SONATA 1254 #define CONFIG_MACH_TYPE MACH_TYPE_SONATA /*===================*/ diff --git a/include/configs/enbw_cmc.h b/include/configs/enbw_cmc.h index c427dc7..1cbc5cc 100644 --- a/include/configs/enbw_cmc.h +++ b/include/configs/enbw_cmc.h @@ -50,7 +50,6 @@ #define CONFIG_ARCH_CPU_INIT #define CONFIG_DA8XX_GPIO #define CONFIG_HOSTNAME enbw_cmc -#define CONFIG_DISPLAY_CPUINFO
#define MACH_TYPE_ENBW_CMC 3585 #define CONFIG_MACH_TYPE MACH_TYPE_ENBW_CMC

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 manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com --- 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 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/cpu.c b/arch/arm/cpu/arm926ejs/davinci/cpu.c index 1735555..b3c9fb7 100644 --- a/arch/arm/cpu/arm926ejs/davinci/cpu.c +++ b/arch/arm/cpu/arm926ejs/davinci/cpu.c @@ -25,6 +25,8 @@ #include <asm/arch/hardware.h> #include <asm/io.h>
+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 f30b9fc..20e1653 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 3d78274..500e216 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 97f2945..5359a47 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 3df1def..637422c 100644 --- a/include/common.h +++ b/include/common.h @@ -284,6 +284,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 419cfd4..3216e67 100644 --- a/include/configs/cam_enc_4xx.h +++ b/include/configs/cam_enc_4xx.h @@ -123,6 +123,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 6ac25d2..7af04d1 100644 --- a/include/configs/da830evm.h +++ b/include/configs/da830evm.h @@ -204,6 +204,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 fcbbace..aa5eb0e 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -270,6 +270,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 8578730..42caf1e 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 eaff66e..35b24f7 100644 --- a/include/configs/davinci_dm355leopard.h +++ b/include/configs/davinci_dm355leopard.h @@ -84,6 +84,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 cb6ed24..a75bce6 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 f7c994e..0cbdec8 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 ddfd3ed..e0fe6b5 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 a2aa3c3..310d577 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 e0a8ee9..949174a 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 a2da65a..c931ede 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 db47966..854099b 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 74fec3f..31c9695 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 1cbc5cc..d759b35 100644 --- a/include/configs/enbw_cmc.h +++ b/include/configs/enbw_cmc.h @@ -271,6 +271,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 12acb27..b37871f 100644 --- a/include/configs/hawkboard.h +++ b/include/configs/hawkboard.h @@ -189,6 +189,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

On Mon, Feb 06, 2012 at 04:00:44PM +0530, Manjunath Hadli wrote:
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 manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com
Sorry I am late to the party, especially as this already seems to have been applied to u-boot master, but I have just tried out this bit of code and have some feedback having looked at it.
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 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/cpu.c b/arch/arm/cpu/arm926ejs/davinci/cpu.c index 1735555..b3c9fb7 100644 --- a/arch/arm/cpu/arm926ejs/davinci/cpu.c +++ b/arch/arm/cpu/arm926ejs/davinci/cpu.c @@ -25,6 +25,8 @@ #include <asm/arch/hardware.h> #include <asm/io.h>
+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;
0x10001 is a magic number... add a define for it?
+#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;
+}
This function seems to be wrong. If CONFIG_SOC_DA8XX, then gd->bd->bi_dsp_freq never gets initialised, as evidenced by the following result:
gsl-diamond > bdinfo arch_number = 0x00000D27 (...snip...) ARM frequency = 300 MHz DSP frequency = -17 MHz DDR frequency = 100 MHz
I suppose it could be resolved by moving the section starting at #ifdef DSP_PLLDIV to just above the return statement, but to be honest I found this function rather difficult to follow. Perhaps it could be reworked to be a bit cleaner?
/*
- 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 f30b9fc..20e1653 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;
I'm not sure that this really belongs in every ARM board's struct bd_info, as it implies the only three clocks we'll care about are ARM, DSP and DDR. I doubt that maps nicely onto most of the SoCs out there.
Whitespace doesn't match the rest of the file (even if the rest of the file is wrong, and this patch has used tabs as it should have).
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 3d78274..500e216 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 97f2945..5359a47 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; }
Again, here it is implied that the only clocks we'll ever want to print are ARM, DSP and DDR. Seems way too specific for such common code.
Bye for now,

On 02/17/2012 06:22 AM, Laurence Withers wrote:
On Mon, Feb 06, 2012 at 04:00:44PM +0530, Manjunath Hadli wrote:
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 Hadlimanjunath.hadli@ti.com Cc: Tom Rinitrini@ti.com
Sorry I am late to the party, especially as this already seems to have been applied to u-boot master, but I have just tried out this bit of code and have some feedback having looked at it.
Review is always welcome, thanks.
[snip]
diff --git a/arch/arm/include/asm/u-boot.h b/arch/arm/include/asm/u-boot.h index f30b9fc..20e1653 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;
I'm not sure that this really belongs in every ARM board's struct bd_info, as it implies the only three clocks we'll care about are ARM, DSP and DDR. I doubt that maps nicely onto most of the SoCs out there.
Checking powerpc there is precedent for #if'ing this structure, so that should be done. As for making it more generic, yes, my hope is that once the next SoC says "I want to print clocks" we can start mapping things out more. And as you noted above (and I snipped) we do need to clean up and fix the current init sequence.
Whitespace doesn't match the rest of the file (even if the rest of the file is wrong, and this patch has used tabs as it should have).
I was hoping checkpatch warned on that type of mismatch so I need to rework my workflow a bit.
[snip]
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 97f2945..5359a47 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; }
Again, here it is implied that the only clocks we'll ever want to print are ARM, DSP and DDR. Seems way too specific for such common code.
Note that do_bdinfo is already per-arch. This is intended as a starting point for generic work and the first step away from doing this in a per-board fashion. Thanks!
participants (3)
-
Laurence Withers
-
Manjunath Hadli
-
Tom Rini