[U-Boot] Common arch-specific header files for SOCs

Hi,
I am looking at generalizing Tegra20 to support other Tegra parts. I can easily create
arch/arm/cpu/armv7/tegra-common
and I see that this is done for OMAP and Samsung with this little fragment in the Makefile:
ifeq ($(SOC),omap3) LIBS += $(CPUDIR)/omap-common/libomap-common.o endif ifeq ($(SOC),omap4) LIBS += $(CPUDIR)/omap-common/libomap-common.o endif
ifeq ($(SOC),s5pc1xx) LIBS += $(CPUDIR)/s5p-common/libs5p-common.o endif ifeq ($(SOC),s5pc2xx) LIBS += $(CPUDIR)/s5p-common/libs5p-common.o endif
Not a long term solution with dozens of SOCs, but fine for now.
But I also have common header files and it isn't so clear what to do there.
The arch/arm/include/asm/arch symlink needs to point to arch-tegra2 in my case, which is fine, but I also want to be able to include common files.
#include <asm/arch/clock.h>
This points to arch/arm/include/asm/arch-tegra2/clock.h but this would not be available from a tegra3 architecture, for example.
One solution is a symlink inside arch-tegra2 to what is effectively arch/arm/include/asm/tegra-common
and then add this path to the flags somehow. Then I can do, in both tegra2 and tegra3 code:
#include <asm/arch/common/clock.h>
Any other suggestions? It almost feels like we need an 'SOC family' field in boards.cfg (as distinct from SOC). Then we could perhaps have this work automatically.
Regards, Simon

On Tuesday, August 30, 2011 17:13:51 Simon Glass wrote:
The arch/arm/include/asm/arch symlink needs to point to arch-tegra2 in my case, which is fine, but I also want to be able to include common files.
#include <asm/arch/clock.h>
This points to arch/arm/include/asm/arch-tegra2/clock.h but this would not be available from a tegra3 architecture, for example.
$ cat arch/arm/include/asm/arch-tegra3/clock.h #include <asm/arch-tegra2/clock.h>
Any other suggestions? It almost feels like we need an 'SOC family' field in boards.cfg (as distinct from SOC). Then we could perhaps have this work automatically.
maybe create asm/arch-tegra/ for the common stuff and have the other tegras include that for common stuff ? -mike

Hi Mike,
On Tue, Aug 30, 2011 at 9:36 PM, Mike Frysinger vapier@gentoo.org wrote:
On Tuesday, August 30, 2011 17:13:51 Simon Glass wrote:
The arch/arm/include/asm/arch symlink needs to point to arch-tegra2 in my case, which is fine, but I also want to be able to include common files.
#include <asm/arch/clock.h>
This points to arch/arm/include/asm/arch-tegra2/clock.h but this would not be available from a tegra3 architecture, for example.
$ cat arch/arm/include/asm/arch-tegra3/clock.h #include <asm/arch-tegra2/clock.h>
Any other suggestions? It almost feels like we need an 'SOC family' field in boards.cfg (as distinct from SOC). Then we could perhaps have this work automatically.
maybe create asm/arch-tegra/ for the common stuff and have the other tegras include that for common stuff ?
That sort-of works. My concern is when drivers start doing
#include <asm/arch-tegra/clock.h>
Doesn't that break the rule that architecture should be set at config time? Not that it matters much I suppose, since the only drivers including this file are architecture-specific.
?
Regards, Simon
-mike

On Wednesday, August 31, 2011 01:30:56 Simon Glass wrote:
On Tue, Aug 30, 2011 at 9:36 PM, Mike Frysinger wrote:
On Tuesday, August 30, 2011 17:13:51 Simon Glass wrote:
The arch/arm/include/asm/arch symlink needs to point to arch-tegra2 in my case, which is fine, but I also want to be able to include common files.
#include <asm/arch/clock.h>
This points to arch/arm/include/asm/arch-tegra2/clock.h but this would not be available from a tegra3 architecture, for example.
$ cat arch/arm/include/asm/arch-tegra3/clock.h #include <asm/arch-tegra2/clock.h>
Any other suggestions? It almost feels like we need an 'SOC family' field in boards.cfg (as distinct from SOC). Then we could perhaps have this work automatically.
maybe create asm/arch-tegra/ for the common stuff and have the other tegras include that for common stuff ?
That sort-of works. My concern is when drivers start doing
#include <asm/arch-tegra/clock.h>
Doesn't that break the rule that architecture should be set at config time? Not that it matters much I suppose, since the only drivers including this file are architecture-specific.
the driver is broken then ? :)
easy to catch this ala bits/ C library headers: arch-tegra2/clock.h: #ifndef _ARCH_TEGRA_CLOCK_H_ #define _ARCH_TEGRA_CLOCK_H_ ... #include <asm/arch-tegra/clock.h> ... #endif
arch-tegra3/clock.h: #ifndef _ARCH_TEGRA_CLOCK_H_ #define _ARCH_TEGRA_CLOCK_H_ ... #include <asm/arch-tegra/clock.h> ... #endif
asm/arch-tegra/clock.h: #ifndef _ARCH_TEGRA_CLOCK_H_ # error "do not include this header directly" #endif #ifndef _ARCH_TEGRA_COMMON_CLOCK_H_ #define _ARCH_TEGRA_COMMON_CLOCK_H_ ... #endif -mike

Hi Mike,
On Wed, Aug 31, 2011 at 7:44 AM, Mike Frysinger vapier@gentoo.org wrote:
On Wednesday, August 31, 2011 01:30:56 Simon Glass wrote:
On Tue, Aug 30, 2011 at 9:36 PM, Mike Frysinger wrote:
On Tuesday, August 30, 2011 17:13:51 Simon Glass wrote:
The arch/arm/include/asm/arch symlink needs to point to arch-tegra2 in my case, which is fine, but I also want to be able to include common files.
#include <asm/arch/clock.h>
This points to arch/arm/include/asm/arch-tegra2/clock.h but this would not be available from a tegra3 architecture, for example.
$ cat arch/arm/include/asm/arch-tegra3/clock.h #include <asm/arch-tegra2/clock.h>
Any other suggestions? It almost feels like we need an 'SOC family' field in boards.cfg (as distinct from SOC). Then we could perhaps have this work automatically.
maybe create asm/arch-tegra/ for the common stuff and have the other tegras include that for common stuff ?
That sort-of works. My concern is when drivers start doing
#include <asm/arch-tegra/clock.h>
Doesn't that break the rule that architecture should be set at config time? Not that it matters much I suppose, since the only drivers including this file are architecture-specific.
the driver is broken then ? :)
easy to catch this ala bits/ C library headers: arch-tegra2/clock.h: #ifndef _ARCH_TEGRA_CLOCK_H_ #define _ARCH_TEGRA_CLOCK_H_ ... #include <asm/arch-tegra/clock.h> ... #endif
arch-tegra3/clock.h: #ifndef _ARCH_TEGRA_CLOCK_H_ #define _ARCH_TEGRA_CLOCK_H_ ... #include <asm/arch-tegra/clock.h> ... #endif
asm/arch-tegra/clock.h: #ifndef _ARCH_TEGRA_CLOCK_H_ # error "do not include this header directly" #endif #ifndef _ARCH_TEGRA_COMMON_CLOCK_H_ #define _ARCH_TEGRA_COMMON_CLOCK_H_ ... #endif -mike
Thank you. I have gone with having
asm/arch-tegra/clock.h
for the generic stuff and
asm/arch-tegra2/clock.h, asm/arch-tegra3/clock.h
which include that. It seems to work ok.
Regards, Simon
participants (2)
-
Mike Frysinger
-
Simon Glass