[U-Boot] [PATCH 1/2] Removed CONFIG_NUM_CPUS for 85xx and 86xx Freescale processors.

Wolfgang Denk wd at denx.de
Tue Jul 21 13:52:13 CEST 2009


Dear Poonam Aggrwal,

In message <1248173263-30516-1-git-send-email-poonam.aggrwal at freescale.com> you wrote:
> The number of CPUs are getting detected dynamically by checking the processor SVR value.
> Also removed CONFIG_NUM_CPUS references from all the platforms with 85xx/86xx processors.

Please restrict your line length to 70 characters or less.

...
> +#ifndef CONFIG_MP
> +	if (cpu_numcores() > 1)
> +		puts("#############################################\n"
> +			"The system is detected to be MULTICORE,\n"
> +			"but u-boot is built with UNI-CORE\n"
> +			"To enable mutlticore Build set CONFIG_MP\n"
> +		     "#############################################\n\n");
>  #endif

Please use terse error messages. We don't print prose here.

> -	cpu = identify_cpu(ver);
> -	if (cpu) {
> +	if (cpu_numcores() > 1) {
> +		volatile ccsr_pic_t *pic = (void *)(CONFIG_SYS_MPC85xx_PIC_ADDR);
> +		printf("CPU%d:  ", pic->whoami);
> +	}
> +	else

Incorrect brace style.

> --- a/cpu/mpc85xx/speed.c
> +++ b/cpu/mpc85xx/speed.c
...
> @@ -51,7 +51,7 @@ void get_sys_info (sys_info_t * sysInfo)
>  	/* Divide before multiply to avoid integer
>  	 * overflow for processor speeds above 2GHz */
>  	half_freqSystemBus = sysInfo->freqSystemBus/2;
> -	for (i = 0; i < CONFIG_NUM_CPUS; i++) {
> +	for (i = 0; i  < cpu_numcores(); i++) {

Only one space before the '<', please.

...
> --- a/cpu/mpc86xx/cpu.c
> +++ b/cpu/mpc86xx/cpu.c
...
> +int probecpu (void)
> +{
> +	uint svr;
> +	uint ver;
> +
> +	svr = get_svr();
> +	ver = SVR_SOC_VER(svr);
> +
> +	gd->cpu = identify_cpu(ver);
> +
> +	return 0;
> +}
> +
> +int cpu_numcores() {
> +	struct cpu_type *cpu;
> +	cpu = gd->cpu;
> +	return cpu->num_cores;
> +}
> +

This seems to be identically repeated code. Please factor out into
common code.

>   * Default board reset function
>   */
> @@ -66,9 +88,9 @@ checkcpu(void)
>  	uint ver;
>  	uint major, minor;
>  	char buf1[32], buf2[32];
> +	struct cpu_type *cpu;
>  	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
>  	volatile ccsr_gur_t *gur = &immap->im_gur;
> -	struct cpu_type *cpu;
>  	uint msscr0 = mfspr(MSSCR0);
>  
>  	svr = get_svr();
> @@ -76,10 +98,20 @@ checkcpu(void)
>  	major = SVR_MAJ(svr);
>  	minor = SVR_MIN(svr);
>  
> +#ifndef CONFIG_MP
> +	if (cpu_numcores() > 1)
> +		puts("#############################################\n"
> +			"The system is detected to be MULTICORE,\n"
> +			"but u-boot is built with UNI-CORE\n"
> +			"To enable mutlticore Build set CONFIG_MP\n"
> +		     "#############################################\n\n");
> +#endif

Ditto.

>  	puts("CPU:   ");
>  
> -	cpu = identify_cpu(ver);
> -	if (cpu) {
> +	cpu = gd->cpu;
> +
> +	if (cpu->name) {
>  		puts(cpu->name);
>  	} else {

No braces for one-line statements, please.

> diff --git a/include/asm-ppc/config.h b/include/asm-ppc/config.h
> index ca143c7..b799a22 100644
> --- a/include/asm-ppc/config.h
> +++ b/include/asm-ppc/config.h
> @@ -37,4 +37,45 @@
>  #endif
>  #endif
>  
> +#if defined(CONFIG_MPC8533)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8535)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8536)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8540)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8541)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8543)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8544)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8545)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8547)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8548)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8555)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8560)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8567)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8568)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8569)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8572)
> +#define CONFIG_MAX_CPUS	2
> +#elif defined(CONFIG_P2020)
> +#define CONFIG_MAX_CPUS	2
> +
> +#elif defined(CONFIG_MPC8610)
> +#define CONFIG_MAX_CPUS	1
> +#elif defined(CONFIG_MPC8641)
> +#define CONFIG_MAX_CPUS	2
> +#endif

Sorry, but this does not scale. Please find a better solution.

> diff --git a/include/asm-ppc/global_data.h b/include/asm-ppc/global_data.h
> index 244c161..aa531b9 100644
> --- a/include/asm-ppc/global_data.h
> +++ b/include/asm-ppc/global_data.h
> @@ -1,4 +1,5 @@
>  /*
> + * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.

On which base to you make such a claim?

>   * (C) Copyright 2002
>   * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
>   *
> @@ -92,6 +93,9 @@ typedef	struct	global_data {
>  #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
>  	u32 lbc_clk;
>  #endif /* CONFIG_MPC85xx || CONFIG_MPC86xx */
> +#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
> +	void *cpu;
> +#endif

Because you added a sinle variable declaration? Come on, be
reasonable...

> diff --git a/include/asm-ppc/processor.h b/include/asm-ppc/processor.h
> index 65546ad..a060697 100644
> --- a/include/asm-ppc/processor.h
> +++ b/include/asm-ppc/processor.h
> @@ -1017,13 +1017,14 @@ n:
>  struct cpu_type {
>  	char name[15];
>  	u32 soc_ver;
> +	u32 num_cores;
>  };
>  
>  struct cpu_type *identify_cpu(u32 ver);
>  
>  #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
> -#define CPU_TYPE_ENTRY(n, v) \
> -	{ .name = #n, .soc_ver = SVR_##v, }
> +#define CPU_TYPE_ENTRY(n, v, nc) \
> +	{ .name = #n, .soc_ver = SVR_##v, .num_cores = (nc), }
>  #else
>  #if defined(CONFIG_MPC83xx)
>  #define CPU_TYPE_ENTRY(x) {#x, SPR_##x}
> diff --git a/include/common.h b/include/common.h
> index 6284b8a..ab5b4f8 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -439,6 +439,8 @@ void		ppcDWstore(unsigned int *addr, unsigned int *value);
>  #endif
>  
>  /* $(CPU)/cpu.c */
> +int	cpu_numcores  (void);
> +int	probecpu      (void);
>  int	checkcpu      (void);
>  int	checkicache   (void);
>  int	checkdcache   (void);
> diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h
> index 6f1b1a4..d542510 100644
> --- a/include/configs/MPC8572DS.h
> +++ b/include/configs/MPC8572DS.h
> @@ -34,7 +34,6 @@
>  #define CONFIG_MPC8572		1
>  #define CONFIG_MPC8572DS	1
>  #define CONFIG_MP		1	/* support multiple processors */
> -#define CONFIG_NUM_CPUS		2	/* Number of CPUs in the system */
>  
>  #define CONFIG_FSL_ELBC		1	/* Has Enhanced localbus controller */
>  #define CONFIG_PCI		1	/* Enable PCI/PCIE */
> diff --git a/include/configs/MPC8610HPCD.h b/include/configs/MPC8610HPCD.h
> index 1091043..45932ef 100644
> --- a/include/configs/MPC8610HPCD.h
> +++ b/include/configs/MPC8610HPCD.h
> @@ -17,7 +17,6 @@
>  #define CONFIG_MPC86xx		1	/* MPC86xx */
>  #define CONFIG_MPC8610		1	/* MPC8610 specific */
>  #define CONFIG_MPC8610HPCD	1	/* MPC8610HPCD board specific */
> -#define CONFIG_NUM_CPUS		1	/* Number of CPUs in the system */
>  #define CONFIG_LINUX_RESET_VEC	0x100	/* Reset vector used by Linux */
>  
>  #define CONFIG_FSL_DIU_FB	1	/* FSL DIU */
> diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h
> index 035874b..a878850 100644
> --- a/include/configs/MPC8641HPCN.h
> +++ b/include/configs/MPC8641HPCN.h
> @@ -37,7 +37,6 @@
>  #define CONFIG_MPC8641		1	/* MPC8641 specific */
>  #define CONFIG_MPC8641HPCN	1	/* MPC8641HPCN board specific */
>  #define CONFIG_MP		1	/* support multiple processors */
> -#define CONFIG_NUM_CPUS		2	/* Number of CPUs in the system */
>  #define CONFIG_LINUX_RESET_VEC	0x100	/* Reset vector used by Linux */
>  /*#define CONFIG_PHYS_64BIT	1*/	/* Place devices in 36-bit space */
>  #define CONFIG_ADDR_MAP		1	/* Use addr map */
> diff --git a/include/configs/P2020DS.h b/include/configs/P2020DS.h
> index 9306860..0d2475a 100644
> --- a/include/configs/P2020DS.h
> +++ b/include/configs/P2020DS.h
> @@ -34,7 +34,6 @@
>  #define CONFIG_P2020		1
>  #define CONFIG_P2020DS		1
>  #define CONFIG_MP		1	/* support multiple processors */
> -#define CONFIG_NUM_CPUS		2	/* Number of CPUs in the system */
>  
>  #define CONFIG_FSL_ELBC		1	/* Has Enhanced localbus controller */
>  #define CONFIG_PCI		1	/* Enable PCI/PCIE */
> diff --git a/include/configs/XPEDITE5170.h b/include/configs/XPEDITE5170.h
> index 2553293..a572fd0 100644
> --- a/include/configs/XPEDITE5170.h
> +++ b/include/configs/XPEDITE5170.h
> @@ -34,7 +34,6 @@
>  #define CONFIG_MPC8641		1	/* MPC8641 specific */
>  #define CONFIG_XPEDITE5140	1	/* MPC8641HPCN board specific */
>  #define CONFIG_SYS_BOARD_NAME	"XPedite5170"
> -#define CONFIG_NUM_CPUS		1	/* Number of CPUs in the system */
>  #define CONFIG_LINUX_RESET_VEC	0x100	/* Reset vector used by Linux */
>  #define CONFIG_BOARD_EARLY_INIT_R	/* Call board_pre_init */
>  #define CONFIG_RELOC_FIXUP_WORKS	/* Fully relocate to SDRAM */
> diff --git a/include/configs/XPEDITE5370.h b/include/configs/XPEDITE5370.h
> index 536e063..422dab3 100644
> --- a/include/configs/XPEDITE5370.h
> +++ b/include/configs/XPEDITE5370.h
> @@ -36,7 +36,6 @@
>  #define CONFIG_MPC8572		1
>  #define CONFIG_XPEDITE5370	1
>  #define CONFIG_SYS_BOARD_NAME	"XPedite5370"
> -#define CONFIG_NUM_CPUS		2	/* 2 Cores */
>  #define CONFIG_BOARD_EARLY_INIT_R	/* Call board_pre_init */
>  #define CONFIG_RELOC_FIXUP_WORKS	/* Fully relocate to SDRAM */
>  
> diff --git a/include/configs/sbc8641d.h b/include/configs/sbc8641d.h
> index ef0f627..5376e4a 100644
> --- a/include/configs/sbc8641d.h
> +++ b/include/configs/sbc8641d.h
> @@ -41,7 +41,6 @@
>  #define CONFIG_MPC8641		1	/* MPC8641 specific */
>  #define CONFIG_SBC8641D		1	/* SBC8641D board specific */
>  #define CONFIG_MP		1	/* support multiple processors */
> -#define CONFIG_NUM_CPUS         2       /* Number of CPUs in the system */
>  #define CONFIG_LINUX_RESET_VEC  0x100   /* Reset vector used by Linux */
>  
>  #ifdef RUN_DIAG
> diff --git a/include/e500.h b/include/e500.h
> index 84b580d..f8c8266 100644
> --- a/include/e500.h
> +++ b/include/e500.h
> @@ -8,13 +8,9 @@
>  
>  #ifndef __ASSEMBLY__
>  
> -#ifndef CONFIG_NUM_CPUS
> -#define CONFIG_NUM_CPUS 1
> -#endif
> -
>  typedef struct
>  {
> -  unsigned long freqProcessor[CONFIG_NUM_CPUS];
> +  unsigned long freqProcessor[CONFIG_MAX_CPUS];
>    unsigned long freqSystemBus;
>    unsigned long freqDDRBus;
>    unsigned long freqLocalBus;
> diff --git a/lib_ppc/board.c b/lib_ppc/board.c
> index 155171d..70dfe95 100644
> --- a/lib_ppc/board.c
> +++ b/lib_ppc/board.c
> @@ -291,6 +291,10 @@ init_fnc_t *init_sequence[] = {
>  	board_early_init_f,
>  #endif
>  
> +#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
> +	probecpu,
> +#endif
> +

No empty line here, please.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You can only live once, but if you do it right, once is enough.


More information about the U-Boot mailing list