Skip to contentSkip to conversation

Create generic board init for ARM, x86, PPC

PATCH Superseded Simon Glass 5 participants 58 messages Mar 15, 2012 – Mar 24, 2012

Subsystems (13)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v4 cover Create generic board init for ARM, x86, PPC

This series creates a generic board.c implementation which contains the essential functions of the major arch/xxx/lib/board.c files.

What is the motivation for this change?

1. There is a lot of repeated code in the board.c files. Any change to things like setting up the baud rate requires a change in 10 separate places.

2. Since there are 10 separate files, adding a new feature which requires initialisation is painful since it must be independently added in 10 places.

3. As time goes by the architectures naturely diverge since there is limited pressure to compare features or even CONFIG options against simiilar things in other board.c files.

4. New architectures must implement all the features all over again, and sometimes in subtley different ways. This places an unfair burden on getting a new architecture fully functional and running with U-Boot.

5. While it is a bit of a tricky change, I believe it is worthwhile and achievable. There is no requirement that all code be common, only that the code that is common should be located in common/board.c rather than arch/xxx/lib/board.c.

All the functions of board_init_f() and board_init_r() are broken into separate function calls so that they can easily be included or excluded for a particular architecture. It also makes it easier to adopt Graeme's initcall proposal when it is ready.

http://lists.denx.de/pipermail/u-boot/2012-January/114499.html

This series removes the dependency on generic relocation. So relocation happens as one big chunk and is still completely arch-specific. See the relocation series for a proposed solution to this for ARM:

http://lists.denx.de/pipermail/u-boot/2011-December/112928.html

or Graeme's recent x86 series v2:

http://lists.denx.de/pipermail/u-boot/2012-January/114467.html

Instead of moving over a whole architecture, this series takes the approach of simply enabling generic board support for an architecture. It is then up to each board to opt in by defining CONFIG_SYS_GENERIC_BOARD in the board config file. If this is not done, then the code will be generated as before. This allows both sets of code to co-exist until we are comfortable with the generic approach, and enough boards run.

ARM is a relatively large board.c file and one which I can test, therefore I think it is a good target for this series. On the other hand, x86 is relatively small and simple, but different enough that it introduces a few issues to be solved. So I have chosen both ARM and x86 for this series. After a suggestion from Wolfgang I have added PPC also. This is the largest and most feature-full board, so hopefully we have all bases covered in this RFC.

A generic global_data structure is also required. This might upset a few people. Here is my basic reasoning: most fields are the same, all architectures include and need it, most global_data.h files already have
#ifdefs to select fields for a particular SOC, so it is hard to
see why architecures are different in this area. We can perhaps add a way to put architecture-specific fields into a separate header file, but for now I have judged that to be counter-productive.

Similarly we need a generic bd_info structure, since generic code will be accessing it. I have done this in the same way as global_data and the same comments apply.

There was dicussion on the list about passing gd_t around as a parameter to pre-relocation init functions. I think this makes sense, but it can be done as a separate change, and this series does not require it.

While this series needs to stand on its own (as with the link script cleanup series and the generic relocation series) the goal is the unification of the board init code. So I hope we can address issues with this in mind, rather than focusing too narrowly on particular ARM, x86 or PPC issues.

I have run-tested ARM on Tegra Seaboard only. To try it out, define CONFIG_SYS_GENERIC_BOARD in your board file and rebuild. Most likely on x86 and PPC at least it will hang, but if you are lucky it will print something first :-)

I have run this though MAKEALL with CONFIG_SYS_GENERIC_BOARD on for all ARM, PPC and x86 boards. There are a few failures due to errors in the board config, which I have sent patches for. The main issue is just the difference between __bss_end and __bss_end__.

Note: the first group of commits are required for this series to build, but could be separated out if required. I have included them here for convenience.

Comments welcome.

Changes in v2:
- Add CONFIG_SYS_GENERIC_BOARD to allow board to select generic board
- Add PowerPC support
- Change generic board to an opt-in system on a per-board basic
- Rebase to master

Changes in v3:
- Add header to new x86 relocate.c and init_helpers.c
- Cast away the volatile on gd for memcpy()
- Rebase on top of x86/master (which has not yet been pulled to master)
- Rebase to master

Changes in v4:
- Add asm/sections.h for each architecture
- Add three more fields required for ARM
- Drop sc520_timer.c patch (warning already fixed by previous patch)
- Rebase to master
- Updates to sit on top of earlier patches
- Use asm/sections.h instead of asm-generic/sections.h

Simon Glass (27):
arm: Change board baud_rate to ulong
x86: Change board baud_rate to ulong
arm: Only display frame buffer info if there is LCD/video support
x86: Remove dead code in eNET
x86: Add initial memory barrier macros
ppc: Add initial memory barrier macros
Introduce generic global_data
Introduce generic u-boot.h file
Introduce generic link section.h symbol files
arm: Use sections header to obtain link symbols
x86: Change stub example to use asm-generic/sections.h Introduce a basic initcall implementation
Define CONFIG_SYS_LEGACY_BOARD everywhere
Introduce generic pre-relocation board_f.c
Introduce generic post-relocation board_r.c
Add spl load feature
arm: Enable generic board support
Add CONFIG_SYS_SYM_OFFSETS to support offset symbols
x86: Use sections header to obtain link symbols
Add x86 fields to generic global_data
x86: Enable generic board support
Add ppc fields to generic global data
Adjust board_f for ppc
Adjust board_r.c for PowerPC
ppc: Enable generic board board
tegra: Mark board init files for ARMv4t
tegra: Enable generic board for Seaboard.

 README                                 |   17 +
 arch/arm/cpu/armv7/tegra2/config.mk    |    2 +
 arch/arm/include/asm/global_data.h     |    7 +
 arch/arm/include/asm/sections.h        |   27 +
 arch/arm/include/asm/u-boot-arm.h      |    4 -
 arch/arm/include/asm/u-boot.h          |   11 +-
 arch/arm/lib/Makefile                  |    4 +-
 arch/arm/lib/board.c                   |    1 +
 arch/avr32/config.mk                   |    3 +
 arch/avr32/cpu/start.S                 |    2 +-
 arch/avr32/cpu/u-boot.lds              |    2 +-
 arch/avr32/include/asm/sections.h      |    6 +-
 arch/avr32/lib/board.c                 |    2 +-
 arch/blackfin/config.mk                |    3 +
 arch/blackfin/include/asm/sections.h   |   27 +
 arch/m68k/config.mk                    |    3 +
 arch/m68k/include/asm/sections.h       |   27 +
 arch/microblaze/config.mk              |    3 +
 arch/microblaze/include/asm/sections.h |   27 +
 arch/mips/config.mk                    |    3 +
 arch/mips/include/asm/sections.h       |   27 +
 arch/nds32/config.mk                   |    3 +
 arch/nds32/include/asm/sections.h      |   27 +
 arch/nios2/config.mk                   |    3 +
 arch/nios2/include/asm/sections.h      |   27 +
 arch/openrisc/include/asm/sections.h   |   27 +
 arch/powerpc/include/asm/global_data.h |    7 +
 arch/powerpc/include/asm/io.h          |    8 +
 arch/powerpc/include/asm/sections.h    |   27 +
 arch/powerpc/include/asm/u-boot.h      |    7 +
 arch/powerpc/lib/Makefile              |    4 +-
 arch/sandbox/config.mk                 |    3 +
 arch/sandbox/include/asm/sections.h    |   27 +
 arch/sh/config.mk                      |    3 +
 arch/sh/include/asm/sections.h         |   27 +
 arch/sparc/config.mk                   |    3 +
 arch/sparc/include/asm/sections.h      |   27 +
 arch/x86/include/asm/global_data.h     |    7 +
 arch/x86/include/asm/io.h              |    8 +
 arch/x86/include/asm/sections.h        |   27 +
 arch/x86/include/asm/u-boot-x86.h      |    8 -
 arch/x86/include/asm/u-boot.h          |   13 +-
 arch/x86/lib/Makefile                  |    4 +-
 arch/x86/lib/board.c                   |    1 +
 arch/x86/lib/init_helpers.c            |    1 +
 arch/x86/lib/relocate.c                |    1 +
 board/cm4008/flash.c                   |    1 +
 board/cm41xx/flash.c                   |    1 +
 board/eNET/eNET.c                      |    5 -
 common/Makefile                        |    4 +
 common/board_f.c                       |  888 ++++++++++++++++++++++++++++++++
 common/board_r.c                       |  862 +++++++++++++++++++++++++++++++
 common/cmd_bdinfo.c                    |    6 +-
 config.mk                              |    8 +
 examples/standalone/stubs.c            |    7 +-
 include/asm-generic/global_data.h      |  241 +++++++++
 include/asm-generic/sections.h         |  124 +++++
 include/asm-generic/u-boot.h           |  160 ++++++
 include/common.h                       |   16 +
 include/configs/seaboard.h             |    2 +
 include/initcall.h                     |   25 +
 lib/Makefile                           |    1 +
 lib/initcall.c                         |   41 ++
 63 files changed, 2866 insertions(+), 34 deletions(-)
 create mode 100644 arch/arm/include/asm/sections.h
 create mode 100644 arch/blackfin/include/asm/sections.h
 create mode 100644 arch/m68k/include/asm/sections.h
 create mode 100644 arch/microblaze/include/asm/sections.h
 create mode 100644 arch/mips/include/asm/sections.h
 create mode 100644 arch/nds32/include/asm/sections.h
 create mode 100644 arch/nios2/include/asm/sections.h
 create mode 100644 arch/openrisc/include/asm/sections.h
 create mode 100644 arch/powerpc/include/asm/sections.h
 create mode 100644 arch/sandbox/include/asm/sections.h
 create mode 100644 arch/sh/include/asm/sections.h
 create mode 100644 arch/sparc/include/asm/sections.h
 create mode 100644 arch/x86/include/asm/sections.h
 create mode 100644 common/board_f.c
 create mode 100644 common/board_r.c
 create mode 100644 include/asm-generic/global_data.h
 create mode 100644 include/asm-generic/sections.h
 create mode 100644 include/asm-generic/u-boot.h
 create mode 100644 include/initcall.h
 create mode 100644 lib/initcall.c
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH v4 1/27 arm: Change board baud_rate to ulong

This is a ulong for some architectures and just unsigned for others. Change ARM to be consistent.

---

 arch/arm/include/asm/u-boot.h |    2 +-
 common/cmd_bdinfo.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/u-boot.h +1 -1
index 20e1653..a0691b7 100644
@@ -37,7 +37,7 @@
 #define _U_BOOT_H_	1
 
 typedef struct bd_info {
-    int			bi_baudrate;	/* serial console baudrate */
+	unsigned long	bi_baudrate;	/* serial console baudrate */
     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 */
common/cmd_bdinfo.c +1 -1
index 5359a47..c034ec9 100644
@@ -361,7 +361,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	print_eth(0);
 	printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
 #endif
-	printf("baudrate    = %d bps\n", bd->bi_baudrate);
+	printf("baudrate    = %ld bps\n", bd->bi_baudrate);
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 	print_num("TLB addr", gd->tlb_addr);
 #endif
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH v4 2/27 x86: Change board baud_rate to ulong

In reply to Simon Glass

This is a ulong for some architectures and just unsigned for others. Change x86 to be consistent.

---

 arch/x86/include/asm/u-boot.h |    2 +-
 common/cmd_bdinfo.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/u-boot.h +1 -1
index 26450eb..dd42209 100644
@@ -49,7 +49,7 @@ typedef struct bd_info {
 	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
 	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
 	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
-	unsigned int	bi_baudrate;	/* Console Baudrate */
+	unsigned long	bi_baudrate;	/* Console Baudrate */
 	unsigned long   bi_boot_params;	/* where this board expects params */
 	struct				/* RAM configuration */
 	{
common/cmd_bdinfo.c +1 -1
index c034ec9..54a56f4 100644
@@ -431,7 +431,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf("ip_addr     = %pI4\n", &bd->bi_ip_addr);
 	print_mhz("ethspeed",	    bd->bi_ethspeed);
 #endif
-	printf("baudrate    = %d bps\n", bd->bi_baudrate);
+	printf("baudrate    = %ld bps\n", bd->bi_baudrate);
 
 	return 0;
 }
Signature · 1 line
1.7.7.3
#3 lore raw

PATCH v4 3/27 arm: Only display frame buffer info if there is LCD/video support

In reply to Simon Glass

This value has no meaning otherwise.

---

 common/cmd_bdinfo.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
common/cmd_bdinfo.c +2 -0
index 54a56f4..80c100c 100644
@@ -369,7 +369,9 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	print_num("reloc off", gd->reloc_off);
 	print_num("irq_sp", gd->irq_sp);	/* irq stack pointer */
 	print_num("sp start ", gd->start_addr_sp);
+#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	print_num("FB base  ", gd->fb_base);
+#endif
 	/*
 	 * TODO: Currently only support for davinci SOC's is added.
 	 * Remove this check once all the board implement this.
Signature · 1 line
1.7.7.3
#4 lore raw

PATCH v4 4/27 x86: Remove dead code in eNET

In reply to Simon Glass

This avoids a compiler warning about unused variables.

---

 board/eNET/eNET.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
board/eNET/eNET.c +0 -5
index 429fe1b..2f26470 100644
@@ -178,11 +178,6 @@ void show_boot_progress(int val)
 
 int last_stage_init(void)
 {
-	int minor;
-	int major;
-
-	major = minor = 0;
-
 	outb(0x00, LED_LATCH_ADDRESS);
 
 	register_timer_isr(enet_timer_isr);
Signature · 1 line
1.7.7.3
#7 lore raw

PATCH v4 5/27 x86: Add initial memory barrier macros

In reply to Simon Glass

These are available on other architectures, so add them on x86.

---

 arch/x86/include/asm/io.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/x86/include/asm/io.h +8 -0
index 9b757d4..b12bdd8 100644
@@ -234,4 +234,12 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 	return (phys_addr_t)(vaddr);
 }
 
+/*
+ * TODO: The kernel offers some more advanced versions of barriers, it might
+ * have some advantages to use them instead of the simple one here.
+ */
+#define dmb()		__asm__ __volatile__ ("" : : : "memory")
+#define __iormb()	dmb()
+#define __iowmb()	dmb()
+
 #endif
Signature · 1 line
1.7.7.3
#8 lore raw

PATCH v4 6/27 ppc: Add initial memory barrier macros

In reply to Simon Glass

These are available on other architectures, so add them on ppc.

---

 arch/powerpc/include/asm/io.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/io.h +8 -0
index 56ac9fe..d246fd8 100644
@@ -318,4 +318,12 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 #endif
 }
 
+/*
+ * TODO: The kernel offers some more advanced versions of barriers, it might
+ * have some advantages to use them instead of the simple one here.
+ */
+#define dmb()		__asm__ __volatile__ ("" : : : "memory")
+#define __iormb()	dmb()
+#define __iowmb()	dmb()
+
 #endif
Signature · 1 line
1.7.7.3
#10 lore raw

PATCH v4 7/27 Introduce generic global_data

In reply to Simon Glass

We want to unify the global_data structure. Most fields are common across architectures, but there are a fair number of SOC-specific additions. It isn't clear how best to deal with these, but for now we just use #ifdef.

Checkpatch warnings here might be unavoidable:

warning: include/asm-generic/global_data.h,43: do not add new typedefs
warning: include/asm-generic/global_data.h,117: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: include/asm-generic/global_data.h,121: storage class should be at the beginning of the declaration

---

 include/asm-generic/global_data.h |  115 +++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/global_data.h
include/asm-generic/global_data.h new file +115 -0
new file mode 100644
index 0000000..6199926
@@ -0,0 +1,115 @@
+/*
+ * (C) Copyright 2002-2010
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef	__ASM_GENERIC_GBL_DATA_H
+#define __ASM_GENERIC_GBL_DATA_H
+/*
+ * The following data structure is placed in some memory which is
+ * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
+ * some locked parts of the data cache) to allow for a minimum set of
+ * global variables during system initialization (until we have set
+ * up the memory controller so that we can use RAM).
+ *
+ * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
+ *
+ * sjg at chromium.org: Well it would be nice to have a generic one of these
+ * since so many fields are similar. But it means that everyone architecture
+ * will want to add its own nutty fields. Perhaps that is no bad thing since
+ * it shows up inconsistences and might produce downward pressure on the
+ * number of fields.
+ */
+
+#ifndef __ASSEMBLY__
+typedef struct global_data {
+	bd_t		*bd;
+	unsigned long	flags;
+	unsigned long	baudrate;
+#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
+	unsigned long	fb_base;	/* Base address of framebuffer mem */
+#endif
+#if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
+	unsigned long	post_log_word;  /* Record POST activities */
+	unsigned long	post_log_res; /* success of POST test */
+	unsigned long	post_init_f_time;  /* When post_init_f started */
+#endif
+	unsigned long	have_console;	/* serial_init() was called */
+#ifdef CONFIG_PRE_CONSOLE_BUFFER
+	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
+#endif
+	unsigned long	env_addr;	/* Address  of Environment struct */
+	unsigned long	env_valid;	/* Checksum of Environment valid? */
+	/* Here begins ARM-specific things. Needs discussion */
+#ifdef CONFIG_AT91FAMILY
+	/* "static data" needed by at91's clock.c */
+	unsigned long	cpu_clk_rate_hz;
+	unsigned long	main_clk_rate_hz;
+	unsigned long	mck_rate_hz;
+	unsigned long	plla_rate_hz;
+	unsigned long	pllb_rate_hz;
+	unsigned long	at91_pllb_usb_init;
+#endif
+#ifdef CONFIG_ARM
+	/* "static data" needed by most of timer.c on ARM platforms */
+	unsigned long	timer_rate_hz;
+	unsigned long	tbl;
+	unsigned long	tbu;
+	unsigned long long	timer_reset_value;
+	unsigned long	lastinc;
+#endif
+#ifdef CONFIG_IXP425
+	unsigned long	timestamp;
+#endif
+	/* TODO: is this the same as relocaddr, or something else? */
+	unsigned long	dest_addr;	/* Post-relocation address of U-Boot */
+	unsigned long	dest_addr_sp;
+	unsigned long	ram_top;	/* Top address of RAM used by U-Boot */
+
+	unsigned long	relocaddr;	/* Start address of U-Boot in RAM */
+	phys_size_t	ram_size;	/* RAM size */
+	unsigned long	mon_len;	/* monitor len */
+	unsigned long	irq_sp;		/* irq stack pointer */
+	unsigned long	start_addr_sp;	/* start_addr_stackpointer */
+	unsigned long	reloc_off;
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
+	unsigned long	tlb_addr;
+#endif
+	struct global_data *new_gd;	/* relocated global data */
+	const void	*fdt_blob;	/* Our device tree, NULL if none */
+	void		**jt;		/* jump table */
+	char		env_buf[32];	/* buffer for getenv() before reloc. */
+} gd_t;
+#endif
+
+/*
+ * Global Data Flags
+ */
+#define	GD_FLG_RELOC		0x00001	/* Code was relocated to RAM	   */
+#define	GD_FLG_DEVINIT		0x00002	/* Devices have been initialized   */
+#define	GD_FLG_SILENT		0x00004	/* Silent mode			   */
+#define	GD_FLG_POSTFAIL		0x00008	/* Critical POST test failed	   */
+#define	GD_FLG_POSTSTOP		0x00010	/* POST seqeunce aborted	   */
+#define	GD_FLG_LOGINIT		0x00020	/* Log Buffer has been initialized */
+#define GD_FLG_DISABLE_CONSOLE	0x00040	/* Disable console (in & out)	   */
+#define GD_FLG_ENV_READY	0x00080	/* Env. imported into hash table   */
+
+#endif /* __ASM_GENERIC_GBL_DATA_H */
Signature · 1 line
1.7.7.3
#20 lore raw

PATCH v4 8/27 Introduce generic u-boot.h file

In reply to Simon Glass

This file holds the board info structure. We need this to be generic for the unified board series, so create a structure which contains the basic fields required by the main architectures.

---
Changes in v4:
- Add three more fields required for ARM

 include/asm-generic/u-boot.h |  160 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 160 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/u-boot.h
include/asm-generic/u-boot.h new file +160 -0
new file mode 100644
index 0000000..8a684fb
@@ -0,0 +1,160 @@
+/*
+ * (C) Copyright 2000 - 2002
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ********************************************************************
+ * NOTE: This header file defines an interface to U-Boot. Including
+ * this (unmodified) header file in another file is considered normal
+ * use of U-Boot, and does *not* fall under the heading of "derived
+ * work".
+ ********************************************************************
+ */
+
+#ifndef __ASM_GENERIC_U_BOOT_H__
+#define __ASM_GENERIC_U_BOOT_H__
+
+/*
+ * Board information passed to Linux kernel from U-Boot
+ *
+ * include/asm-ppc/u-boot.h
+ */
+
+#ifndef __ASSEMBLY__
+
+typedef struct bd_info {
+	unsigned long	bi_memstart;	/* start of DRAM memory */
+	phys_size_t	bi_memsize;	/* size	 of DRAM memory in bytes */
+	unsigned long	bi_flashstart;	/* start of FLASH memory */
+	unsigned long	bi_flashsize;	/* size	 of FLASH memory */
+	unsigned long	bi_flashoffset; /* reserved area for startup monitor */
+	unsigned long	bi_sramstart;	/* start of SRAM memory */
+	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
+#ifdef CONFIG_ARM
+	unsigned long	bi_arm_freq; /* arm frequency */
+	unsigned long	bi_dsp_freq; /* dsp core frequency */
+	unsigned long	bi_ddr_freq; /* ddr frequency */
+#endif
+#if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) \
+	|| defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
+	unsigned long	bi_immr_base;	/* base of IMMR register */
+#endif
+#if defined(CONFIG_MPC5xxx)
+	unsigned long	bi_mbar_base;	/* base of internal registers */
+#endif
+#if defined(CONFIG_MPC83xx)
+	unsigned long	bi_immrbar;
+#endif
+#if defined(CONFIG_MPC8220)
+	unsigned long	bi_mbar_base;	/* base of internal registers */
+	unsigned long   bi_inpfreq;     /* Input Freq, In MHz */
+	unsigned long   bi_pcifreq;     /* PCI Freq, in MHz */
+	unsigned long   bi_pevfreq;     /* PEV Freq, in MHz */
+	unsigned long   bi_flbfreq;     /* Flexbus Freq, in MHz */
+	unsigned long   bi_vcofreq;     /* VCO Freq, in MHz */
+#endif
+	unsigned long	bi_bootflags;	/* boot / reboot flag (Unused) */
+	unsigned long	bi_ip_addr;	/* IP Address */
+	unsigned char	bi_enetaddr[6];	/* OLD: see README.enetaddr */
+	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
+	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
+	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
+#if defined(CONFIG_CPM2)
+	unsigned long	bi_cpmfreq;	/* CPM_CLK Freq, in MHz */
+	unsigned long	bi_brgfreq;	/* BRG_CLK Freq, in MHz */
+	unsigned long	bi_sccfreq;	/* SCC_CLK Freq, in MHz */
+	unsigned long	bi_vco;		/* VCO Out from PLL, in MHz */
+#endif
+#if defined(CONFIG_MPC512X)
+	unsigned long	bi_ipsfreq;	/* IPS Bus Freq, in MHz */
+#endif /* CONFIG_MPC512X */
+#if defined(CONFIG_MPC5xxx)
+	unsigned long	bi_ipbfreq;	/* IPB Bus Freq, in MHz */
+	unsigned long	bi_pcifreq;	/* PCI Bus Freq, in MHz */
+#endif
+	unsigned long	bi_baudrate;	/* Console Baudrate */
+#if defined(CONFIG_405)   || \
+		defined(CONFIG_405GP) || \
+		defined(CONFIG_405CR) || \
+		defined(CONFIG_405EP) || \
+		defined(CONFIG_405EZ) || \
+		defined(CONFIG_405EX) || \
+		defined(CONFIG_440)
+	unsigned char	bi_s_version[4];	/* Version of this structure */
+	unsigned char	bi_r_version[32];	/* Version of the ROM (AMCC) */
+	unsigned int	bi_procfreq;	/* CPU (Internal) Freq, in Hz */
+	unsigned int	bi_plb_busfreq;	/* PLB Bus speed, in Hz */
+	unsigned int	bi_pci_busfreq;	/* PCI Bus speed, in Hz */
+	unsigned char	bi_pci_enetaddr[6];	/* PCI Ethernet MAC address */
+#endif
+#if defined(CONFIG_HYMOD)
+	hymod_conf_t	bi_hymod_conf;	/* hymod configuration information */
+#endif
+
+#ifdef CONFIG_HAS_ETH1
+	unsigned char   bi_enet1addr[6];	/* OLD: see README.enetaddr */
+#endif
+#ifdef CONFIG_HAS_ETH2
+	unsigned char	bi_enet2addr[6];	/* OLD: see README.enetaddr */
+#endif
+#ifdef CONFIG_HAS_ETH3
+	unsigned char   bi_enet3addr[6];	/* OLD: see README.enetaddr */
+#endif
+#ifdef CONFIG_HAS_ETH4
+	unsigned char   bi_enet4addr[6];	/* OLD: see README.enetaddr */
+#endif
+#ifdef CONFIG_HAS_ETH5
+	unsigned char   bi_enet5addr[6];	/* OLD: see README.enetaddr */
+#endif
+
+#if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
+		defined(CONFIG_405EZ) || defined(CONFIG_440GX) || \
+		defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+		defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
+		defined(CONFIG_460EX) || defined(CONFIG_460GT)
+	unsigned int	bi_opbfreq;		/* OPB clock in Hz */
+	int		bi_iic_fast[2];		/* Use fast i2c mode */
+#endif
+#if defined(CONFIG_NX823)
+	unsigned char	bi_sernum[8];
+#endif
+#if defined(CONFIG_4xx)
+#if defined(CONFIG_440GX) || \
+		defined(CONFIG_460EX) || defined(CONFIG_460GT)
+	int		bi_phynum[4];           /* Determines phy mapping */
+	int		bi_phymode[4];          /* Determines phy mode */
+#elif defined(CONFIG_405EP) || defined(CONFIG_405EX) || defined(CONFIG_440)
+	int		bi_phynum[2];           /* Determines phy mapping */
+	int		bi_phymode[2];          /* Determines phy mode */
+#else
+	int		bi_phynum[1];           /* Determines phy mapping */
+	int		bi_phymode[1];          /* Determines phy mode */
+#endif
+#endif /* defined(CONFIG_4xx) */
+	ulong	        bi_arch_number;	/* unique id for this board */
+	ulong	        bi_boot_params;	/* where this board expects params */
+#ifdef CONFIG_NR_DRAM_BANKS
+	struct {			/* RAM configuration */
+		ulong start;
+		ulong size;
+	} bi_dram[CONFIG_NR_DRAM_BANKS];
+#endif /* CONFIG_NR_DRAM_BANKS */
+} bd_t;
+
+#endif /* __ASSEMBLY__ */
+
+#endif	/* __ASM_GENERIC_U_BOOT_H__ */
Signature · 1 line
1.7.7.3
#21 lore raw

PATCH v4 9/27 Introduce generic link section.h symbol files

In reply to Simon Glass

We create a separate header file for link symbols defined by the link scripts. It is helpful to have these all in one place and try to make them common across architectures. Since Linux already has a similar file, we bring this in even though many of the symbols there are not relevant to us.

Each architecture has its own asm/sections.h where symbols specifc to that architecture can be added. For now everything except AVR32 just includes the generic header.

One change is needed in arch/avr32/lib/board.c to make this conversion work.

---
Changes in v4:
- Add asm/sections.h for each architecture

 arch/arm/include/asm/sections.h        |   27 +++++++
 arch/avr32/include/asm/sections.h      |    6 +-
 arch/avr32/lib/board.c                 |    2 +-
 arch/blackfin/include/asm/sections.h   |   27 +++++++
 arch/m68k/include/asm/sections.h       |   27 +++++++
 arch/microblaze/include/asm/sections.h |   27 +++++++
 arch/mips/include/asm/sections.h       |   27 +++++++
 arch/nds32/include/asm/sections.h      |   27 +++++++
 arch/nios2/include/asm/sections.h      |   27 +++++++
 arch/openrisc/include/asm/sections.h   |   27 +++++++
 arch/powerpc/include/asm/sections.h    |   27 +++++++
 arch/sandbox/include/asm/sections.h    |   27 +++++++
 arch/sh/include/asm/sections.h         |   27 +++++++
 arch/sparc/include/asm/sections.h      |   27 +++++++
 arch/x86/include/asm/sections.h        |   27 +++++++
 include/asm-generic/sections.h         |  124 ++++++++++++++++++++++++++++++++
 16 files changed, 479 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/include/asm/sections.h
 create mode 100644 arch/blackfin/include/asm/sections.h
 create mode 100644 arch/m68k/include/asm/sections.h
 create mode 100644 arch/microblaze/include/asm/sections.h
 create mode 100644 arch/mips/include/asm/sections.h
 create mode 100644 arch/nds32/include/asm/sections.h
 create mode 100644 arch/nios2/include/asm/sections.h
 create mode 100644 arch/openrisc/include/asm/sections.h
 create mode 100644 arch/powerpc/include/asm/sections.h
 create mode 100644 arch/sandbox/include/asm/sections.h
 create mode 100644 arch/sh/include/asm/sections.h
 create mode 100644 arch/sparc/include/asm/sections.h
 create mode 100644 arch/x86/include/asm/sections.h
 create mode 100644 include/asm-generic/sections.h
arch/arm/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..c042cb6
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_ARM_SECTIONS_H
+#define __ASM_ARM_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/avr32/include/asm/sections.h +3 -3
index 3f15788..056d7a0 100644
@@ -22,11 +22,11 @@
 #ifndef __ASM_AVR32_SECTIONS_H
 #define __ASM_AVR32_SECTIONS_H
 
+#include <asm-generic/sections.h>
+
 /* References to section boundaries */
 
-extern char _text[], _etext[];
-extern char _data[], __data_lma[], _edata[], __edata_lma[];
+extern char __data_lma[], __edata_lma[];
 extern char __got_start[], __got_lma[], __got_end[];
-extern char __bss_end__[];
 
 #endif /* __ASM_AVR32_SECTIONS_H */
arch/avr32/lib/board.c +1 -1
index 63fe297..de1b127 100644
@@ -176,7 +176,7 @@ void board_init_f(ulong board_type)
 	 *  - stack
 	 */
 	addr = CONFIG_SYS_SDRAM_BASE + sdram_size;
-	monitor_len = __bss_end__ - _text;
+	monitor_len = (char *)__bss_end__ - _text;
 
 	/*
 	 * Reserve memory for u-boot code, data and bss.
arch/blackfin/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..85af42c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_BLACKFIN_SECTIONS_H
+#define __ASM_BLACKFIN_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/m68k/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..9228987
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_M68K_SECTIONS_H
+#define __ASM_M68K_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/microblaze/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..156c149
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_MICROBLAZE_SECTIONS_H
+#define __ASM_MICROBLAZE_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/mips/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..54cd8b3
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_MIPS_SECTIONS_H
+#define __ASM_MIPS_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/nds32/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..a65735e
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_NDS32_SECTIONS_H
+#define __ASM_NDS32_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/nios2/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..d813563
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_NIOS2_SECTIONS_H
+#define __ASM_NIOS2_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/openrisc/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..6eb5a66
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_OPENRISC_SECTIONS_H
+#define __ASM_OPENRISC_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/powerpc/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..0a94102
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_POWERPC_SECTIONS_H
+#define __ASM_POWERPC_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/sandbox/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..db1fabb
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SANDBOX_SECTIONS_H
+#define __ASM_SANDBOX_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/sh/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..8824560
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SH_SECTIONS_H
+#define __ASM_SH_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/sparc/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..90f7fa7
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_SPARC_SECTIONS_H
+#define __ASM_SPARC_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
arch/x86/include/asm/sections.h new file +27 -0
new file mode 100644
index 0000000..602df86
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_X86_SECTIONS_H
+#define __ASM_X86_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+#endif
include/asm-generic/sections.h new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#22 lore raw

PATCH v4 10/27 arm: Use sections header to obtain link symbols

In reply to Simon Glass

Include this header to get access to link symbols, which are otherwise removed.

---
Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

 arch/arm/include/asm/u-boot-arm.h |    4 ----
 arch/arm/lib/board.c              |    1 +
 arch/avr32/cpu/start.S            |    2 +-
 arch/avr32/cpu/u-boot.lds         |    2 +-
 board/cm4008/flash.c              |    1 +
 board/cm41xx/flash.c              |    1 +
 6 files changed, 5 insertions(+), 6 deletions(-)
arch/arm/include/asm/u-boot-arm.h +0 -4
index 4ca75f9..7cfae9b 100644
@@ -30,12 +30,8 @@
 #define _U_BOOT_ARM_H_	1
 
 /* for the following variables, see start.S */
-extern ulong _bss_start_ofs;	/* BSS start relative to _start */
-extern ulong _bss_end_ofs;		/* BSS end relative to _start */
-extern ulong _end_ofs;		/* end of image relative to _start */
 extern ulong IRQ_STACK_START;	/* top of IRQ stack */
 extern ulong FIQ_STACK_START;	/* top of FIQ stack */
-extern ulong _TEXT_BASE;	/* code start */
 extern ulong _datarel_start_ofs;
 extern ulong _datarelrolocal_start_ofs;
 extern ulong _datarellocal_start_ofs;
arch/arm/lib/board.c +1 -0
index 500e216..fdd5d15 100644
@@ -63,6 +63,7 @@
 #ifdef CONFIG_DRIVER_LAN91C96
 #include "../drivers/net/lan91c96.h"
 #endif
+#include <asm/sections.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
arch/avr32/cpu/start.S +1 -1
index 71cbc52..c8decea 100644
@@ -244,7 +244,7 @@ relocate_code:
 	/* zero out .bss */
 	mov	r0, 0
 	mov	r1, 0
-	lda.w	r9, __bss_end__
+	lda.w	r9, __bss_end
 	sub	r9, r8
 1:	st.d	r10++, r0
 	sub	r9, 8
arch/avr32/cpu/u-boot.lds +1 -1
index 0e532f2..4de2fff 100644
@@ -68,5 +68,5 @@ SECTIONS
 		*(.bss.*)
 	}
 	. = ALIGN(8);
-	__bss_end__ = .;
+	__bss_end = .;
 }
board/cm4008/flash.c +1 -0
index 5522bf0..0faf197 100644
@@ -29,6 +29,7 @@
 
 #include <common.h>
 #include <linux/byteorder/swab.h>
+#include <asm/sections.h>
 
 
 flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];	/* info for FLASH chips */
board/cm41xx/flash.c +1 -0
index 5522bf0..0faf197 100644
@@ -29,6 +29,7 @@
 
 #include <common.h>
 #include <linux/byteorder/swab.h>
+#include <asm/sections.h>
 
 
 flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];	/* info for FLASH chips */
Signature · 1 line
1.7.7.3
#23 lore raw

PATCH v4 11/27 x86: Change stub example to use asm-generic/sections.h

In reply to Simon Glass

We can use the declarations of __bss_start and _end from this header instead of declaring them locally.

---
Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

 examples/standalone/stubs.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
examples/standalone/stubs.c +3 -4
index 15e9afc..8fb1765 100644
@@ -217,16 +217,15 @@ void __attribute__((unused)) dummy(void)
 #include <_exports.h>
 }
 
-extern unsigned long __bss_start, _end;
+#include <asm/sections.h>
 
 void app_startup(char * const *argv)
 {
-	unsigned char * cp = (unsigned char *) &__bss_start;
+	char *cp = __bss_start;
 
 	/* Zero out BSS */
-	while (cp < (unsigned char *)&_end) {
+	while (cp < _end)
 		*cp++ = 0;
-	}
 
 #if defined(CONFIG_X86)
 	/* x86 does not have a dedicated register for passing global_data */
Signature · 1 line
1.7.7.3
#27 lore raw

PATCH v4 12/27 Introduce a basic initcall implementation

In reply to Simon Glass

This library supports calling a list of functions one after the other.

It is intended that we move to a more powerful initcall implementation as proposed by Graeme Russ <[email protected]>. For now, this allows us to do the basics.

---

 include/initcall.h |   25 +++++++++++++++++++++++++
 lib/Makefile       |    1 +
 lib/initcall.c     |   41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 include/initcall.h
 create mode 100644 lib/initcall.c
include/initcall.h new file +25 -0
new file mode 100644
index 0000000..9e54fa5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+typedef int (*init_fnc_t)(void);
+
+int initcall_run_list(init_fnc_t init_sequence[]);
lib/Makefile +1 -0
index e6e6ec6..f4d3325 100644
@@ -41,6 +41,7 @@ COBJS-y += display_options.o
 COBJS-y += errno.o
 COBJS-$(CONFIG_OF_CONTROL) += fdtdec.o
 COBJS-$(CONFIG_GZIP) += gunzip.o
+COBJS-y += initcall.o
 COBJS-y += hashtable.o
 COBJS-$(CONFIG_LMB) += lmb.o
 COBJS-y += ldiv.o
lib/initcall.c new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#28 lore raw

PATCH v4 13/27 Define CONFIG_SYS_LEGACY_BOARD everywhere

In reply to Simon Glass

We are introducing a new unified board setup and we want this to be the default. So we need to opt all architectures out first.

---

 README                    |   11 +++++++++++
 arch/arm/config.mk        |    3 +++
 arch/avr32/config.mk      |    3 +++
 arch/blackfin/config.mk   |    3 +++
 arch/m68k/config.mk       |    3 +++
 arch/microblaze/config.mk |    3 +++
 arch/mips/config.mk       |    3 +++
 arch/nds32/config.mk      |    3 +++
 arch/nios2/config.mk      |    3 +++
 arch/powerpc/config.mk    |    3 +++
 arch/sandbox/config.mk    |    3 +++
 arch/sh/config.mk         |    3 +++
 arch/sparc/config.mk      |    3 +++
 arch/x86/config.mk        |    3 +++
 config.mk                 |    8 ++++++++
 15 files changed, 58 insertions(+), 0 deletions(-)
README +11 -0
index 8964672..f471627 100644
@@ -2770,6 +2770,17 @@ Configuration Settings:
 	cases. This setting can be used to tune behaviour; see
 	lib/hashtable.c for details.
 
+- CONFIG_SYS_GENERIC_BOARD
+	This selects the architecture-generic board system instead of the
+	architecture-specific board files. It is intended to move boards
+	to this new framework over time. Defining this will disable the
+	arch/foo/lib/board.c file and use common/board_f.c and
+	common/board_r.c instead. To use this option your architecture
+	must support it (i.e. must NOT define CONFIG_SYS_LEGACY_BOARD in
+	its config.mk file). If you find problems enabling this option on
+	your board please report the problem and send patches!
+
+
 The following definitions that deal with the placement and management
 of environment data (variable area); in general, we support the
 following configurations:
arch/arm/config.mk +3 -0
index 45f9dca..31e9ef9 100644
@@ -33,6 +33,9 @@ endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
 PF_CPPFLAGS_ARM := $(call cc-option,-marm,)
 
arch/avr32/config.mk +3 -0
index d8e7ebb..6eb00f6 100644
@@ -31,3 +31,6 @@ PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
 LDFLAGS_u-boot		= --gc-sections --relax
 
 LDSCRIPT			= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/blackfin/config.mk +3 -0
index 3595aa2..972afb1 100644
@@ -37,6 +37,9 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
 PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
 PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 LDFLAGS_FINAL += --gc-sections
 LDFLAGS += -m elf32bfin
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
arch/m68k/config.mk +3 -0
index 11ba334..11ad9a5 100644
@@ -29,3 +29,6 @@ PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
 PLATFORM_LDFLAGS  += -n
 PLATFORM_RELFLAGS              += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL                  += --gc-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/microblaze/config.mk +3 -0
index abea70b..119a596 100644
@@ -29,3 +29,6 @@ CROSS_COMPILE ?= mb-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/mips/config.mk +3 -0
index 6ab8acd..8f5305e 100644
@@ -27,6 +27,9 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T mips.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 #
 # From Linux arch/mips/Makefile
 #
arch/nds32/config.mk +3 -0
index c589829..f989053 100644
@@ -33,3 +33,6 @@ PLATFORM_RELFLAGS	+= -gdwarf-2
 PLATFORM_CPPFLAGS	+= -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
 
 LDFLAGS_u-boot		= --gc-sections --relax
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/nios2/config.mk +3 -0
index 7b03ed8..0172f70 100644
@@ -31,3 +31,6 @@ PLATFORM_CPPFLAGS += -G0
 
 LDFLAGS_FINAL += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/powerpc/config.mk +3 -0
index a307154..e6203dd 100644
@@ -29,6 +29,9 @@ PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
 
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
+
 #
 # When cross-compiling on NetBSD, we have to define __PPC__ or else we
 # will pick up a va_list declaration that is incompatible with the
arch/sandbox/config.mk +3 -0
index 2ec1bb7..38c97d9 100644
@@ -19,3 +19,6 @@
 
 PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__
 PLATFORM_LIBS += -lrt
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/sh/config.mk +3 -0
index 07ff8b9..0c21ef5 100644
@@ -31,3 +31,6 @@ endif
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
 PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
 LDFLAGS_FINAL = --gc-sections
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/sparc/config.mk +3 -0
index cae7478..b98a173 100644
@@ -26,3 +26,6 @@ CROSS_COMPILE ?= sparc-elf-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) -T sparc.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
arch/x86/config.mk +3 -0
index 23cacff..7be3036 100644
@@ -48,3 +48,6 @@ NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
 
 export USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC))
+
+# Move to unified board system later
+CONFIG_SYS_LEGACY_BOARD := y
config.mk +8 -0
index ddaa477..a936f1f 100644
@@ -206,6 +206,14 @@ ifeq ($(CONFIG_SPL_BUILD),y)
 CPPFLAGS += -DCONFIG_SPL_BUILD
 endif
 
+# Does this architecture support generic board init?
+ifneq ($(CONFIG_SYS_LEGACY_BOARD),)
+ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
+$(error Your architecture does not support generic board. Please undefined \
+CONFIG_SYS_GENERIC_BOARD in your board config file)
+endif
+endif
+
 ifneq ($(RESET_VECTOR_ADDRESS),)
 CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
 endif
Signature · 1 line
1.7.7.3
#29 lore raw

PATCH v4 14/27 Introduce generic pre-relocation board_f.c

In reply to Simon Glass

This file handles common pre-relocation init for boards which use the generic framework.

It starts up the console, DRAM, performs relocation and then jumps to post-relocation init.

---
Changes in v3:
- Cast away the volatile on gd for memcpy()

Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

 common/Makefile  |    3 +
 common/board_f.c |  490 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 493 insertions(+), 0 deletions(-)
 create mode 100644 common/board_f.c
common/Makefile +3 -0
index 2a31c62..125c2a9 100644
@@ -36,6 +36,9 @@ COBJS-y += s_record.o
 COBJS-$(CONFIG_SERIAL_MULTI) += serial.o
 COBJS-y += xyzModem.o
 
+# boards
+COBJS-$(CONFIG_SYS_GENERIC_BOARD) += board_f.o
+
 # core command
 COBJS-y += cmd_boot.o
 COBJS-$(CONFIG_CMD_BOOTM) += cmd_bootm.o
common/board_f.c new file +490 -0

490 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#34 lore raw

PATCH v4 15/27 Introduce generic post-relocation board_r.c

In reply to Simon Glass

This file handles common post-relocation init for boards which use the generic framework.

---
Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

 common/Makefile  |    1 +
 common/board_r.c |  401 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 402 insertions(+), 0 deletions(-)
 create mode 100644 common/board_r.c
common/Makefile +1 -0
index 125c2a9..a10e5a9 100644
@@ -38,6 +38,7 @@ COBJS-y += xyzModem.o
 
 # boards
 COBJS-$(CONFIG_SYS_GENERIC_BOARD) += board_f.o
+COBJS-$(CONFIG_SYS_GENERIC_BOARD) += board_r.o
 
 # core command
 COBJS-y += cmd_boot.o
common/board_r.c new file +401 -0

401 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#35 lore raw

PATCH v4 16/27 Add spl load feature

In reply to Simon Glass

This adds secondary program loader support to the generic board.

---

 common/board_f.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
common/board_f.c +20 -0
index 9477721..a08f0a1 100644
@@ -305,6 +305,7 @@ static int reserve_uboot(void)
 	return 0;
 }
 
+#ifndef CONFIG_SPL_BUILD
 /* reserve memory for malloc() area */
 static int reserve_malloc(void)
 {
@@ -324,6 +325,7 @@ static int reserve_board(void)
 			sizeof(bd_t), gd->dest_addr_sp);
 	return 0;
 }
+#endif
 
 static int setup_machine(void)
 {
@@ -342,6 +344,7 @@ static int reserve_global_data(void)
 	return 0;
 }
 
+#ifndef CONFIG_SPL_BUILD
 static int reserve_stacks(void)
 {
 	/* setup stack pointer for exceptions */
@@ -359,6 +362,17 @@ static int reserve_stacks(void)
 
 	return 0;
 }
+#endif
+
+#ifdef CONFIG_SPL_BUILD
+static int reserve_stacks_spl(void)
+{
+	/* Why not -= ? */
+	gd->dest_addr_sp += 128;	/* leave 32 words for abort-stack */
+	gd->irq_sp = gd->dest_addr_sp;
+	return 0;
+}
+#endif
 
 static int display_new_sp(void)
 {
@@ -458,11 +472,17 @@ static init_fnc_t init_sequence_f[] = {
 	reserve_lcd,
 #endif
 	reserve_uboot,
+#ifndef CONFIG_SPL_BUILD
 	reserve_malloc,
 	reserve_board,
+#endif
 	setup_machine,
 	reserve_global_data,
+#ifdef CONFIG_SPL_BUILD
+	reserve_stacks_spl,
+#else
 	reserve_stacks,
+#endif
 	setup_baud_rate,
 	display_new_sp,
 	jump_to_copy,
Signature · 1 line
1.7.7.3
#37 lore raw

PATCH v4 17/27 arm: Enable generic board support

In reply to Simon Glass

This enables generic board support so that ARM boards can define CONFIG_SYS_GENERIC_BOARD.

---

 arch/arm/config.mk                 |    3 ---
 arch/arm/include/asm/global_data.h |    7 +++++++
 arch/arm/include/asm/u-boot.h      |    9 +++++++++
 arch/arm/lib/Makefile              |    4 +++-
 4 files changed, 19 insertions(+), 4 deletions(-)
arch/arm/config.mk +0 -3
index 31e9ef9..45f9dca 100644
@@ -33,9 +33,6 @@ endif
 
 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
 
-# Move to unified board system later
-CONFIG_SYS_LEGACY_BOARD := y
-
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
 PF_CPPFLAGS_ARM := $(call cc-option,-marm,)
 
arch/arm/include/asm/global_data.h +7 -0
index c3ff789..aced4fe 100644
@@ -23,6 +23,11 @@
 
 #ifndef	__ASM_GBL_DATA_H
 #define __ASM_GBL_DATA_H
+
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified global_data */
+#include <asm-generic/global_data.h>
+#else
 /*
  * The following data structure is placed in some memory which is
  * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
@@ -98,6 +103,8 @@ typedef	struct	global_data {
 #define GD_FLG_DISABLE_CONSOLE	0x00040	/* Disable console (in & out)		*/
 #define GD_FLG_ENV_READY	0x00080	/* Environment imported into hash table	*/
 
+#endif /* nCONFIG_SYS_GENERIC_BOARD */
+
 #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r8")
 
 #endif /* __ASM_GBL_DATA_H */
arch/arm/include/asm/u-boot.h +9 -0
index a0691b7..fe336b3 100644
@@ -36,6 +36,12 @@
 #ifndef _U_BOOT_H_
 #define _U_BOOT_H_	1
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified bd_info */
+#include <asm-generic/u-boot.h>
+#else
+
+#ifndef __ASSEMBLY__
 typedef struct bd_info {
 	unsigned long	bi_baudrate;	/* serial console baudrate */
     unsigned long	bi_ip_addr;	/* IP Address */
@@ -50,6 +56,9 @@ typedef struct bd_info {
 	ulong size;
     }			bi_dram[CONFIG_NR_DRAM_BANKS];
 } bd_t;
+#endif
+
+#endif /* nCONFIG_SYS_GENERIC_BOARD */
 
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_ARM
arch/arm/lib/Makefile +3 -1
index 300c8fa..11cfc00 100644
@@ -37,7 +37,9 @@ GLSOBJS	+= _umodsi3.o
 
 GLCOBJS	+= div0.o
 
-COBJS-y	+= board.o
+ifeq ($(CONFIG_SYS_GENERIC_BOARD),)
+COBJS-y += board.o
+endif
 COBJS-y	+= bootm.o
 COBJS-y	+= cache.o
 COBJS-y	+= cache-cp15.o
Signature · 1 line
1.7.7.3
#38 lore raw

PATCH v4 18/27 Add CONFIG_SYS_SYM_OFFSETS to support offset symbols

In reply to Simon Glass

Link symbols as created by the link script can either be absolute or relative to the text start. This option switches between the two options so that we can support both.

As we convert architectures over to generic board, we can see if this option is actually needed, or whether it is possible to unify this feature also.

---

 README           |    6 ++++++
 common/board_f.c |   11 +++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
README +6 -0
index f471627..251afaf 100644
@@ -2780,6 +2780,12 @@ Configuration Settings:
 	its config.mk file). If you find problems enabling this option on
 	your board please report the problem and send patches!
 
+- CONFIG_SYS_SYM_OFFSETS
+	This is set by architectures that use offsets for link symbols
+	instead of absolute values. So bss_start is obtained using an
+	offset _bss_start_ofs from CONFIG_SYS_TEXT_BASE, rather than
+	directly. You should not need to touch this setting.
+
 
 The following definitions that deal with the placement and management
 of environment data (variable area); in general, we support the
common/board_f.c +11 -0
index a08f0a1..2f14118 100644
@@ -108,8 +108,13 @@ static int display_text_info(void)
 {
 	ulong bss_start, bss_end;
 
+#ifdef CONFIG_SYS_SYM_OFFSETS
 	bss_start = _bss_start_ofs + _TEXT_BASE;
 	bss_end = _bss_end_ofs + _TEXT_BASE;
+#else
+	bss_start = (ulong)&__bss_start;
+	bss_end = (ulong)&__bss_end;
+#endif
 	debug("U-Boot code: %08X -> %08lX  BSS: -> %08lX\n",
 	      CONFIG_SYS_TEXT_BASE, bss_start, bss_end);
 
@@ -186,7 +191,11 @@ static int zero_global_data(void)
 
 static int setup_mon_len(void)
 {
+#ifdef CONFIG_SYS_SYM_OFFSETS
 	gd->mon_len = _bss_end_ofs;
+#else
+	gd->mon_len = (ulong)&__bss_end - (ulong)&__text_start;
+#endif
 	return 0;
 }
 
@@ -423,6 +432,7 @@ static int jump_to_copy(void)
 
 static init_fnc_t init_sequence_f[] = {
 	setup_global_data_ptr,
+	zero_global_data,
 	setup_fdt,
 	setup_mon_len,
 #if defined(CONFIG_ARCH_CPU_INIT)
@@ -457,6 +467,7 @@ static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_POST
 	init_post,
 #endif
+	setup_dram_config,
 	setup_reloc,
 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
 	reserve_logbuffer,
Signature · 1 line
1.7.7.3
#39 lore raw

PATCH v4 19/27 x86: Use sections header to obtain link symbols

In reply to Simon Glass

These are defined in asm-generic/sections.h, so remove them from architecture-specific files.

---
Changes in v3:
- Add header to new x86 relocate.c and init_helpers.c

Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

 arch/x86/include/asm/u-boot-x86.h |    8 --------
 arch/x86/lib/board.c              |    1 +
 arch/x86/lib/init_helpers.c       |    1 +
 arch/x86/lib/relocate.c           |    1 +
 4 files changed, 3 insertions(+), 8 deletions(-)
arch/x86/include/asm/u-boot-x86.h +0 -8
index 878a1ee..069cbbc 100644
@@ -24,14 +24,6 @@
 #ifndef _U_BOOT_I386_H_
 #define _U_BOOT_I386_H_	1
 
-/* Exports from the Linker Script */
-extern ulong __text_start;
-extern ulong __data_end;
-extern ulong __rel_dyn_start;
-extern ulong __rel_dyn_end;
-extern ulong __bss_start;
-extern ulong __bss_end;
-
 /* cpu/.../cpu.c */
 int x86_cpu_init_r(void);
 int cpu_init_r(void);
arch/x86/lib/board.c +1 -0
index 5f0b62c..5931153 100644
@@ -36,6 +36,7 @@
 #include <stdio_dev.h>
 #include <asm/u-boot-x86.h>
 #include <asm/relocate.h>
+#include <asm/sections.h>
 
 #include <asm/init_helpers.h>
 #include <asm/init_wrappers.h>
arch/x86/lib/init_helpers.c +1 -0
index 9f4dee0..633b72b 100644
@@ -31,6 +31,7 @@
 #include <status_led.h>
 #include <asm/processor.h>
 #include <asm/u-boot-x86.h>
+#include <asm/sections.h>
 
 #include <asm/init_helpers.h>
 
arch/x86/lib/relocate.c +1 -0
index 200baab..cd26636 100644
@@ -35,6 +35,7 @@
 #include <malloc.h>
 #include <asm/u-boot-x86.h>
 #include <asm/relocate.h>
+#include <asm/sections.h>
 #include <elf.h>
 
 int copy_uboot_to_ram(void)
Signature · 1 line
1.7.7.3
#40 lore raw

PATCH v4 20/27 Add x86 fields to generic global_data

In reply to Simon Glass

These fields are needed for x86.

---

 include/asm-generic/global_data.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/asm-generic/global_data.h +2 -0
index 6199926..fb976f9 100644
@@ -44,6 +44,8 @@ typedef struct global_data {
 	bd_t		*bd;
 	unsigned long	flags;
 	unsigned long	baudrate;
+	unsigned long	cpu_clk;	/* CPU clock in Hz!		*/
+	unsigned long	bus_clk;
 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	unsigned long	fb_base;	/* Base address of framebuffer mem */
 #endif
Signature · 1 line
1.7.7.3
#43 lore raw

PATCH v4 21/27 x86: Enable generic board support

In reply to Simon Glass

This enables generic board support so that x86 boards can define CONFIG_SYS_GENERIC_BOARD.

---

 arch/x86/config.mk                 |    3 ---
 arch/x86/include/asm/global_data.h |    7 +++++++
 arch/x86/include/asm/u-boot.h      |   11 +++++++++++
 arch/x86/lib/Makefile              |    4 +++-
 common/board_r.c                   |    5 +++++
 5 files changed, 26 insertions(+), 4 deletions(-)
arch/x86/config.mk +0 -3
index 7be3036..23cacff 100644
@@ -48,6 +48,3 @@ NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
 
 export USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC))
-
-# Move to unified board system later
-CONFIG_SYS_LEGACY_BOARD := y
arch/x86/include/asm/global_data.h +7 -0
index 908a02c..fe50856 100644
@@ -23,6 +23,11 @@
 
 #ifndef	__ASM_GBL_DATA_H
 #define __ASM_GBL_DATA_H
+
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified global_data */
+#include <asm-generic/global_data.h>
+#else
 /*
  * The following data structure is placed in some memory wich is
  * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
@@ -86,6 +91,8 @@ static inline gd_t *get_fs_gd_ptr(void)
 #define GD_FLG_DISABLE_CONSOLE	0x00040	/* Disable console (in & out)		*/
 #define GD_FLG_ENV_READY	0x00080	/* Environment imported into hash table	*/
 
+#endif /* nCONFIG_SYS_GENERIC_BOARD */
+
 #define DECLARE_GLOBAL_DATA_PTR
 
 #endif /* __ASM_GBL_DATA_H */
arch/x86/include/asm/u-boot.h +11 -0
index dd42209..ef8b7d5 100644
@@ -36,6 +36,13 @@
 #ifndef _U_BOOT_H_
 #define _U_BOOT_H_	1
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified bd_info */
+#include <asm-generic/u-boot.h>
+#else
+
+#ifndef __ASSEMBLY__
+
 typedef struct bd_info {
 	unsigned long	bi_memstart;	/* start of DRAM memory */
 	phys_size_t	bi_memsize;	/* size	 of DRAM memory in bytes */
@@ -58,6 +65,10 @@ typedef struct bd_info {
 	}bi_dram[CONFIG_NR_DRAM_BANKS];
 } bd_t;
 
+#endif /* __ASSEMBLY__ */
+
+#endif /* nCONFIG_SYS_GENERIC_BOARD */
+
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_I386
 
arch/x86/lib/Makefile +3 -1
index 51836da..a2083f4 100644
@@ -30,7 +30,9 @@ SOBJS-$(CONFIG_SYS_PCI_BIOS)	+= bios_pci.o
 SOBJS-$(CONFIG_SYS_X86_REALMODE)	+= realmode_switch.o
 
 COBJS-$(CONFIG_SYS_PC_BIOS)	+= bios_setup.o
-COBJS-y	+= board.o
+ifeq ($(CONFIG_SYS_GENERIC_BOARD),)
+COBJS-y += board.o
+endif
 COBJS-y	+= bootm.o
 COBJS-y	+= cmd_boot.o
 COBJS-y	+= gcc.o
common/board_r.c +5 -0
index 8b9adc2..f587c03 100644
@@ -56,12 +56,15 @@ static int initr_reloc(void)
  * Some of these functions are needed purely because the functions they
  * call return void. If we change them to return 0, these stubs can go away.
  */
+#ifdef CONFIG_ARM
 static int initr_caches(void)
 {
+	/* TODO: sort out x86 code here */
 	/* Enable caches */
 	enable_caches();
 	return 0;
 }
+#endif
 
 static int initr_reloc_global_data(void)
 {
@@ -232,11 +235,13 @@ static int initr_api(void)
 #endif
 
 /* enable exceptions */
+#ifdef CONFIG_ARM
 static int initr_enable_interrupts(void)
 {
 	enable_interrupts();
 	return 0;
 }
+#endif
 
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
Signature · 1 line
1.7.7.3
#44 lore raw

PATCH v4 22/27 Add ppc fields to generic global data

In reply to Simon Glass

This adds fields required by PowerPC to the global data.

---

 include/asm-generic/global_data.h |  124 +++++++++++++++++++++++++++++++++++++
 1 files changed, 124 insertions(+), 0 deletions(-)
include/asm-generic/global_data.h +124 -0
index fb976f9..fb2891e 100644
@@ -46,6 +46,114 @@ typedef struct global_data {
 	unsigned long	baudrate;
 	unsigned long	cpu_clk;	/* CPU clock in Hz!		*/
 	unsigned long	bus_clk;
+#if defined(CONFIG_8xx)
+	unsigned long	brg_clk;
+#endif
+#if defined(CONFIG_CPM2)
+	/* There are many clocks on the MPC8260 - see page 9-5 */
+	unsigned long	vco_out;
+	unsigned long	cpm_clk;
+	unsigned long	scc_clk;
+	unsigned long	brg_clk;
+#ifdef CONFIG_PCI
+	unsigned long	pci_clk;
+#endif
+#endif
+	unsigned long   mem_clk;
+#if defined(CONFIG_MPC83xx)
+	/* There are other clocks in the MPC83XX */
+	u32 csb_clk;
+#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
+	defined(CONFIG_MPC834x) || defined(CONFIG_MPC837x)
+	u32 tsec1_clk;
+	u32 tsec2_clk;
+	u32 usbdr_clk;
+#endif
+#if defined(CONFIG_MPC834x)
+	u32 usbmph_clk;
+#endif /* CONFIG_MPC834x */
+#if defined(CONFIG_MPC8315)
+	u32 tdm_clk;
+#endif
+	u32 core_clk;
+	u32 enc_clk;
+	u32 lbiu_clk;
+	u32 lclk_clk;
+	u32 pci_clk;
+#if defined(CONFIG_MPC8308) || defined(CONFIG_MPC831x) || \
+	defined(CONFIG_MPC837x)
+	u32 pciexp1_clk;
+	u32 pciexp2_clk;
+#endif
+#if defined(CONFIG_MPC837x) || defined(CONFIG_MPC8315)
+	u32 sata_clk;
+#endif
+#if defined(CONFIG_MPC8360)
+	u32  mem_sec_clk;
+#endif /* CONFIG_MPC8360 */
+#endif
+#if defined(CONFIG_FSL_ESDHC)
+	u32 sdhc_clk;
+#endif
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+	u32 lbc_clk;
+	void *cpu;
+#endif /* CONFIG_MPC85xx || CONFIG_MPC86xx */
+#if defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) \
+		|| defined(CONFIG_MPC86xx)
+	u32 i2c1_clk;
+	u32 i2c2_clk;
+#endif
+#if defined(CONFIG_QE)
+	u32 qe_clk;
+	u32 brg_clk;
+	uint mp_alloc_base;
+	uint mp_alloc_top;
+#endif /* CONFIG_QE */
+#if defined(CONFIG_FSL_LAW)
+	u32 used_laws;
+#endif
+#if defined(CONFIG_E500)
+	u32 used_tlb_cams[(CONFIG_SYS_NUM_TLBCAMS+31)/32];
+#endif
+#if defined(CONFIG_MPC5xxx)
+	unsigned long	ipb_clk;
+	unsigned long	pci_clk;
+#endif
+#if defined(CONFIG_MPC512X)
+	u32 ips_clk;
+	u32 csb_clk;
+	u32 pci_clk;
+#endif /* CONFIG_MPC512X */
+#if defined(CONFIG_MPC8220)
+	unsigned long   bExtUart;
+	unsigned long   inp_clk;
+	unsigned long   pci_clk;
+	unsigned long   vco_clk;
+	unsigned long   pev_clk;
+	unsigned long   flb_clk;
+#endif
+	unsigned long	reset_status;	/* reset status register at boot */
+#if defined(CONFIG_MPC83xx)
+	unsigned long	arbiter_event_attributes;
+	unsigned long	arbiter_event_address;
+#endif
+#if defined(CONFIG_SYS_ALLOC_DPRAM) || defined(CONFIG_CPM2)
+	unsigned int	dp_alloc_base;
+	unsigned int	dp_alloc_top;
+#endif
+#if defined(CONFIG_4xx)
+	u32  uart_clk;
+#endif /* CONFIG_4xx */
+#if defined(CONFIG_SYS_GT_6426x)
+	unsigned int	mirror_hack[16];
+#endif
+#if defined(CONFIG_A3000)	|| \
+		defined(CONFIG_HIDDEN_DRAGON)  || \
+		defined(CONFIG_MUSENKI)	||  \
+		defined(CONFIG_SANDPOINT)
+	void *console_addr;
+#endif
 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	unsigned long	fb_base;	/* Base address of framebuffer mem */
 #endif
@@ -54,6 +162,22 @@ typedef struct global_data {
 	unsigned long	post_log_res; /* success of POST test */
 	unsigned long	post_init_f_time;  /* When post_init_f started */
 #endif
+#ifdef CONFIG_BOARD_TYPES
+	unsigned long	board_type;
+#endif
+#ifdef CONFIG_MODEM_SUPPORT
+	unsigned long do_mdm_init;
+	unsigned long be_quiet;
+#endif
+#if defined(CONFIG_LWMON) || defined(CONFIG_LWMON5)
+	unsigned long kbd_status;
+#endif
+#ifdef CONFIG_SYS_FPGA_COUNT
+	unsigned fpga_state[CONFIG_SYS_FPGA_COUNT];
+#endif
+#if defined(CONFIG_WD_MAX_RATE)
+	unsigned long long wdt_last;	/* trace watch-dog triggering rate */
+#endif
 	unsigned long	have_console;	/* serial_init() was called */
 #ifdef CONFIG_PRE_CONSOLE_BUFFER
 	unsigned long	precon_buf_idx;	/* Pre-Console buffer index */
Signature · 1 line
1.7.7.3
#45 lore raw

PATCH v4 23/27 Adjust board_f for ppc

In reply to Simon Glass

This adds ppc features to the generic pre-relocation board init.

This is a separate commit so that these features are clearly shown.

---
Changes in v4:
- Updates to sit on top of earlier patches

 common/board_f.c |  373 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 include/common.h |   16 +++
 2 files changed, 386 insertions(+), 3 deletions(-)
common/board_f.c +370 -3
index 2f14118..bcbc809 100644
@@ -30,10 +30,31 @@
 #include <linux/compiler.h>
 #include <version.h>
 #include <environment.h>
+#if defined(CONFIG_CMD_IDE)
+#include <ide.h>
+#endif
+#include <i2c.h>
 #include <initcall.h>
 #include <logbuff.h>
+
+/* TODO: Can we move these into arch/ headers? */
+#ifdef CONFIG_8xx
+#include <mpc8xx.h>
+#endif
+#ifdef CONFIG_5xx
+#include <mpc5xx.h>
+#endif
+#ifdef CONFIG_MPC5xxx
+#include <mpc5xxx.h>
+#endif
+
 #include <post.h>
+#include <spi.h>
+#include <watchdog.h>
 #include <asm/io.h>
+#ifdef CONFIG_MP
+#include <asm/mp.h>
+#endif
 #include <asm/sections.h>
 
 /*
@@ -98,6 +119,34 @@ void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
  * Could the CONFIG_SPL_BUILD infection become a flag in gd?
  */
 
+#if defined(CONFIG_WATCHDOG)
+static int init_func_watchdog_init(void)
+{
+	puts("       Watchdog enabled\n");
+	WATCHDOG_RESET();
+	return 0;
+}
+
+#define INIT_FUNC_WATCHDOG_INIT	init_func_watchdog_init,
+
+int init_func_watchdog_reset(void)
+{
+	WATCHDOG_RESET();
+	return 0;
+}
+
+#else
+#define INIT_FUNC_WATCHDOG_INIT
+#endif /* CONFIG_WATCHDOG */
+
+void __board_add_ram_info(int use_default)
+{
+	/* please define platform specific board_add_ram_info() */
+}
+
+void board_add_ram_info(int)
+	__attribute__ ((weak, alias("__board_add_ram_info")));
+
 static int init_baud_rate(void)
 {
 	gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
@@ -135,6 +184,25 @@ static int announce_dram_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_PPC
+static int init_func_ram(void)
+{
+#ifdef	CONFIG_BOARD_TYPES
+	int board_type = gd->board_type;
+#else
+	int board_type = 0;	/* use dummy arg */
+#endif
+
+	gd->ram_size = initdram(board_type);
+
+	if (gd->ram_size > 0)
+		return 0;
+
+	puts("*** failed ***\n");
+	return 1;
+}
+#endif
+
 static int display_dram_config(void)
 {
 	ulong size;
@@ -155,11 +223,24 @@ static int display_dram_config(void)
 	size = gd->ram_size;
 #endif
 
-	print_size(size, "\n");
+	print_size(size, "");
+	board_add_ram_info(0);
+	putc('\n');
 
 	return 0;
 }
 
+ulong get_effective_memsize(void)
+{
+#ifndef	CONFIG_VERY_BIG_RAM
+	return gd->ram_size;
+#else
+	/* limit stack to what we can reasonable map */
+	return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
+		CONFIG_MAX_MEM_MAPPED : gd->ram_size);
+#endif
+}
+
 void __dram_init_banksize(void)
 {
 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
@@ -171,10 +252,37 @@ void __dram_init_banksize(void)
 void dram_init_banksize(void)
 	__attribute__((weak, alias("__dram_init_banksize")));
 
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+static int init_func_i2c(void)
+{
+	puts("I2C:   ");
+	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+	puts("ready\n");
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_HARD_SPI)
+static int init_func_spi(void)
+{
+	puts("SPI:   ");
+	spi_init();
+	puts("ready\n");
+	return 0;
+}
+#endif
+
 static int setup_global_data_ptr(void)
 {
-	/* Pointer is writable since we allocated a register for it */
+	/*
+	 * Pointer is writable since we allocated a register for it.
+	 * Can we choose one of these two methods instead of offering both?
+	 */
+#ifdef CONFIG_SYS_INIT_SP_ADDR
 	gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
+#else
+	gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
+#endif
 
 	/* compiler optimization barrier needed for GCC >= 3.4 */
 	dmb();
@@ -182,6 +290,7 @@ static int setup_global_data_ptr(void)
 	return 0;
 }
 
+__maybe_unused
 static int zero_global_data(void)
 {
 	memset((void *)gd, '\0', sizeof(gd_t));
@@ -194,7 +303,8 @@ static int setup_mon_len(void)
 #ifdef CONFIG_SYS_SYM_OFFSETS
 	gd->mon_len = _bss_end_ofs;
 #else
-	gd->mon_len = (ulong)&__bss_end - (ulong)&__text_start;
+	/* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
+	gd->mon_len = (ulong)&__bss_end__ - CONFIG_SYS_MONITOR_BASE;
 #endif
 	return 0;
 }
@@ -234,7 +344,22 @@ static int setup_reloc(void)
 	 */
 	gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
+#ifdef CONFIG_NR_DRAM_BANKS
 	gd->dest_addr = gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size;
+#else
+	gd->dest_addr = CONFIG_SYS_SDRAM_BASE + get_effective_memsize();
+#endif
+	gd->ram_top = gd->dest_addr;
+#if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
+	/*
+	 * We need to make sure the location we intend to put secondary core
+	 * boot code is reserved and not used by any part of u-boot
+	 */
+	if (gd->dest_addr > determine_mp_bootpg()) {
+		gd->dest_addr = determine_mp_bootpg();
+		debug("Reserving MP boot page to %08lx\n", gd->dest_addr);
+	}
+#endif
 	gd->dest_addr_sp = gd->dest_addr;
 	return 0;
 }
@@ -300,6 +425,19 @@ static int reserve_lcd(void)
 }
 #endif /* CONFIG_LCD */
 
+/* TODO: We should be able to just use CONFIG_VIDEO here */
+#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) \
+		&& !defined(CONFIG_ARM)
+static int reserve_video(void)
+{
+	/* reserve memory for video display (always full pages) */
+	gd->dest_addr = video_setmem(gd->dest_addr);
+	gd->fb_base = gd->dest_addr;
+
+	return 0;
+}
+#endif
+
 static int reserve_uboot(void)
 {
 	/*
@@ -308,6 +446,10 @@ static int reserve_uboot(void)
 	 */
 	gd->dest_addr -= gd->mon_len;
 	gd->dest_addr &= ~(4096 - 1);
+#ifdef CONFIG_E500
+	/* round down to next 64 kB limit so that IVPR stays aligned */
+	gd->dest_addr &= ~(65536 - 1);
+#endif
 
 	debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10,
 	      gd->dest_addr);
@@ -356,7 +498,13 @@ static int reserve_global_data(void)
 #ifndef CONFIG_SPL_BUILD
 static int reserve_stacks(void)
 {
+#ifdef CONFIG_PPC
+	ulong *s;
+#endif
+
 	/* setup stack pointer for exceptions */
+	gd->dest_addr_sp -= 16;
+	gd->dest_addr_sp &= ~0xf;
 	gd->irq_sp = gd->dest_addr_sp;
 #ifdef CONFIG_USE_IRQ
 	gd->dest_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
@@ -369,6 +517,14 @@ static int reserve_stacks(void)
 	/* leave 3 words for abort-stack, plus 1 for alignment */
 	gd->dest_addr_sp -= 16;
 
+#ifdef CONFIG_PPC
+	/* Clear initial stack frame */
+	s = (ulong *) gd->dest_addr_sp;
+	*s-- = 0;
+	*s-- = 0;
+	gd->dest_addr_sp = (ulong) s;
+#endif
+
 	return 0;
 }
 #endif
@@ -390,6 +546,106 @@ static int display_new_sp(void)
 	return 0;
 }
 
+#ifdef CONFIG_PPC
+static int setup_board_part1(void)
+{
+	bd_t *bd = gd->bd;
+
+	/*
+	 * Save local variables to board info struct
+	 */
+
+	bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;	/* start of memory */
+	bd->bi_memsize = gd->ram_size;			/* size in bytes */
+
+#ifdef CONFIG_SYS_SRAM_BASE
+	bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;	/* start of SRAM */
+	bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;		/* size  of SRAM */
+#endif
+
+#if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \
+		defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
+	bd->bi_immr_base = CONFIG_SYS_IMMR;	/* base  of IMMR register     */
+#endif
+#if defined(CONFIG_MPC5xxx)
+	bd->bi_mbar_base = CONFIG_SYS_MBAR;	/* base of internal registers */
+#endif
+#if defined(CONFIG_MPC83xx)
+	bd->bi_immrbar = CONFIG_SYS_IMMR;
+#endif
+#if defined(CONFIG_MPC8220)
+	bd->bi_mbar_base = CONFIG_SYS_MBAR;	/* base of internal registers */
+	bd->bi_inpfreq = gd->inp_clk;
+	bd->bi_pcifreq = gd->pci_clk;
+	bd->bi_vcofreq = gd->vco_clk;
+	bd->bi_pevfreq = gd->pev_clk;
+	bd->bi_flbfreq = gd->flb_clk;
+
+	/* store bootparam to sram (backward compatible), here? */
+	{
+		u32 *sram = (u32 *) CONFIG_SYS_SRAM_BASE;
+
+		*sram++ = gd->ram_size;
+		*sram++ = gd->bus_clk;
+		*sram++ = gd->inp_clk;
+		*sram++ = gd->cpu_clk;
+		*sram++ = gd->vco_clk;
+		*sram++ = gd->flb_clk;
+		*sram++ = 0xb8c3ba11;	/* boot signature */
+	}
+#endif
+
+	return 0;
+}
+
+static int setup_board_part2(void)
+{
+	bd_t *bd = gd->bd;
+
+	bd->bi_intfreq = gd->cpu_clk;	/* Internal Freq, in Hz */
+	bd->bi_busfreq = gd->bus_clk;	/* Bus Freq,      in Hz */
+#if defined(CONFIG_CPM2)
+	bd->bi_cpmfreq = gd->cpm_clk;
+	bd->bi_brgfreq = gd->brg_clk;
+	bd->bi_sccfreq = gd->scc_clk;
+	bd->bi_vco = gd->vco_out;
+#endif /* CONFIG_CPM2 */
+#if defined(CONFIG_MPC512X)
+	bd->bi_ipsfreq = gd->ips_clk;
+#endif /* CONFIG_MPC512X */
+#if defined(CONFIG_MPC5xxx)
+	bd->bi_ipbfreq = gd->ipb_clk;
+	bd->bi_pcifreq = gd->pci_clk;
+#endif /* CONFIG_MPC5xxx */
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_SYS_EXTBDINFO
+static int setup_board_extra(void)
+{
+	bd_t *bd = gd->bd;
+
+	strncpy((char *) bd->bi_s_version, "1.2", sizeof(bd->bi_s_version));
+	strncpy((char *) bd->bi_r_version, U_BOOT_VERSION,
+		sizeof(bd->bi_r_version));
+
+	bd->bi_procfreq = gd->cpu_clk;	/* Processor Speed, In Hz */
+	bd->bi_plb_busfreq = gd->bus_clk;
+#if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
+		defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+		defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
+	bd->bi_pci_busfreq = get_PCI_freq();
+	bd->bi_opbfreq = get_OPB_freq();
+#elif defined(CONFIG_XILINX_405)
+	bd->bi_pci_busfreq = get_PCI_freq();
+#endif
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_POST
 static int init_post(void)
 {
@@ -432,9 +688,17 @@ static int jump_to_copy(void)
 
 static init_fnc_t init_sequence_f[] = {
 	setup_global_data_ptr,
+#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC512X) && \
+		!defined(CONFIG_MPC83xx) && !defined(CONFIG_MPC85xx) && \
+		!defined(CONFIG_MPC86xx)
 	zero_global_data,
+#endif
 	setup_fdt,
 	setup_mon_len,
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+	/* TODO: can this go into arch_cpu_init()? */
+	probecpu,
+#endif
 #if defined(CONFIG_ARCH_CPU_INIT)
 	arch_cpu_init,		/* basic arch cpu dependent setup */
 #endif
@@ -444,30 +708,119 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 	board_early_init_f,
 #endif
+	/* TODO: can any of this go into arch_cpu_init()? */
+#if defined(CONFIG_PPC) && !defined(CONFIG_8xx_CPUCLK_DEFAULT)
+	get_clocks,		/* get CPU and bus clocks (etc.) */
+#if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
+		&& !defined(CONFIG_TQM885D)
+	adjust_sdram_tbs_8xx,
+#endif
+	/* TODO: can we rename this to timer_init()? */
+	init_timebase,
+#endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F)
+	board_early_init_f,
+#endif
+#ifdef CONFIG_ARM
 	timer_init,		/* initialize timer */
+#endif
 #ifdef CONFIG_FSL_ESDHC
 	get_clocks,
 #endif
+#ifdef CONFIG_SYS_ALLOC_DPRAM
+#if !defined(CONFIG_CPM2)
+	dpram_init,
+#endif
+#endif
+#if defined(CONFIG_BOARD_POSTCLK_INIT)
+	board_postclk_init,
+#endif
 	env_init,		/* initialize environment */
+#if defined(CONFIG_8xx_CPUCLK_DEFAULT)
+	/* get CPU and bus clocks according to the environment variable */
+	get_clocks_866,
+	/* adjust sdram refresh rate according to the new clock */
+	sdram_adjust_866,
+	init_timebase,
+#endif
 	init_baud_rate,		/* initialze baudrate settings */
 	serial_init,		/* serial communications setup */
 	console_init_f,		/* stage 1 init of console */
 	display_options,	/* say that we are here */
 	display_text_info,	/* show debugging info if required */
+#if defined(CONFIG_8260)
+	prt_8260_rsr,
+	prt_8260_clks,
+#endif /* CONFIG_8260 */
+#if defined(CONFIG_MPC83xx)
+	prt_83xx_rsr,
+#endif
+#ifdef CONFIG_PPC
+	checkcpu,
+#endif
 #if defined(CONFIG_DISPLAY_CPUINFO)
 	print_cpuinfo,		/* display cpu info (and speed) */
 #endif
+#if defined(CONFIG_MPC5xxx)
+	prt_mpc5xxx_clks,
+#endif /* CONFIG_MPC5xxx */
+#if defined(CONFIG_MPC8220)
+	prt_mpc8220_clks,
+#endif
 #if defined(CONFIG_DISPLAY_BOARDINFO)
 	checkboard,		/* display board info */
 #endif
+	INIT_FUNC_WATCHDOG_INIT
+#if defined(CONFIG_MISC_INIT_F)
+	misc_init_f,
+#endif
+	INIT_FUNC_WATCHDOG_RESET
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
+	init_func_i2c,
+#endif
+#if defined(CONFIG_HARD_SPI)
+	init_func_spi,
+#endif
 	announce_dram_init,
+	/* TODO: unify all these dram functions? */
+#ifdef CONFIG_ARM
 	dram_init,		/* configure available RAM banks */
 	setup_dram_config,
+#endif
+#ifdef CONFIG_X86
+	dram_init_f,		/* configure available RAM banks */
+#endif
+#ifdef CONFIG_PPC
+	init_func_ram,
+#endif
 	display_dram_config,
 #ifdef CONFIG_POST
+	post_init_f,
+#endif
+	INIT_FUNC_WATCHDOG_RESET
+#if defined(CONFIG_SYS_DRAM_TEST)
+	testdram,
+#endif /* CONFIG_SYS_DRAM_TEST */
+	INIT_FUNC_WATCHDOG_RESET
+
+#ifdef CONFIG_POST
 	init_post,
 #endif
+	INIT_FUNC_WATCHDOG_RESET
 	setup_dram_config,
+
+	/*
+	 * Now that we have DRAM mapped and working, we can
+	 * relocate the code and continue running from DRAM.
+	 *
+	 * Reserve memory at end of RAM for (top down in that order):
+	 *  - area that won't get touched by U-Boot and Linux (optional)
+	 *  - kernel log buffer
+	 *  - protected RAM
+	 *  - LCD framebuffer
+	 *  - monitor code
+	 *  - board info struct
+	 */
 	setup_reloc,
 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
 	reserve_logbuffer,
@@ -482,6 +835,11 @@ static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_LCD
 	reserve_lcd,
 #endif
+	/* TODO: Why the dependency on CONFIG_8xx? */
+#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) \
+		&& !defined(CONFIG_ARM)
+	reserve_video,
+#endif
 	reserve_uboot,
 #ifndef CONFIG_SPL_BUILD
 	reserve_malloc,
@@ -494,8 +852,17 @@ static init_fnc_t init_sequence_f[] = {
 #else
 	reserve_stacks,
 #endif
+#ifdef CONFIG_PPC
+	setup_board_part1,
+	INIT_FUNC_WATCHDOG_RESET
+	setup_board_part2,
+#endif
 	setup_baud_rate,
 	display_new_sp,
+#ifdef CONFIG_SYS_EXTBDINFO
+	setup_board_extra,
+#endif
+	INIT_FUNC_WATCHDOG_RESET
 	jump_to_copy,
 	NULL,
 };
include/common.h +16 -0
index 0bda049..3140375 100644
@@ -284,6 +284,22 @@ int mac_read_from_eeprom(void);
 extern u8 _binary_dt_dtb_start[];	/* embedded device tree blob */
 int set_cpu_clk_info(void);
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/*
+ * Reset the watchdog timer, always returns 0
+ *
+ * This function is here since it is shared between board_f() and board_r().
+ */
+int init_func_watchdog_reset(void);
+#endif
+
+#if defined(CONFIG_WATCHDOG)
+#define INIT_FUNC_WATCHDOG_RESET	init_func_watchdog_reset,
+#else
+#define INIT_FUNC_WATCHDOG_RESET	/* undef */
+#endif /* CONFIG_WATCHDOG */
+
+
 /*
  * Called when console output is requested before the console is available.
  * The board should do its best to get the character out to the user any way
Signature · 1 line
1.7.7.3
#48 lore raw

PATCH v4 24/27 Adjust board_r.c for PowerPC

In reply to Simon Glass

This adds ppc features to the generic post-relocation board init.

---
Changes in v4:
- Updates to sit on top of earlier patches

 common/board_r.c |  462 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 459 insertions(+), 3 deletions(-)
common/board_r.c +459 -3
index f587c03..19d162b 100644
@@ -27,24 +27,84 @@
  */
 
 #include <common.h>
+/* TODO: can we just include all these headers whether needed or not? */
+#if defined(CONFIG_CMD_BEDBUG)
+#include <bedbug/type.h>
+#endif
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
 #include <environment.h>
+#if defined(CONFIG_CMD_IDE)
+#include <ide.h>
+#endif
 #include <initcall.h>
+#ifdef CONFIG_PS2KBD
+#include <keyboard.h>
+#endif
+#if defined(CONFIG_CMD_KGDB)
+#include <kgdb.h>
+#endif
 #include <logbuff.h>
 #include <malloc.h>
+#ifdef CONFIG_BITBANGMII
+#include <miiphy.h>
+#endif
 #include <mmc.h>
 #include <nand.h>
 #include <onenand_uboot.h>
+#include <scsi.h>
 #include <serial.h>
+#include <spi.h>
 #include <stdio_dev.h>
+#include <watchdog.h>
+#ifdef CONFIG_ADDR_MAP
+#include <asm/mmu.h>
+#endif
 #include <asm/sections.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
+/* TODO: Move this prototype to a header? */
+#ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
+extern int update_flash_size(int flash_size);
+#endif
+
+int __board_flash_wp_on(void)
+{
+	/*
+	 * Most flashes can't be detected when write protection is enabled,
+	 * so provide a way to let U-Boot gracefully ignore write protected
+	 * devices.
+	 */
+	return 0;
+}
+
+int board_flash_wp_on(void)
+	__attribute__ ((weak, alias("__board_flash_wp_on")));
+
+void __cpu_secondary_init_r(void)
+{
+}
+
+void cpu_secondary_init_r(void)
+	__attribute__ ((weak, alias("__cpu_secondary_init_r")));
+
+static int initr_secondary_cpu(void)
+{
+	/*
+	 * after non-volatile devices & environment is setup and cpu code have
+	 * another round to deal with any initialization that might require
+	 * full access to the environment or loading of some image (firmware)
+	 * from a non-volatile device
+	 */
+	/* TODO: maybe define this for all archs? */
+	cpu_secondary_init_r();
+
+	return 0;
+}
 
 static int initr_reloc(void)
 {
@@ -73,6 +133,25 @@ static int initr_reloc_global_data(void)
 #else
 	monitor_flash_len = (ulong)&__init_end - gd->dest_addr;
 #endif
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+	/*
+	 * The gd->cpu pointer is set to an address in flash before relocation.
+	 * We need to update it to point to the same CPU entry in RAM.
+	 * TODO: why not just add gd->reloc_ofs?
+	 */
+	gd->cpu += gd->dest_addr - CONFIG_SYS_MONITOR_BASE;
+#endif
+#ifdef CONFIG_SYS_EXTRA_ENV_RELOC
+	/*
+	 * Some systems need to relocate the env_addr pointer early because the
+	 * location it points to will get invalidated before env_relocate is
+	 * called.  One example is on systems that might use a L2 or L3 cache
+	 * in SRAM mode and initialize that cache from SRAM mode back to being
+	 * a cache in cpu_init_r.
+	 */
+	gd->env_addr += gd->dest_addr - CONFIG_SYS_MONITOR_BASE;
+#endif
+	return 0;
 }
 
 #ifdef CONFIG_SERIAL_MULTI
@@ -83,6 +162,27 @@ static int initr_serial(void)
 }
 #endif
 
+#ifdef CONFIG_PPC
+static int initr_trap(void)
+{
+	/*
+	 * Setup trap handlers
+	 */
+	trap_init(gd->dest_addr);
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_ADDR_MAP
+static int initr_addr_map(void)
+{
+	init_addr_map();
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_LOGBUFFER
 unsigned long logbuffer_base(void)
 {
@@ -104,6 +204,50 @@ static int initr_post_backlog(void)
 }
 #endif
 
+#ifdef CONFIG_SYS_DELAYED_ICACHE
+static int initr_icache_enable(void)
+{
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
+static int initr_unlock_ram_in_cache(void)
+{
+	unlock_ram_in_cache();	/* it's time to unlock D-cache in e500 */
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PCI
+static int initr_pci(void)
+{
+	pci_init();
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_WINBOND_83C553
+static int initr_w83c553f(void)
+{
+	/*
+	 * Initialise the ISA bridge
+	 */
+	initialise_w83c553f();
+	return 0;
+}
+#endif
+
+static int initr_barrier(void)
+{
+#ifdef CONFIG_PPC
+	/* TODO: Can we not use dmb() macros for this? */
+	asm("sync ; isync");
+#endif
+	return 0;
+}
+
 static int initr_malloc(void)
 {
 	ulong malloc_start;
@@ -123,13 +267,26 @@ static int initr_announce(void)
 #if !defined(CONFIG_SYS_NO_FLASH)
 static int initr_flash(void)
 {
-	ulong flash_size;
+	ulong flash_size = 0;
+	bd_t *bd = gd->bd;
+	int ok;
 
 	puts("Flash: ");
 
-	flash_size = flash_init();
-	if (flash_size <= 0) {
+	if (board_flash_wp_on()) {
+		printf("Uninitialized - Write Protect On\n");
+		/* Since WP is on, we can't find real size.  Set to 0 */
+		ok = 1;
+	} else {
+		flash_size = flash_init();
+		ok = flash_size > 0;
+	}
+	if (!ok) {
 		puts("*** failed ***\n");
+#ifdef CONFIG_PPC
+		/* Why does PPC do this? */
+		hang();
+#endif
 		return -1;
 	}
 	print_size(flash_size, "");
@@ -152,6 +309,40 @@ static int initr_flash(void)
 	}
 #endif /* CONFIG_SYS_FLASH_CHECKSUM */
 	putc('\n');
+
+	/* update start of FLASH memory    */
+#ifdef CONFIG_SYS_FLASH_BASE
+	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
+#endif
+	/* size of FLASH memory (final value) */
+	bd->bi_flashsize = flash_size;
+
+#if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
+	/* Make a update of the Memctrl. */
+	update_flash_size(flash_size);
+#endif
+
+
+#if defined(CONFIG_OXC) || defined(CONFIG_RMU)
+	/* flash mapped at end of memory map */
+	bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
+#elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
+	bd->bi_flashoffset = monitor_flash_len;	/* reserved area for monitor */
+#endif
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PPC
+static int initr_spi(void)
+{
+	/* PPC does this here */
+#ifdef CONFIG_SPI
+#if !defined(CONFIG_ENV_IS_IN_EEPROM)
+	spi_init_f();
+#endif
+	spi_init_r();
+#endif
 	return 0;
 }
 #endif
@@ -216,9 +407,56 @@ static int initr_env(void)
 			copy_filename(BootFile, s, sizeof(BootFile));
 	}
 #endif
+#if defined(CONFIG_SYS_EXTBDINFO)
+#if defined(CONFIG_405GP) || defined(CONFIG_405EP)
+#if defined(CONFIG_I2CFAST)
+	/*
+	 * set bi_iic_fast for linux taking environment variable
+	 * "i2cfast" into account
+	 */
+	{
+		char *s = getenv("i2cfast");
+
+		if (s && ((*s == 'y') || (*s == 'Y'))) {
+			gd->bd->bi_iic_fast[0] = 1;
+			gd->bd->bi_iic_fast[1] = 1;
+		}
+	}
+#endif /* CONFIG_I2CFAST */
+#endif /* CONFIG_405GP, CONFIG_405EP */
+#endif /* CONFIG_SYS_EXTBDINFO */
+	return 0;
+}
+
+#ifdef	CONFIG_HERMES
+static int initr_hermes(void)
+{
+	if ((gd->board_type >> 16) == 2)
+		gd->bd->bi_ethspeed = gd->board_type & 0xFFFF;
+	else
+		gd->bd->bi_ethspeed = 0xFFFF;
 	return 0;
 }
 
+static int initr_hermes_start(void)
+{
+	if (gd->bd->bi_ethspeed != 0xFFFF)
+		hermes_start_lxt980((int) gd->bd->bi_ethspeed);
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_SC3
+/* TODO: with new initcalls, move this into the driver */
+extern void sc3_read_eeprom(void);
+
+static int initr_sc3_read_eeprom(void)
+{
+	sc3_read_eeprom();
+	return 0;
+}
+#endif
+
 static int initr_jumptable(void)
 {
 	jumptable_init();
@@ -246,6 +484,8 @@ static int initr_enable_interrupts(void)
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
 {
+	bd_t *bd = gd->bd;
+
 #if defined(CONFIG_DRIVER_SMC91111) || defined(CONFIG_DRIVER_LAN91C96)
 	/* Perform network card initialisation if necessary */
 	/* XXX: this needs to be moved to board init */
@@ -257,11 +497,63 @@ static int initr_ethaddr(void)
 		smc_set_mac_addr(enetaddr);
 	}
 #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
+	/* kept around for legacy kernels only ... ignore the next section */
+	eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
+#ifdef CONFIG_HAS_ETH1
+	eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
+#endif
+#ifdef CONFIG_HAS_ETH2
+	eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
+#endif
+#ifdef CONFIG_HAS_ETH3
+	eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
+#endif
+#ifdef CONFIG_HAS_ETH4
+	eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
+#endif
+#ifdef CONFIG_HAS_ETH5
+	eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
+#endif
+	return 0;
+}
+#endif /* CONFIG_CMD_NET */
+
+#ifdef CONFIG_CMD_KGDB
+static int initr_kgdb(void)
+{
+	puts("KGDB:  ");
+	kgdb_init();
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+static int initr_status_led(void)
+{
+	status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
+
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_CMD_SCSI)
+static int initr_scsi(void)
+{
+	puts("SCSI:  ");
+	scsi_init();
 
 	return 0;
 }
 #endif /* CONFIG_CMD_NET */
 
+#if defined(CONFIG_CMD_DOC)
+static int initr_doc(void)
+{
+	puts("DOC:   ");
+	doc_init();
+}
+#endif
+
 #ifdef CONFIG_BITBANGMII
 static int initr_bbmii(void)
 {
@@ -291,6 +583,33 @@ static int initr_post(void)
 }
 #endif
 
+#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
+static int initr_pcmcia(void)
+{
+	puts("PCMCIA:");
+	pcmcia_init();
+	return 0;
+}
+#endif
+
+#if defined(CONFIG_CMD_IDE)
+static int initr_ide(void)
+{
+#ifdef	CONFIG_IDE_8xx_PCCARD
+	puts("PCMCIA:");
+#else
+	puts("IDE:   ");
+#endif
+#if defined(CONFIG_START_IDE)
+	if (board_start_ide())
+		ide_init();
+#else
+	ide_init();
+#endif
+	return 0;
+}
+#endif
+
 #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
 /*
  * Export available size of memory for Linux, taking into account the
@@ -310,6 +629,37 @@ int initr_mem(void)
 # endif
 	sprintf(memsz, "%ldk", (gd->ram_size / 1024) - pram);
 	setenv("mem", memsz);
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_CMD_BEDBUG
+static int initr_bedbug(void)
+{
+	bedbug_init();
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PS2KBD
+static int initr_kbd(void)
+{
+	puts("PS/2:  ");
+	kbd_init();
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_MODEM_SUPPORT
+static int initr_modem(void)
+{
+	/* TODO: with new initcalls, move this into the driver */
+	extern int do_mdm_init;
+
+	do_mdm_init = gd->do_mdm_init;
+	return 0;
 }
 #endif
 
@@ -327,9 +677,12 @@ static int run_main_loop(void)
  *
  * We also hope to remove most of the driver-related init and do it if/when
  * the driver is later used.
+ *
+ * TODO: perhaps reset the watchdog in the initcall function after each call?
  */
 init_fnc_t init_sequence_r[] = {
 	initr_reloc,
+	/* TODO: could x86/PPC have this also perhaps? */
 #ifdef CONFIG_ARM
 	initr_caches,
 	board_init,	/* Setup chipselects */
@@ -339,16 +692,51 @@ init_fnc_t init_sequence_r[] = {
 	initr_serial,
 #endif
 	initr_announce,
+	INIT_FUNC_WATCHDOG_RESET
+#ifdef CONFIG_PPC
+	initr_trap,
+#endif
+#ifdef CONFIG_ADDR_MAP
+	initr_addr_map,
+#endif
+#if defined(CONFIG_BOARD_EARLY_INIT_R)
+	board_early_init_r,
+#endif
+	INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_LOGBUFFER
 	initr_logbuffer,
 #endif
 #ifdef CONFIG_POST
 	initr_post_backlog,
 #endif
+	INIT_FUNC_WATCHDOG_RESET
+#ifdef CONFIG_SYS_DELAYED_ICACHE
+	initr_icache_enable,
+#endif
+#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
+	initr_unlock_ram_in_cache,
+#endif
+#if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
+	/*
+	 * Do early PCI configuration _before_ the flash gets initialised,
+	 * because PCU ressources are crucial for flash access on some boards.
+	 */
+	initr_pci,
+#endif
+#ifdef CONFIG_WINBOND_83C553
+	initr_w83c553f,
+#endif
+	initr_barrier,
 	initr_malloc,
 #ifndef CONFIG_SYS_NO_FLASH
 	initr_flash,
 #endif
+	INIT_FUNC_WATCHDOG_RESET
+#ifdef CONFIG_PPC
+	/* initialize higher level parts of CPU like time base and timers */
+	cpu_init_r,
+	initr_spi,
+#endif
 #ifdef CONFIG_CMD_NAND
 	initr_nand,
 #endif
@@ -362,6 +750,24 @@ init_fnc_t init_sequence_r[] = {
 	initr_dataflash,
 #endif
 	initr_env,
+	INIT_FUNC_WATCHDOG_RESET
+	initr_secondary_cpu,
+#ifdef CONFIG_SC3
+	initr_sc3_read_eeprom,
+#endif
+#ifdef	CONFIG_HERMES
+	initr_hermes,
+#endif
+#if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
+	mac_read_from_eeprom,
+#endif
+	INIT_FUNC_WATCHDOG_RESET
+#if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
+	/*
+	 * Do pci configuration
+	 */
+	initr_pci,
+#endif
 	stdio_init,
 	initr_jumptable,
 #ifdef CONFIG_API
@@ -374,23 +780,73 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_MISC_INIT_R
 	misc_init_r,		/* miscellaneous platform-dependent init */
 #endif
+#ifdef CONFIG_HERMES
+	initr_hermes_start,
+#endif
+	INIT_FUNC_WATCHDOG_RESET
+#ifdef CONFIG_CMD_KGDB
+	initr_kgdb,
+#endif
 	interrupt_init,
+#ifdef CONFIG_ARM
 	initr_enable_interrupts,
+#endif
+#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+	initr_status_led,
+#endif
+	/* PPC has a udelay(20) here dating from 2002. Why? */
 #ifdef CONFIG_CMD_NET
 	initr_ethaddr,
 #endif
 #ifdef CONFIG_BOARD_LATE_INIT
 	board_late_init,
 #endif
+#ifdef CONFIG_CMD_SCSI
+	INIT_FUNC_WATCHDOG_RESET
+	initr_scsi,
+#endif
+#ifdef CONFIG_CMD_DOC
+	INIT_FUNC_WATCHDOG_RESET
+	initr_doc,
+#endif
 #ifdef CONFIG_BITBANGMII
 	initr_bbmii,
 #endif
 #ifdef CONFIG_CMD_NET
+	INIT_FUNC_WATCHDOG_RESET
 	initr_net,
 #endif
 #ifdef CONFIG_POST
 	initr_post,
 #endif
+#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
+	initr_pcmcia,
+#endif
+#if defined(CONFIG_CMD_IDE)
+	initr_ide,
+#endif
+#ifdef CONFIG_LAST_STAGE_INIT
+	INIT_FUNC_WATCHDOG_RESET
+	/*
+	 * Some parts can be only initialized if all others (like
+	 * Interrupts) are up and running (i.e. the PC-style ISA
+	 * keyboard).
+	 */
+	last_stage_init,
+#endif
+#ifdef CONFIG_CMD_BEDBUG
+	INIT_FUNC_WATCHDOG_RESET
+	initr_bedbug,
+#endif
+#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
+	initr_mem,
+#endif
+#ifdef CONFIG_PS2KBD
+	initr_kbd,
+#endif
+#ifdef CONFIG_MODEM_SUPPORT
+	initr_modem,
+#endif
 	run_main_loop,
 };
 
Signature · 1 line
1.7.7.3
#49 lore raw

PATCH v4 25/27 ppc: Enable generic board board

In reply to Simon Glass

This enables generic board support so that ppc boards can define CONFIG_SYS_GENERIC_BOARD.

---

 arch/powerpc/config.mk                 |    3 ---
 arch/powerpc/include/asm/global_data.h |    7 +++++++
 arch/powerpc/include/asm/u-boot.h      |    7 +++++++
 arch/powerpc/lib/Makefile              |    4 +++-
 4 files changed, 17 insertions(+), 4 deletions(-)
arch/powerpc/config.mk +0 -3
index e6203dd..a307154 100644
@@ -29,9 +29,6 @@ PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
 
-# Move to unified board system later
-CONFIG_SYS_LEGACY_BOARD := y
-
 #
 # When cross-compiling on NetBSD, we have to define __PPC__ or else we
 # will pick up a va_list declaration that is incompatible with the
arch/powerpc/include/asm/global_data.h +7 -0
index 01f1d4a..3200443 100644
@@ -27,6 +27,11 @@
 #include "config.h"
 #include "asm/types.h"
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified global_data */
+#include <asm-generic/global_data.h>
+#else
+
 /*
  * The following data structure is placed in some memory wich is
  * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or
@@ -198,6 +203,8 @@ typedef	struct	global_data {
 #define GD_FLG_DISABLE_CONSOLE	0x00040	/* Disable console (in & out)		*/
 #define GD_FLG_ENV_READY	0x00080	/* Environment imported into hash table	*/
 
+#endif /* nCONFIG_SYS_GENERIC_BOARD */
+
 #if 1
 #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r2")
 #else /* We could use plain global data, but the resulting code is bigger */
arch/powerpc/include/asm/u-boot.h +7 -0
index b2fa2b5..7cc9af7 100644
@@ -34,6 +34,11 @@
  * include/asm-ppc/u-boot.h
  */
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified bd_info */
+#include <asm-generic/u-boot.h>
+#else
+
 #ifndef __ASSEMBLY__
 
 typedef struct bd_info {
@@ -144,6 +149,8 @@ typedef struct bd_info {
 
 #endif /* __ASSEMBLY__ */
 
+#endif /* nCONFIG_SYS_GENERIC_BOARD */
+
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_PPC
 
arch/powerpc/lib/Makefile +3 -1
index cdd62a2..eef76b5 100644
@@ -44,7 +44,9 @@ SOBJS-y	+= ticks.o
 SOBJS-y	+= reloc.o
 
 COBJS-$(CONFIG_BAT_RW) += bat_rw.o
-COBJS-y	+= board.o
+ifeq ($(CONFIG_SYS_GENERIC_BOARD),)
+COBJS-y += board.o
+endif
 COBJS-y	+= bootm.o
 COBJS-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount.o
 COBJS-y	+= cache.o
Signature · 1 line
1.7.7.3
#50 lore raw

PATCH v4 26/27 tegra: Mark board init files for ARMv4t

In reply to Simon Glass

Since Tegra executes early code on an ARMv4T (but the rest on ARMv7) we must mark the new board init files for compilation with ARMv4t architecture.

---

 arch/arm/cpu/armv7/tegra2/config.mk |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/config.mk +2 -0
index 2303dba..4b43dde 100644
@@ -28,6 +28,8 @@
 # file with compatible flags
 ifdef CONFIG_TEGRA2
 CFLAGS_arch/arm/lib/board.o += -march=armv4t
+CFLAGS_common/board_f.o += -march=armv4t
+CFLAGS_lib/initcall.o += -march=armv4t
 endif
 
 USE_PRIVATE_LIBGCC = yes
Signature · 1 line
1.7.7.3
#51 lore raw

PATCH v4 27/27 tegra: Enable generic board for Seaboard.

In reply to Simon Glass

Enable CONFIG_SYS_GENERIC_BOARD for Tegra 2 Seaboard.

---
Changes in v2:
- Add CONFIG_SYS_GENERIC_BOARD to allow board to select generic board
- Add PowerPC support
- Change generic board to an opt-in system on a per-board basic
- Rebase to master

Changes in v3:
- Rebase on top of x86/master (which has not yet been pulled to master)
- Rebase to master

Changes in v4:
- Drop sc520_timer.c patch (warning already fixed by previous patch)
- Rebase to master

 include/configs/seaboard.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/configs/seaboard.h +2 -0
index 261f952..11d9e8d 100644
@@ -27,6 +27,8 @@
 #include <asm/sizes.h>
 #include "tegra2-common.h"
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /* High-level configuration options */
 #define TEGRA2_SYSMEM		"mem=384M at 0M nvmem=128M at 384M mem=512M at 512M"
 #define V_PROMPT		"Tegra2 (SeaBoard) # "
Signature · 1 line
1.7.7.3
#6 lore raw

PATCH v4 4/27 x86: Remove dead code in eNET

Quoted 8 lines · Graeme Russ

Hi Simon,

Quoted 5 lines · Simon Glass

This avoids a compiler warning about unused variables.

---

Quoted 6 lines
Quoted 2 lines

?board/eNET/eNET.c | ? ?5 -----
?1 files changed, 0 insertions(+), 5 deletions(-)

I'll apply this to x86/master directly and send a pull request

Thanks Graeme.

Quoted 4 lines

Regards,

Graeme

#24 lore raw

PATCH v4 11/27 x86: Change stub example to use asm-generic/sections.h

In reply to Simon Glass

Hi Simon,

Quoted 33 lines · Simon Glass

We can use the declarations of __bss_start and _end from this header instead of declaring them locally.

---
Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

?examples/standalone/stubs.c | ? ?7 +++----
?1 files changed, 3 insertions(+), 4 deletions(-)

examples/standalone/stubs.c +0 -0
index 15e9afc..8fb1765 100644
@@ -217,16 +217,15 @@ void __attribute__((unused)) dummy(void)

?#include <_exports.h>
?}

examples/standalone/stubs.c +1 -1
-extern unsigned long __bss_start, _end;
+#include <asm/sections.h>

?void app_startup(char * const *argv)
?{
- ? ? ? unsigned char * cp = (unsigned char *) &__bss_start;
+ ? ? ? char *cp = __bss_start;

? ? ? ?/* Zero out BSS */
- ? ? ? while (cp < (unsigned char *)&_end) {
+ ? ? ? while (cp < _end)
? ? ? ? ? ? ? ?*cp++ = 0;
- ? ? ? }

Quoted 5 lines

?#if defined(CONFIG_X86)
? ? ? ?/* x86 does not have a dedicated register for passing global_data */ --
1.7.7.3

Does not look like x86 to me - looks like common code

Regards,

Graeme

#11 lore raw

PATCH v4 7/27 Introduce generic global_data

In reply to Simon Glass

Hi Simon,

Quoted 9 lines · Simon Glass

We want to unify the global_data structure. Most fields are common across architectures, but there are a fair number of SOC-specific additions. It isn't clear how best to deal with these, but for now we just use #ifdef.

Checkpatch warnings here might be unavoidable:

warning: include/asm-generic/global_data.h,43: do not add new typedefs
warning: include/asm-generic/global_data.h,117: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: include/asm-generic/global_data.h,121: storage class should be at the beginning of the declaration

IMHO global data does not need to be (and should not be) typedef'd

Regards,

Graeme

#12 lore raw

PATCH v4 7/27 Introduce generic global_data

In reply to Simon Glass

Hi Simon,

Quoted 21 lines · Simon Glass

We want to unify the global_data structure. Most fields are common across architectures, but there are a fair number of SOC-specific additions. It isn't clear how best to deal with these, but for now we just use #ifdef.

Checkpatch warnings here might be unavoidable:

warning: include/asm-generic/global_data.h,43: do not add new typedefs
warning: include/asm-generic/global_data.h,117: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: include/asm-generic/global_data.h,121: storage class should be at the beginning of the declaration

---

(quoted diff) +7 -0
+#ifdef CONFIG_AT91FAMILY
+ ? ? ? /* "static data" needed by at91's clock.c */
+ ? ? ? unsigned long ? cpu_clk_rate_hz;
+ ? ? ? unsigned long ? main_clk_rate_hz;
+ ? ? ? unsigned long ? mck_rate_hz;
+ ? ? ? unsigned long ? plla_rate_hz;
+ ? ? ? unsigned long ? pllb_rate_hz;

Review

Quoted 10 lines
(quoted diff) +10 -0
+ ? ? ? unsigned long ? at91_pllb_usb_init;
+#endif
+#ifdef CONFIG_ARM
+ ? ? ? /* "static data" needed by most of timer.c on ARM platforms */
+ ? ? ? unsigned long ? timer_rate_hz;
+ ? ? ? unsigned long ? tbl;
+ ? ? ? unsigned long ? tbu;
+ ? ? ? unsigned long long ? ? ?timer_reset_value;
+ ? ? ? unsigned long ? lastinc;
+#endif

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

Regards,

Graeme

#41 lore raw

PATCH v4 20/27 Add x86 fields to generic global_data

In reply to Simon Glass

Hi Simon,

Quoted 13 lines · Simon Glass

These fields are needed for x86.

---

?include/asm-generic/global_data.h | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

include/asm-generic/global_data.h +0 -0
index 6199926..fb976f9 100644

include/asm-generic/global_data.h typedef struct global_data { · line 48

Quoted 5 lines
include/asm-generic/global_data.h +2 -0
@@ -44,6 +44,8 @@ typedef struct global_data {
 ? ? ? ?bd_t ? ? ? ? ? ?*bd;
 ? ? ? ?unsigned long ? flags;
 ? ? ? ?unsigned long ? baudrate;
+ ? ? ? unsigned long ? cpu_clk; ? ? ? ?/* CPU clock in Hz! ? ? ? ? ? ? */
+ ? ? ? unsigned long ? bus_clk;

Refer to my other comment, but this impacts all arches for no good reason

Regards,

Graeme

#25 lore raw

PATCH v4 11/27 x86: Change stub example to use asm-generic/sections.h

In reply to Graeme Russ

Hi Graeme,

Quoted 36 lines · Graeme Russ

Hi Simon,

Quoted 33 lines · Simon Glass

We can use the declarations of __bss_start and _end from this header instead of declaring them locally.

---
Changes in v4:
- Use asm/sections.h instead of asm-generic/sections.h

?examples/standalone/stubs.c | ? ?7 +++----
?1 files changed, 3 insertions(+), 4 deletions(-)

examples/standalone/stubs.c +0 -0
index 15e9afc..8fb1765 100644
@@ -217,16 +217,15 @@ void __attribute__((unused)) dummy(void)

?#include <_exports.h>
?}

examples/standalone/stubs.c +1 -1
-extern unsigned long __bss_start, _end;
+#include <asm/sections.h>

?void app_startup(char * const *argv)
?{
- ? ? ? unsigned char * cp = (unsigned char *) &__bss_start;
+ ? ? ? char *cp = __bss_start;

? ? ? ?/* Zero out BSS */
- ? ? ? while (cp < (unsigned char *)&_end) {
+ ? ? ? while (cp < _end)
? ? ? ? ? ? ? ?*cp++ = 0;
- ? ? ? }

Quoted 7 lines
Quoted 5 lines

?#if defined(CONFIG_X86)
? ? ? ?/* x86 does not have a dedicated register for passing global_data */ --
1.7.7.3

Does not look like x86 to me - looks like common code

Yes that tag is wrong. Should I re-issue the patch?

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#26 lore raw

PATCH v4 11/27 x86: Change stub example to use asm-generic/sections.h

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Graeme,

Quoted 4 lines · Graeme Russ

Hi Simon,

Does not look like x86 to me - looks like common code

Yes that tag is wrong. Should I re-issue the patch?

Yes, but wait until you rev the whole series

Regards,

Graeme

#13 lore raw

PATCH v4 7/27 Introduce generic global_data

In reply to Graeme Russ

Hi Graeme,

Quoted 29 lines · Graeme Russ

Hi Simon,

Quoted 26 lines · Simon Glass

We want to unify the global_data structure. Most fields are common across architectures, but there are a fair number of SOC-specific additions. It isn't clear how best to deal with these, but for now we just use #ifdef.

Checkpatch warnings here might be unavoidable:

warning: include/asm-generic/global_data.h,43: do not add new typedefs
warning: include/asm-generic/global_data.h,117: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
warning: include/asm-generic/global_data.h,121: storage class should be at the beginning of the declaration

---

(quoted diff) +12 -0
+#ifdef CONFIG_AT91FAMILY
+ ? ? ? /* "static data" needed by at91's clock.c */
+ ? ? ? unsigned long ? cpu_clk_rate_hz;
+ ? ? ? unsigned long ? main_clk_rate_hz;
+ ? ? ? unsigned long ? mck_rate_hz;
+ ? ? ? unsigned long ? plla_rate_hz;
+ ? ? ? unsigned long ? pllb_rate_hz;
+ ? ? ? unsigned long ? at91_pllb_usb_init;
+#endif
+#ifdef CONFIG_ARM
+ ? ? ? /* "static data" needed by most of timer.c on ARM platforms */
+ ? ? ? unsigned long ? timer_rate_hz;
Quoted 8 lines
Quoted 5 lines

+ ? ? ? unsigned long ? tbl;
+ ? ? ? unsigned long ? tbu;
+ ? ? ? unsigned long long ? ? ?timer_reset_value;
+ ? ? ? unsigned long ? lastinc;
+#endif

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

My thinking here was to try to bring everything into a single file. It then should be clearer when things are common between different architectures. Patches to the generic file can be made without also having to patch the non-generic files, etc.

A fair number of the #ifdefs are not needed, or are there because some archs don't implement all the features of U-Boot.

You have an example right there: cpu_clk_rate_hz is similar to cpu_clk and core_clk.

That said it is a bit of a daunting task to amalgamate them.

Also there is the purely practical consideration that if we continue to have an asm/global_data.h then we end up with two global datas. One is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all fields. Ick.

So what do you think?

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#42 lore raw

PATCH v4 20/27 Add x86 fields to generic global_data

In reply to Graeme Russ

Hi Graeme,

Quoted 11 lines · Graeme Russ

Hi Simon,

Quoted 8 lines · Simon Glass

These fields are needed for x86.

---

?include/asm-generic/global_data.h | ? ?2 ++
?1 files changed, 2 insertions(+), 0 deletions(-)

Quoted 12 lines

include/asm-generic/global_data.h typedef struct global_data { · line 48

Quoted 10 lines
include/asm-generic/global_data.h +2 -0
index 6199926..fb976f9 100644
@@ -44,6 +44,8 @@ typedef struct global_data {
 ? ? ? ?bd_t ? ? ? ? ? ?*bd;
 ? ? ? ?unsigned long ? flags;
 ? ? ? ?unsigned long ? baudrate;
+ ? ? ? unsigned long ? cpu_clk; ? ? ? ?/* CPU clock in Hz! ? ? ? ? ? ? */
+ ? ? ? unsigned long ? bus_clk;

Refer to my other comment, but this impacts all arches for no good reason

See my other reply. Let me just add that these values would be pretty useful to most archs.

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#14 lore raw

PATCH v4 7/27 Introduce generic global_data

In reply to Simon Glass

Hi Simon,

Quoted 5 lines · Simon Glass

Hi Graeme,

Quoted 2 lines · Graeme Russ

Hi Simon,

[snip]

Quoted 17 lines
Quoted 3 lines

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

My thinking here was to try to bring everything into a single file. It then should be clearer when things are common between different architectures. Patches to the generic file can be made without also having to patch the non-generic files, etc.

A fair number of the #ifdefs are not needed, or are there because some archs don't implement all the features of U-Boot.

You have an example right there: cpu_clk_rate_hz is similar to cpu_clk and core_clk.

That said it is a bit of a daunting task to amalgamate them.

Quoted 7 lines

Also there is the purely practical consideration that if we continue to have an asm/global_data.h then we end up with two global datas. One is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all fields. Ick.

So what do you think?

Do you really need to unify global data to achieve what the title of the patch series suggests (i.e. to unify the init processing loop)? Maybe you could leave global data as is (or slightly tweak the odd arch) and leave the resolution of just how bad global data is becoming for another day

I only say this because this is turning into "let's do a dirty hack now to partially fix it and leave the rest for later (it'll get done, really, honestly, I promise)" ;)

There will always be arch specific global data members - I see a few options:

- Move them into bd
- Move them into an arch_global_data struct inside gd
- Move them into an arch_global_data struct totally seperate from gd
- Question how many are really required to be in gd (remember, gd is only there to cart around writable global variable before .bss and .data are available after relocation)

Regards,

Graeme

#15 lore raw

PATCH v4 7/27 Introduce generic global_data

Hi Graeme,

Quoted 34 lines · Graeme Russ

Hi Simon,

Quoted 5 lines · Simon Glass

Hi Graeme,

Quoted 2 lines · Graeme Russ

Hi Simon,

[snip]

Quoted 23 lines
Quoted 3 lines

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

My thinking here was to try to bring everything into a single file. It then should be clearer when things are common between different architectures. Patches to the generic file can be made without also having to patch the non-generic files, etc.

A fair number of the #ifdefs are not needed, or are there because some archs don't implement all the features of U-Boot.

You have an example right there: cpu_clk_rate_hz is similar to cpu_clk and core_clk.

That said it is a bit of a daunting task to amalgamate them.

Also there is the purely practical consideration that if we continue to have an asm/global_data.h then we end up with two global datas. One is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all fields. Ick.

Quoted 6 lines
Quoted 1 line

So what do you think?

Do you really need to unify global data to achieve what the title of the patch series suggests (i.e. to unify the init processing loop)? Maybe you could leave global data as is (or slightly tweak the odd arch) and leave the resolution of just how bad global data is becoming for another day

It's not that easy, because in board_f.c and board_r.c and other files there are certain fields required. It doesn't make a huge amount of sense to have generic code which accesses a different global structure depending on what architecture it is built for. Then there are fields are are only used when certain options are defined. Ick.

If I am going to pull this off I need a bit of flexibility. I've looked into this quite a bit and mapped a path through this which I think will work. It requires doing things in stages, or it will never happen.

Quoted 4 lines

I only say this because this is turning into "let's do a dirty hack now to partially fix it and leave the rest for later (it'll get done, really, honestly, I promise)" ;)

It was always like that. Although I wouldn't characterise it as a dirty hack. If there was a requirement to do all of this in one big bang then I wouldn't have even started. It is just too hard :-(

Quoted 5 lines

There will always be arch specific global data members - I see a few options:

?- Move them into bd

I recall talk of getting rid of this (Mike?)

Quoted 1 line

?- Move them into an arch_global_data struct inside gd

This was Mike's idea. It is probably the easiest thing to do.

Quoted 1 line

?- Move them into an arch_global_data struct totally seperate from gd

I sort-of like this except it would slow down access and maybe increase code size. Then again perhaps that's a good thing if it provides an incentive to reduce the number of arch-specific fields.

Quoted 3 lines

?- Question how many are really required to be in gd (remember, gd is ? only there to cart around writable global variable before .bss and ? .data are available after relocation)

Well yes, I feel there are far more at present than are needed. Having them all there in the open feels like a nice way to draw attention to the mess.

Regards,
Simon

Quoted 4 lines

Regards,

Graeme

#9 lore raw

PATCH v4 6/27 ppc: Add initial memory barrier macros

In reply to Simon Glass
Quoted 13 lines · Simon Glass

These are available on other architectures, so add them on ppc.

---

 arch/powerpc/include/asm/io.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/io.h +0 -0
index 56ac9fe..d246fd8 100644

arch/powerpc/include/asm/io.h static inline phys_addr_t virt_to_phys(void * vaddr) · line 327

Quoted 10 lines
arch/powerpc/include/asm/io.h +7 -0
@@ -318,4 +318,12 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
 #endif
 }
 
+/*
+ * TODO: The kernel offers some more advanced versions of barriers, it might
+ * have some advantages to use them instead of the simple one here.
+ */
+#define dmb()		__asm__ __volatile__ ("" : : : "memory")
+#define __iormb()	dmb()
+#define __iowmb()	dmb()

What are the semantics of these (they are not the standard Linux barriers), and how is a simple compiler barrier adequate?

-Scott

#30 lore raw

PATCH v4 14/27 Introduce generic pre-relocation board_f.c

In reply to Simon Glass
Quoted 20 lines · Simon Glass
common/board_f.c new file +20 -0
+/*
+ * sjg: IMO this code should be
+ * refactored to a single function, something like:
+ *
+ * void led_set_state(enum led_colour_t colour, int on);
+ */
+/************************************************************************
+ * Coloured LED functionality
+ ************************************************************************
+ * May be supplied by boards if desired
+ */
+inline void __coloured_LED_init(void) {}
+void coloured_LED_init(void)
+	__attribute__((weak, alias("__coloured_LED_init")));
+inline void __red_led_on(void) {}
+void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
+inline void __red_led_off(void) {}
+void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
+inline void __green_led_on(void) {}
+void green_led_on(void) __attribute__((weak, alias("__green_led_on")));

common/board_f.c line 84

Quoted 10 lines
common/board_f.c new file +10 -0
+inline void __green_led_off(void) {}
+void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
+inline void __yellow_led_on(void) {}
+void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
+inline void __yellow_led_off(void) {}
+void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
+inline void __blue_led_on(void) {}
+void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
+inline void __blue_led_off(void) {}
+void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));

Is this really the right file for this?

Quoted 3 lines

+/*
+ * Why is gd allocated a register? Prior to reloc it might be better to
+ * just pass it around to each function in this file?

You're assuming that this is the only file that needs gd.

Quoted 7 lines
common/board_f.c new file +7 -0
+static int reserve_stacks(void)
+{
+	/* setup stack pointer for exceptions */
+	gd->irq_sp = gd->dest_addr_sp;
+#ifdef CONFIG_USE_IRQ
+	gd->dest_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
+	debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",

common/board_f.c line 361

Quoted 10 lines
common/board_f.c new file +10 -0
+		CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->dest_addr_sp);
+
+	/* 8-byte alignment for ARM ABI compliance */
+	gd->dest_addr_sp &= ~0x07;
+#endif
+	/* leave 3 words for abort-stack, plus 1 for alignment */
+	gd->dest_addr_sp -= 16;
+
+	return 0;
+}

What does "leave 3 words for abort-stack, plus 1 for alignment" mean in a generic context? Certainly we shouldn't have references to things like FIQ or ARM ABI.

Do all architectures U-Boot supports have a stack that grows downward?

PowerPC requires 16-byte stack alignment, not 8-byte.

-Scott

#46 lore raw

PATCH v4 23/27 Adjust board_f for ppc

In reply to Simon Glass
Quoted 1 line · Simon Glass

This adds ppc features to the generic pre-relocation board init.

This is making this file look not very generic. Can we factor out the parts that are actually generic and leave the rest in arch code, rather than create a mess of ifdefs?

-Scott

#36 lore raw

PATCH v4 16/27 Add spl load feature

In reply to Simon Glass

common/board_f.c static int reserve_stacks(void) · line 375

Quoted 9 lines · Simon Glass
common/board_f.c +9 -0
+#ifdef CONFIG_SPL_BUILD
+static int reserve_stacks_spl(void)
+{
+	/* Why not -= ? */
+	gd->dest_addr_sp += 128;	/* leave 32 words for abort-stack */
+	gd->irq_sp = gd->dest_addr_sp;
+	return 0;
+}
+#endif

Please explain what's going on here, and why it's suitable for all (or at least most) SPLs.

And answer your own question about "Why not -=". :-)

-Scott

#31 lore raw

PATCH v4 14/27 Introduce generic pre-relocation board_f.c

In reply to Scott Wood

Hi Scott,

Quoted 25 lines · Scott Wood
Quoted 24 lines · Simon Glass
common/board_f.c new file +24 -0
+/*
+ * sjg: IMO this code should be
+ * refactored to a single function, something like:
+ *
+ * void led_set_state(enum led_colour_t colour, int on);
+ */
+/************************************************************************
+ * Coloured LED functionality
+ ************************************************************************
+ * May be supplied by boards if desired
+ */
+inline void __coloured_LED_init(void) {}
+void coloured_LED_init(void)
+ ? ? __attribute__((weak, alias("__coloured_LED_init")));
+inline void __red_led_on(void) {}
+void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
+inline void __red_led_off(void) {}
+void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
+inline void __green_led_on(void) {}
+void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
+inline void __green_led_off(void) {}
+void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
+inline void __yellow_led_on(void) {}
+void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
Quoted 8 lines

common/board_f.c line 84

Quoted 6 lines
common/board_f.c new file +6 -0
+inline void __yellow_led_off(void) {}
+void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
+inline void __blue_led_on(void) {}
+void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
+inline void __blue_led_off(void) {}
+void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));

Is this really the right file for this?

Not in my opinion, but it comes from arch/arm/lib/board.c, which is why it is here. I have already mentioned my thoughts on this API on the list, and maybe this is something that could be tidied up.

Quoted 6 lines
Quoted 4 lines

+/*
+ * Why is gd allocated a register? Prior to reloc it might be better to
+ * just pass it around to each function in this file?

You're assuming that this is the only file that needs gd.

Not quite - I am wondering whether we should just pass it as an argument whichever file it is in. I think this was in fact discussed on the list and it is better to keep it the way it is. I may look at this later.

Quoted 14 lines
Quoted 14 lines
(quoted diff) +13 -0
+static int reserve_stacks(void)
+{
+ ? ? /* setup stack pointer for exceptions */
+ ? ? gd->irq_sp = gd->dest_addr_sp;
+#ifdef CONFIG_USE_IRQ
+ ? ? gd->dest_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
+ ? ? debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
+ ? ? ? ? ? ? CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->dest_addr_sp);
+
+ ? ? /* 8-byte alignment for ARM ABI compliance */
+ ? ? gd->dest_addr_sp &= ~0x07;
+#endif
+ ? ? /* leave 3 words for abort-stack, plus 1 for alignment */
Quoted 8 lines

common/board_f.c line 105

Quoted 4 lines

+ ? ? gd->dest_addr_sp -= 16;

common/board_f.c new file +3 -0
+
+ ? ? return 0;
+}

What does "leave 3 words for abort-stack, plus 1 for alignment" mean in a generic context? ?Certainly we shouldn't have references to things like FIQ or ARM ABI.

This is limited to code which has CONFIG_USE_IRQ in it. Maybe this function will have to be per-architecture?

Quoted 2 lines

Do all architectures U-Boot supports have a stack that grows downward?

So far I have included ARM, x86 and PowerPC. If we add other archs to generic board init, we will need to look at this.

Quoted 2 lines

PowerPC requires 16-byte stack alignment, not 8-byte.

OK I will update this.

Quoted 3 lines

-Scott

Thanks for reviewing this.

Regards,
Simon

#32 lore raw

PATCH v4 14/27 Introduce generic pre-relocation board_f.c

Quoted 22 lines · Simon Glass
Quoted 13 lines
Quoted 13 lines
common/board_f.c new file +13 -0
+static int reserve_stacks(void)
+{
+     /* setup stack pointer for exceptions */
+     gd->irq_sp = gd->dest_addr_sp;
+#ifdef CONFIG_USE_IRQ
+     gd->dest_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
+     debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
+             CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->dest_addr_sp);
+
+     /* 8-byte alignment for ARM ABI compliance */
+     gd->dest_addr_sp &= ~0x07;
+#endif
+     /* leave 3 words for abort-stack, plus 1 for alignment */
Quoted 8 lines

common/board_f.c line 361

Quoted 4 lines
common/board_f.c new file +4 -0
+     gd->dest_addr_sp -= 16;
+
+     return 0;
+}

What does "leave 3 words for abort-stack, plus 1 for alignment" mean in a generic context? Certainly we shouldn't have references to things like FIQ or ARM ABI.

Quoted 2 lines

This is limited to code which has CONFIG_USE_IRQ in it. Maybe this function will have to be per-architecture?

If CONFIG_USE_IRQ is ARM-specific, perhaps it needs a better name.

Quoted 4 lines
Quoted 1 line

Do all architectures U-Boot supports have a stack that grows downward?

So far I have included ARM, x86 and PowerPC. If we add other archs to generic board init, we will need to look at this.

So it's not so much "generic" as supports more than one architecture.

-Scott

#47 lore raw

PATCH v4 23/27 Adjust board_f for ppc

In reply to Scott Wood

+Graeme

Hi Scott,

Quoted 6 lines · Scott Wood
Quoted 1 line · Simon Glass

This adds ppc features to the generic pre-relocation board init.

This is making this file look not very generic. ?Can we factor out the parts that are actually generic and leave the rest in arch code, rather than create a mess of ifdefs?

Yes that is the plan - Graeme is working on an initcall setup which will make this really easy. For now we have #ifdefs. Bear in mind that most of these were already there in arch/powerpc/lib/board.c.

One other point - one of the reasons that this patch adds so much code is that PPC supports more features than other architectures. In fact I hope that we can make most of those features generic, so that we can remove the PPC #ifdefs and support them for all architectures.

Regards,
Simon

Quoted 3 lines

-Scott

#33 lore raw

PATCH v4 14/27 Introduce generic pre-relocation board_f.c

In reply to Simon Glass

Dear Simon Glass,

Quoted 25 lines · In message <CAPnjgZ1ngBc4SdJbiemQu2znprZ6iwjVRotGMcdVKhdgDSr7tQ@mail.gmail.com>…
Quoted 11 lines

common/board_f.c

Quoted 11 lines
common/board_f.c new file +10 -0
+void coloured_LED_init(void)
+     __attribute__((weak, alias("__coloured_LED_init")));
+inline void __red_led_on(void) {}
+void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
+inline void __red_led_off(void) {}
+void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
+inline void __green_led_on(void) {}
+void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
+inline void __green_led_off(void) {}
+void green_led_off(void) __attribute__((weak, alias("__green_led_off"))=

);

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+inline void __yellow_led_on(void) {}
+void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on"))=

);

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+inline void __yellow_led_off(void) {}
+void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off"=

)));

Quoted 6 lines

common/board_f.c line 84

Quoted 4 lines
common/board_f.c new file +4 -0
+inline void __blue_led_on(void) {}
+void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
+inline void __blue_led_off(void) {}
+void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));

Is this really the right file for this?

Quoted 3 lines

Not in my opinion, but it comes from arch/arm/lib/board.c, which is why it is here. I have already mentioned my thoughts on this API on the list, and maybe this is something that could be tidied up.

s/could/should/

This interface is realy ugly crap, and doesn't scale at all.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

+/*
+ * Why is gd allocated a register? Prior to reloc it might be better to
+ * just pass it around to each function in this file?

You're assuming that this is the only file that needs gd.

Not quite - I am wondering whether we should just pass it as an argument whichever file it is in. I think this was in fact discussed on the list and it is better to keep it the way it is. I may look at this later.

Passing it as arguments will make the code size grow and the code harder to read.

Quoted 6 lines
Quoted 3 lines

What does "leave 3 words for abort-stack, plus 1 for alignment" mean in a generic context? Certainly we shouldn't have references to things like FIQ or ARM ABI.

This is limited to code which has CONFIG_USE_IRQ in it. Maybe this function will have to be per-architecture?

Yes. Eventually only ARM has this.

Best regards,

Wolfgang Denk

Signature · 10 lines
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
The language provides a programmer with a set of conceptual tools; if
these are inadequate for the task, they will simply be  ignored.  For
example, seriously restricting the concept of a pointer simply forces
the  programmer  to use a vector plus integer arithmetic to implement
structures, pointer, etc. Good  design  and  the  absence  of  errors
cannot  be guaranteed by mere language features. - Bjarne Stroustrup,
"The C++ Programming Language"
#52 lore raw

v4 cover Create generic board init for ARM, x86, PPC

In reply to Simon Glass
Quoted 2 lines · Simon Glass

This series creates a generic board.c implementation which contains the essential functions of the major arch/xxx/lib/board.c files.

Let me start by saying that I agree with the premise, please read any inflection/tone as that of someone trying to debug a problem only :)

I'm trying to test this on omap4_panda right now and I'm running into a problem where we hang setting up gd->bd->bi_dram[0]. I don't see why this isn't being set (some quick peeking around and SPL is behaving normally and doing its configure of DRAM and so forth). But I also can't debug this problem as easily as I would like because:
(a) despite DEBUG being defined, none of the debug() prints are printing (my printf's are)
(b) I assume this is because there's so much reconciliation needed still, but the file is an unwieldy mess. In fact, as I'm writing this and debugging at the same time, it seems reserve_board isn't being called, but it's compiled in, in the non-SPL case. I'm not seeing what's up...

Signature · 1 line
Tom
#53 lore raw

v4 cover Create generic board init for ARM, x86, PPC

Hi Tom,

Quoted 7 lines · Tom Rini
Quoted 2 lines · Simon Glass

This series creates a generic board.c implementation which contains the essential functions of the major arch/xxx/lib/board.c files.

Let me start by saying that I agree with the premise, please read any inflection/tone as that of someone trying to debug a problem only :)

Understood :-)

Quoted 8 lines

I'm trying to test this on omap4_panda right now and I'm running into a problem where we hang setting up gd->bd->bi_dram[0]. ?I don't see why this isn't being set (some quick peeking around and SPL is behaving normally and doing its configure of DRAM and so forth). ?But I also can't debug this problem as easily as I would like because:
(a) despite DEBUG being defined, none of the debug() prints are printing (my printf's are)

There is only one macro that affects that - make sure #define DEBUG is above #include common.h or maybe just change them to printf() to work this out...

Quoted 5 lines

(b) I assume this is because there's so much reconciliation needed still, but the file is an unwieldy mess. ?In fact, as I'm writing this and debugging at the same time, it seems reserve_board isn't being called, but it's compiled in, in the non-SPL case. ?I'm not seeing what's up...

I split out the SPL stuff because it wasn't exactly clear to me what was different between SPL and normal start-up. Only recently did I get a board that supports SPL, and I was planning on looking at this soon. I can't give any specific guidance other than persistence and good debug tools :-)

But please do let me know how you get on, and thanks for looking at it. This effort is worthy but not easy.

Regards,
Simon

Quoted 3 lines

--
Tom

#54 lore raw

v4 cover Create generic board init for ARM, x86, PPC

Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 7 lines · Tom Rini
Quoted 2 lines · Simon Glass

This series creates a generic board.c implementation which contains the essential functions of the major arch/xxx/lib/board.c files.

Let me start by saying that I agree with the premise, please read any inflection/tone as that of someone trying to debug a problem only :)

Understood :-)

Quoted 8 lines

I'm trying to test this on omap4_panda right now and I'm running into a problem where we hang setting up gd->bd->bi_dram[0]. ?I don't see why this isn't being set (some quick peeking around and SPL is behaving normally and doing its configure of DRAM and so forth). ?But I also can't debug this problem as easily as I would like because:
(a) despite DEBUG being defined, none of the debug() prints are printing (my printf's are)

Quoted 3 lines

There is only one macro that affects that - make sure #define DEBUG is above #include common.h or maybe just change them to printf() to work this out...

I've gone and changed them to printf's, and a lot of stuff I would expect to see, I don't. On tegra, can you do a before/after debug build and see what board_init_f shows?

Quoted 11 lines
Quoted 5 lines

(b) I assume this is because there's so much reconciliation needed still, but the file is an unwieldy mess. ?In fact, as I'm writing this and debugging at the same time, it seems reserve_board isn't being called, but it's compiled in, in the non-SPL case. ?I'm not seeing what's up...

I split out the SPL stuff because it wasn't exactly clear to me what was different between SPL and normal start-up. Only recently did I get a board that supports SPL, and I was planning on looking at this soon. I can't give any specific guidance other than persistence and good debug tools :-)

Actually, what I'm seeing is more "is this generic or ARM or x86 or PPC code?" There's a lot of that merging that needs doing still and I guess that's part of the mess.

Quoted 2 lines

But please do let me know how you get on, and thanks for looking at it. This effort is worthy but not easy.

I'll post patches for omap4_panda and then hopefully omap3_beagle, or die trying :)

Signature · 1 line
Tom
#55 lore raw

v4 cover Create generic board init for ARM, x86, PPC

Quoted 23 lines · Tom Rini
Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 7 lines · Tom Rini
Quoted 2 lines · Simon Glass

This series creates a generic board.c implementation which contains the essential functions of the major arch/xxx/lib/board.c files.

Let me start by saying that I agree with the premise, please read any inflection/tone as that of someone trying to debug a problem only :)

Understood :-)

Quoted 8 lines

I'm trying to test this on omap4_panda right now and I'm running into a problem where we hang setting up gd->bd->bi_dram[0]. ?I don't see why this isn't being set (some quick peeking around and SPL is behaving normally and doing its configure of DRAM and so forth). ?But I also can't debug this problem as easily as I would like because:
(a) despite DEBUG being defined, none of the debug() prints are printing (my printf's are)

Quoted 7 lines
Quoted 3 lines

There is only one macro that affects that - make sure #define DEBUG is above #include common.h or maybe just change them to printf() to work this out...

I've gone and changed them to printf's, and a lot of stuff I would expect to see, I don't. On tegra, can you do a before/after debug build and see what board_init_f shows?

I've found the problem, but I don't have an easy fix. The problem is we aren't doing things in the same order we used to. We need gd->bd setup before we call setup_dram_config (which is just __dram_init_banksize). This doesn't blow up on Tegra2 as memory starts at 0. That's not true on TI's Cortex-A* parts and we hang :)

So my request for a V5 is to boot with DEBUG enabled and compare CONFIG_SYS_GENERIC_BOARD=y and =n and fix the ordering issues. I suspect this will be complex, or at least a pain due to the unwieldyness I was talking about before of the merged list of calls being so very long and with PPC-specific stuff stuck in (and some ARM and so forth).

Signature · 1 line
Tom
#56 lore raw

v4 cover Create generic board init for ARM, x86, PPC

Hi Tom,

Quoted 32 lines · Tom Rini
Quoted 23 lines · Tom Rini
Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 7 lines · Tom Rini
Quoted 2 lines · Simon Glass

This series creates a generic board.c implementation which contains the essential functions of the major arch/xxx/lib/board.c files.

Let me start by saying that I agree with the premise, please read any inflection/tone as that of someone trying to debug a problem only :)

Understood :-)

Quoted 8 lines

I'm trying to test this on omap4_panda right now and I'm running into a problem where we hang setting up gd->bd->bi_dram[0]. ?I don't see why this isn't being set (some quick peeking around and SPL is behaving normally and doing its configure of DRAM and so forth). ?But I also can't debug this problem as easily as I would like because:
(a) despite DEBUG being defined, none of the debug() prints are printing (my printf's are)

Quoted 7 lines
Quoted 3 lines

There is only one macro that affects that - make sure #define DEBUG is above #include common.h or maybe just change them to printf() to work this out...

I've gone and changed them to printf's, and a lot of stuff I would expect to see, I don't. ?On tegra, can you do a before/after debug build and see what board_init_f shows?

Quoted 5 lines

I've found the problem, but I don't have an easy fix. ?The problem is we aren't doing things in the same order we used to. ?We need gd->bd setup before we call setup_dram_config (which is just __dram_init_banksize). This doesn't blow up on Tegra2 as memory starts at 0. ?That's not true on TI's Cortex-A* parts and we hang :)

Great! Thanks for the info and your efforts on this - much appreciated!

Quoted 6 lines

So my request for a V5 is to boot with DEBUG enabled and compare CONFIG_SYS_GENERIC_BOARD=y and =n and fix the ordering issues. ?I suspect this will be complex, or at least a pain due to the unwieldyness I was talking about before of the merged list of calls being so very long and with PPC-specific stuff stuck in (and some ARM and so forth).

Well I created this by painstakingly comparing the ordering in the different archs and trying to come up with something reasonable. Clearly I got it wrong, but I don't think it's a big job to figure out the error. Hopefully it is not just an incompatibility between the archs.

I will take a look.

Also for DEBUG, can you please tell me which file you added the DEBUG to?

Regards,
Simon

Quoted 3 lines

--
Tom

#57 lore raw

v4 cover Create generic board init for ARM, x86, PPC

Quoted 3 lines · Simon Glass

Hi Tom,

On Fri, Mar 16, 2012 at 2:53 PM, Tom Rini <[email protected]> wrote:

[snip]

Quoted 11 lines
Quoted 5 lines

So my request for a V5 is to boot with DEBUG enabled and compare CONFIG_SYS_GENERIC_BOARD=y and =n and fix the ordering issues. ?I suspect this will be complex, or at least a pain due to the unwieldyness I was talking about before of the merged list of calls being so very long and with PPC-specific stuff stuck in (and some ARM and so forth).

Well I created this by painstakingly comparing the ordering in the different archs and trying to come up with something reasonable. Clearly I got it wrong, but I don't think it's a big job to figure out the error. Hopefully it is not just an incompatibility between the archs.

Yeah. I suspect it'll be easier on you since that code feels like a place that once you've got a lot of mental notes made you can fiddle in quickly.

Quoted 1 line

I will take a look.

k. Hoping v5 is as easy to turn on for omap* as it is for Tegra :)

Quoted 1 line

Also for DEBUG, can you please tell me which file you added the DEBUG to?

include/configs/omap4_common.h since that's where I usually dump that (and it works fine in the old setup).

Signature · 1 line
Tom
#16 lore raw

PATCH v4 7/27 Introduce generic global_data

In reply to Simon Glass

Hi Graeme,

Quoted 82 lines · Simon Glass

Hi Graeme,

Quoted 34 lines · Graeme Russ

Hi Simon,

Quoted 5 lines · Simon Glass

Hi Graeme,

Quoted 2 lines · Graeme Russ

Hi Simon,

[snip]

Quoted 23 lines
Quoted 3 lines

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

My thinking here was to try to bring everything into a single file. It then should be clearer when things are common between different architectures. Patches to the generic file can be made without also having to patch the non-generic files, etc.

A fair number of the #ifdefs are not needed, or are there because some archs don't implement all the features of U-Boot.

You have an example right there: cpu_clk_rate_hz is similar to cpu_clk and core_clk.

That said it is a bit of a daunting task to amalgamate them.

Also there is the purely practical consideration that if we continue to have an asm/global_data.h then we end up with two global datas. One is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all fields. Ick.

Quoted 6 lines
Quoted 1 line

So what do you think?

Do you really need to unify global data to achieve what the title of the patch series suggests (i.e. to unify the init processing loop)? Maybe you could leave global data as is (or slightly tweak the odd arch) and leave the resolution of just how bad global data is becoming for another day

It's not that easy, because in board_f.c and board_r.c and other files there are certain fields required. It doesn't make a huge amount of sense to have generic code which accesses a different global structure depending on what architecture it is built for. Then there are fields are are only used when certain options are defined. Ick.

If I am going to pull this off I need a bit of flexibility. I've looked into this quite a bit and mapped a path through this which I think will work. It requires doing things in stages, or it will never happen.

Quoted 4 lines

I only say this because this is turning into "let's do a dirty hack now to partially fix it and leave the rest for later (it'll get done, really, honestly, I promise)" ;)

It was always like that. Although I wouldn't characterise it as a dirty hack. If there was a requirement to do all of this in one big bang then I wouldn't have even started. It is just too hard :-(

Quoted 5 lines

There will always be arch specific global data members - I see a few options:

?- Move them into bd

I recall talk of getting rid of this (Mike?)

Quoted 1 line

?- Move them into an arch_global_data struct inside gd

This was Mike's idea. It is probably the easiest thing to do.

Quoted 1 line

?- Move them into an arch_global_data struct totally seperate from gd

I sort-of like this except it would slow down access and maybe increase code size. Then again perhaps that's a good thing if it provides an incentive to reduce the number of arch-specific fields.

Quoted 7 lines
Quoted 3 lines

?- Question how many are really required to be in gd (remember, gd is ? only there to cart around writable global variable before .bss and ? .data are available after relocation)

Well yes, I feel there are far more at present than are needed. Having them all there in the open feels like a nice way to draw attention to the mess.

Any more comments on this thread? At this stage I am still not sure of the best approach for this header...none of the options is particularly attractive. I can imagine something horrible like:

struct global_data {
<common fields>
...
#include <asm/arch_global_data.h>
};

which would be the smallest code change (essentially no accesses would need to change). But it is too awful.

Of course I have a generic bd structure now, so moving things into there doesn't fix the problem.

So if I rewind back to your first suggestion (just leave global-data and bd as they are now), then I have the problem that I need to add quite a bit of stuff to these structures for every architecture. This is because at present most architectures don't support all the features, and so don't need all the fields. As soon as I have generic C code, I have references in that C code to global data members that only exist for some architectures. Then someone enables CONFIG_SPI, and breaks the board on the architecture that didn't previously have SPI support. I wonder if that matters?

It sort-off seems attractive from the 'less work' point of view, and is a stepping stone along the way, though.

Just to repeat your other ideas:

Quoted 6 lines

- Move them into bd
- Move them into an arch_global_data struct inside gd
- Move them into an arch_global_data struct totally seperate from gd
- Question how many are really required to be in gd (remember, gd is only there to cart around writable global variable before .bss and .data are available after relocation)

(I feel the last one has to come later, though, even if unfortunately it would simplify things now - how on earth are we going to work out what things are really needed in global data?)

Regards,
Simon

#17 lore raw

PATCH v4 7/27 Introduce generic global_data

Hi Simon,

Quoted 97 lines · Simon Glass

Hi Graeme,

Quoted 82 lines · Simon Glass

Hi Graeme,

Quoted 34 lines · Graeme Russ

Hi Simon,

Quoted 5 lines · Simon Glass

Hi Graeme,

Quoted 2 lines · Graeme Russ

Hi Simon,

[snip]

Quoted 23 lines
Quoted 3 lines

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

My thinking here was to try to bring everything into a single file. It then should be clearer when things are common between different architectures. Patches to the generic file can be made without also having to patch the non-generic files, etc.

A fair number of the #ifdefs are not needed, or are there because some archs don't implement all the features of U-Boot.

You have an example right there: cpu_clk_rate_hz is similar to cpu_clk and core_clk.

That said it is a bit of a daunting task to amalgamate them.

Also there is the purely practical consideration that if we continue to have an asm/global_data.h then we end up with two global datas. One is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all fields. Ick.

Quoted 6 lines
Quoted 1 line

So what do you think?

Do you really need to unify global data to achieve what the title of the patch series suggests (i.e. to unify the init processing loop)? Maybe you could leave global data as is (or slightly tweak the odd arch) and leave the resolution of just how bad global data is becoming for another day

It's not that easy, because in board_f.c and board_r.c and other files there are certain fields required. It doesn't make a huge amount of sense to have generic code which accesses a different global structure depending on what architecture it is built for. Then there are fields are are only used when certain options are defined. Ick.

If I am going to pull this off I need a bit of flexibility. I've looked into this quite a bit and mapped a path through this which I think will work. It requires doing things in stages, or it will never happen.

Quoted 4 lines

I only say this because this is turning into "let's do a dirty hack now to partially fix it and leave the rest for later (it'll get done, really, honestly, I promise)" ;)

It was always like that. Although I wouldn't characterise it as a dirty hack. If there was a requirement to do all of this in one big bang then I wouldn't have even started. It is just too hard :-(

Quoted 5 lines

There will always be arch specific global data members - I see a few options:

- Move them into bd

I recall talk of getting rid of this (Mike?)

Quoted 1 line

- Move them into an arch_global_data struct inside gd

This was Mike's idea. It is probably the easiest thing to do.

Quoted 1 line

- Move them into an arch_global_data struct totally seperate from gd

I sort-of like this except it would slow down access and maybe increase code size. Then again perhaps that's a good thing if it provides an incentive to reduce the number of arch-specific fields.

Quoted 7 lines
Quoted 3 lines

- Question how many are really required to be in gd (remember, gd is only there to cart around writable global variable before .bss and .data are available after relocation)

Well yes, I feel there are far more at present than are needed. Having them all there in the open feels like a nice way to draw attention to the mess.

Any more comments on this thread? At this stage I am still not sure of the best approach for this header...none of the options is particularly attractive. I can imagine something horrible like:

Quoted 5 lines
struct global_data {
   <common fields>
   ...

#include <asm/arch_global_data.h>
};

Ick! - NAK NAK NAK NAK ;)

Quoted 17 lines

which would be the smallest code change (essentially no accesses would need to change). But it is too awful.

Of course I have a generic bd structure now, so moving things into there doesn't fix the problem.

So if I rewind back to your first suggestion (just leave global-data and bd as they are now), then I have the problem that I need to add quite a bit of stuff to these structures for every architecture. This is because at present most architectures don't support all the features, and so don't need all the fields. As soon as I have generic C code, I have references in that C code to global data members that only exist for some architectures. Then someone enables CONFIG_SPI, and breaks the board on the architecture that didn't previously have SPI support. I wonder if that matters?

Quoted 11 lines

It sort-off seems attractive from the 'less work' point of view, and is a stepping stone along the way, though.

Just to repeat your other ideas:

Quoted 6 lines

- Move them into bd
- Move them into an arch_global_data struct inside gd
- Move them into an arch_global_data struct totally seperate from gd
- Question how many are really required to be in gd (remember, gd is only there to cart around writable global variable before .bss and .data are available after relocation)

IIRC the Linux driver model includes a pointer to non-generic driver specific data which only the driver knows what to do with (the framework ignores it)
If struct global_data has struct arch_global_data *agd in gd - Means a lot of changing of accessors and maybe a little code increase and slight access penalty (and maybe changes to asm startup code to handle the creation of gd plus agd and setting the pointer)

But that would be way cleaner for stuct global_data

Having agd in gd is probably a lot easier as the auto-generated gd size will be good to use

Hmmm..

arch/asm/global_data.h:

#define HAS_ARCH_GD

struct arch_global_data {
	...
};

include/global_data.h:

#include <arch/asm/global_data.h>

struct global_data {
	...
#ifdef HAS_ARCH_GD
	struct arch_global_data agd;

#endif
};

I like this better

P.S. Can we ditch the typedef while we are at it?

Q: Are there any board specific global data members anywhere?

Quoted 4 lines

(I feel the last one has to come later, though, even if unfortunately it would simplify things now - how on earth are we going to work out what things are really needed in global data?)

Look at the functions which are called prior to relocation - Anything referenced in these functions needs to be in gd

Regards,

Graeme

#18 lore raw

PATCH v4 7/27 Introduce generic global_data

Hi Graeme,

Quoted 100 lines · Graeme Russ

Hi Simon,

Quoted 97 lines · Simon Glass

Hi Graeme,

Quoted 82 lines · Simon Glass

Hi Graeme,

Quoted 34 lines · Graeme Russ

Hi Simon,

Quoted 5 lines · Simon Glass

Hi Graeme,

Quoted 2 lines · Graeme Russ

Hi Simon,

[snip]

Quoted 23 lines
Quoted 3 lines

IMHO, global data should contain only globally common members and an arch- specific struct and ditch (most of) the #ifdefs

My thinking here was to try to bring everything into a single file. It then should be clearer when things are common between different architectures. Patches to the generic file can be made without also having to patch the non-generic files, etc.

A fair number of the #ifdefs are not needed, or are there because some archs don't implement all the features of U-Boot.

You have an example right there: cpu_clk_rate_hz is similar to cpu_clk and core_clk.

That said it is a bit of a daunting task to amalgamate them.

Also there is the purely practical consideration that if we continue to have an asm/global_data.h then we end up with two global datas. One is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all fields. Ick.

Quoted 6 lines
Quoted 1 line

So what do you think?

Do you really need to unify global data to achieve what the title of the patch series suggests (i.e. to unify the init processing loop)? Maybe you could leave global data as is (or slightly tweak the odd arch) and leave the resolution of just how bad global data is becoming for another day

It's not that easy, because in board_f.c and board_r.c and other files there are certain fields required. It doesn't make a huge amount of sense to have generic code which accesses a different global structure depending on what architecture it is built for. Then there are fields are are only used when certain options are defined. Ick.

If I am going to pull this off I need a bit of flexibility. I've looked into this quite a bit and mapped a path through this which I think will work. It requires doing things in stages, or it will never happen.

Quoted 4 lines

I only say this because this is turning into "let's do a dirty hack now to partially fix it and leave the rest for later (it'll get done, really, honestly, I promise)" ;)

It was always like that. Although I wouldn't characterise it as a dirty hack. If there was a requirement to do all of this in one big bang then I wouldn't have even started. It is just too hard :-(

Quoted 5 lines

There will always be arch specific global data members - I see a few options:

?- Move them into bd

I recall talk of getting rid of this (Mike?)

Quoted 1 line

?- Move them into an arch_global_data struct inside gd

This was Mike's idea. It is probably the easiest thing to do.

Quoted 1 line

?- Move them into an arch_global_data struct totally seperate from gd

I sort-of like this except it would slow down access and maybe increase code size. Then again perhaps that's a good thing if it provides an incentive to reduce the number of arch-specific fields.

Quoted 7 lines
Quoted 3 lines

?- Question how many are really required to be in gd (remember, gd is ? only there to cart around writable global variable before .bss and ? .data are available after relocation)

Well yes, I feel there are far more at present than are needed. Having them all there in the open feels like a nice way to draw attention to the mess.

Any more comments on this thread? At this stage I am still not sure of the best approach for this header...none of the options is particularly attractive. I can imagine something horrible like:

Quoted 7 lines
Quoted 5 lines

struct global_data {
? ?<common fields>
? ?...
#include <asm/arch_global_data.h>
};

Ick! - NAK NAK NAK NAK ;)

You surprise me :-)

Quoted 65 lines
Quoted 18 lines

which would be the smallest code change (essentially no accesses would need to change). But it is too awful.

Of course I have a generic bd structure now, so moving things into there doesn't fix the problem.

So if I rewind back to your first suggestion (just leave global-data and bd as they are now), then I have the problem that I need to add quite a bit of stuff to these structures for every architecture. This is because at present most architectures don't support all the features, and so don't need all the fields. As soon as I have generic C code, I have references in that C code to global data members that only exist for some architectures. Then someone enables CONFIG_SPI, and breaks the board on the architecture that didn't previously have SPI support. I wonder if that matters?

Quoted 11 lines

It sort-off seems attractive from the 'less work' point of view, and is a stepping stone along the way, though.

Just to repeat your other ideas:

Quoted 6 lines

?- Move them into bd
?- Move them into an arch_global_data struct inside gd
?- Move them into an arch_global_data struct totally seperate from gd ?- Question how many are really required to be in gd (remember, gd is ? only there to cart around writable global variable before .bss and ? .data are available after relocation)

IIRC the Linux driver model includes a pointer to non-generic driver specific data which only the driver knows what to do with (the framework ignores it)
If struct global_data has struct arch_global_data *agd in gd - Means a lot of changing of accessors and maybe a little code increase and slight access penalty (and maybe changes to asm startup code to handle the creation of gd plus agd and setting the pointer)

But that would be way cleaner for stuct global_data

Having agd in gd is probably a lot easier as the auto-generated gd size will be good to use

Hmmm..

arch/asm/global_data.h:

#define HAS_ARCH_GD

struct arch_global_data {
? ? ? ?...
};

include/global_data.h:

#include <arch/asm/global_data.h>

struct global_data {
? ? ? ?...
#ifdef HAS_ARCH_GD
? ? ? ?struct arch_global_data agd;
#endif
};

Quoted 3 lines

I like this better

P.S. Can we ditch the typedef while we are at it?

Separate issue, but I can't see why not.

But I now remember the main problem I had with this. CONFIG_SYS_GENERIC_BOARD is an option, not mandatory, so we must not change the C code (much, ideally not at all) to make this work. If we move things around as you suggest then we should probably do it first as part of the normal code, so that generic board can just use it.

So the first change might be to move arch-specific data into an agd structure, and get everything building again. Then finally pull out the common part of each file into a new asm-generic file. It's the opposite way to what I have done so far, but the result will be the same in the end. I suppose my only reservation is that it creates patches initially for little benefit. I will have to think about how to motivate it.

Quoted 2 lines

Q: Are there any board specific global data members anywhere?

Probably, if we went into a deep enough. Certainly there are members which are only used for one sub-archs, and some of those sub-archs have a very small number of boards, perhaps 1 in some cases.

Quoted 8 lines
Quoted 5 lines

(I feel the last one has to come later, though, even if unfortunately it would simplify things now - how on earth are we going to work out what things are really needed in global data?)

Look at the functions which are called prior to relocation - Anything referenced in these functions needs to be in gd

Yes, but I'm just saying that is a long list, and involves a lot of code searching.

Quoted 5 lines

Regards,

Graeme

Regards,
Simon

#19 lore raw

PATCH v4 7/27 Introduce generic global_data

Hi Simon,

Quoted 5 lines · Simon Glass

Hi Graeme,

Quoted 2 lines · Graeme Russ

Hi Simon,

[snip]

Quoted 21 lines
Quoted 21 lines

arch/asm/global_data.h:

#define HAS_ARCH_GD

struct arch_global_data {
       ...
};

include/global_data.h:

#include <arch/asm/global_data.h>

struct global_data {
       ...
#ifdef HAS_ARCH_GD
       struct arch_global_data agd;

#endif
};

Quoted 5 lines
Quoted 3 lines

I like this better

P.S. Can we ditch the typedef while we are at it?

Separate issue, but I can't see why not.

OK - See below

Quoted 5 lines

But I now remember the main problem I had with this. CONFIG_SYS_GENERIC_BOARD is an option, not mandatory, so we must not change the C code (much, ideally not at all) to make this work. If we move things around as you suggest then we should probably do it first as part of the normal code, so that generic board can just use it.

Sounds like a solid plan

Quoted 7 lines

So the first change might be to move arch-specific data into an agd structure, and get everything building again. Then finally pull out the common part of each file into a new asm-generic file. It's the opposite way to what I have done so far, but the result will be the same in the end. I suppose my only reservation is that it creates patches initially for little benefit. I will have to think about how to motivate it.

Clean-up work that, on the surface, appears to not do much does much more than you think. It may highlight a few nasty quibbles that you hadn't expected that you will need to plan around.

Big changes made against good, clean, consistent code are always easier than against bad, dirty, inconsistent code :)

And I think this is the ideal opportunity to drop the typedef

Quoted 5 lines
Quoted 1 line

Q: Are there any board specific global data members anywhere?

Probably, if we went into a deep enough. Certainly there are members which are only used for one sub-archs, and some of those sub-archs have a very small number of boards, perhaps 1 in some cases.

OK, it might be worth investigating HAS_BOARD_GD. Maybe bring that through struct arch_global_data but it's not as clear an issue (there is a symlink to include/arch/asm but none for include/board/. For the time being, we may just have to leave the ifdefs in the include/arch/asm/global_data.h

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

(I feel the last one has to come later, though, even if unfortunately it would simplify things now - how on earth are we going to work out what things are really needed in global data?)

Look at the functions which are called prior to relocation - Anything referenced in these functions needs to be in gd

Yes, but I'm just saying that is a long list, and involves a lot of code searching.

I didn't say it would be easy ;)

The board_init_f array is a starting point.

I was planning on moving pre-relocation functions into a .init section so they were not copied during code relocation (much like Linux marks init functions so the memory can be free'd post init). Once this is done, identifying 'real' global data members will be trivial

Regards,

Graeme