Message ID | 20190724143911.29770-3-andrei@balena.io |
---|---|
State | Accepted |
Commit | 1cfac5204c5f4128072878653c6e36336f5cd488 |
Delegated to: | Matthias Brugger |
Headers | show |
Series | Raspberry Pi 32/64 support | expand |
On 24.07.19 16:39, Andrei Gherzan wrote: > From: Matthias Brugger <mbrugger@suse.com> > > Devices of bcm283x have different base address, depending if they are on > bcm2835 or bcm2836/7. Use BCM283x_BASE depending on the SoC you want to > build and only add the offset in the header files. > > Signed-off-by: Matthias Brugger <mbrugger@suse.com> > Signed-off-by: Andrei Gherzan <andrei@balena.io> > --- > arch/arm/mach-bcm283x/Kconfig | 5 +++++ > arch/arm/mach-bcm283x/include/mach/mbox.h | 6 +----- > arch/arm/mach-bcm283x/include/mach/sdhci.h | 6 +----- > arch/arm/mach-bcm283x/include/mach/timer.h | 6 +----- > arch/arm/mach-bcm283x/include/mach/wdog.h | 6 +----- > 5 files changed, 9 insertions(+), 20 deletions(-) > > diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig > index 3eb5a9a897..8e69914a83 100644 > --- a/arch/arm/mach-bcm283x/Kconfig > +++ b/arch/arm/mach-bcm283x/Kconfig > @@ -141,4 +141,9 @@ config SYS_SOC > config SYS_CONFIG_NAME > default "rpi" > > +config BCM283x_BASE > + hex > + default "0x20000000" if BCM2835 > + default "0x3f000000" if BCM2836 || BCM2837 How hard would it be to make the base a global variable instead and just set it early on board init based on the FDT or maybe even CPU core revision registers? That would allow us to support RPi3 & 4 with the same U-Boot binary. Alex
On 26.07.19 13:55, Matthias Brugger wrote: > > > On 26/07/2019 13:16, Alexander Graf wrote: >> >> >> On 24.07.19 16:39, Andrei Gherzan wrote: >>> From: Matthias Brugger <mbrugger@suse.com> >>> >>> Devices of bcm283x have different base address, depending if they are on >>> bcm2835 or bcm2836/7. Use BCM283x_BASE depending on the SoC you want to >>> build and only add the offset in the header files. >>> >>> Signed-off-by: Matthias Brugger <mbrugger@suse.com> >>> Signed-off-by: Andrei Gherzan <andrei@balena.io> >>> --- >>> arch/arm/mach-bcm283x/Kconfig | 5 +++++ >>> arch/arm/mach-bcm283x/include/mach/mbox.h | 6 +----- >>> arch/arm/mach-bcm283x/include/mach/sdhci.h | 6 +----- >>> arch/arm/mach-bcm283x/include/mach/timer.h | 6 +----- >>> arch/arm/mach-bcm283x/include/mach/wdog.h | 6 +----- >>> 5 files changed, 9 insertions(+), 20 deletions(-) >>> >>> diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig >>> index 3eb5a9a897..8e69914a83 100644 >>> --- a/arch/arm/mach-bcm283x/Kconfig >>> +++ b/arch/arm/mach-bcm283x/Kconfig >>> @@ -141,4 +141,9 @@ config SYS_SOC >>> config SYS_CONFIG_NAME >>> default "rpi" >>> +config BCM283x_BASE >>> + hex >>> + default "0x20000000" if BCM2835 >>> + default "0x3f000000" if BCM2836 || BCM2837 >> >> How hard would it be to make the base a global variable instead and just set it >> early on board init based on the FDT or maybe even CPU core revision registers? > > Might be possible. Candidates to implement this are board_early_init_f or > misc_init_f, I think. > >> >> That would allow us to support RPi3 & 4 with the same U-Boot binary. > > Good point :) Yeah, then you only need to do the memory map dynamically as well and the rest should all be handled by DT :). Which again means you don't need a new config target at all! Alex
Hi, On 26/07/2019 13.04, Alexander Graf wrote: > > > On 26.07.19 13:55, Matthias Brugger wrote: >> >> >> On 26/07/2019 13:16, Alexander Graf wrote: >>> >>> >>> On 24.07.19 16:39, Andrei Gherzan wrote: >>>> From: Matthias Brugger <mbrugger@suse.com> >>>> >>>> Devices of bcm283x have different base address, depending if they >>>> are on >>>> bcm2835 or bcm2836/7. Use BCM283x_BASE depending on the SoC you >>>> want to >>>> build and only add the offset in the header files. >>>> >>>> Signed-off-by: Matthias Brugger <mbrugger@suse.com> >>>> Signed-off-by: Andrei Gherzan <andrei@balena.io> >>>> --- >>>> arch/arm/mach-bcm283x/Kconfig | 5 +++++ >>>> arch/arm/mach-bcm283x/include/mach/mbox.h | 6 +----- >>>> arch/arm/mach-bcm283x/include/mach/sdhci.h | 6 +----- >>>> arch/arm/mach-bcm283x/include/mach/timer.h | 6 +----- >>>> arch/arm/mach-bcm283x/include/mach/wdog.h | 6 +----- >>>> 5 files changed, 9 insertions(+), 20 deletions(-) >>>> >>>> diff --git a/arch/arm/mach-bcm283x/Kconfig >>>> b/arch/arm/mach-bcm283x/Kconfig >>>> index 3eb5a9a897..8e69914a83 100644 >>>> --- a/arch/arm/mach-bcm283x/Kconfig >>>> +++ b/arch/arm/mach-bcm283x/Kconfig >>>> @@ -141,4 +141,9 @@ config SYS_SOC >>>> config SYS_CONFIG_NAME >>>> default "rpi" >>>> +config BCM283x_BASE >>>> + hex >>>> + default "0x20000000" if BCM2835 >>>> + default "0x3f000000" if BCM2836 || BCM2837 >>> >>> How hard would it be to make the base a global variable instead and >>> just set it >>> early on board init based on the FDT or maybe even CPU core revision >>> registers? >> >> Might be possible. Candidates to implement this are >> board_early_init_f or >> misc_init_f, I think. >> >>> >>> That would allow us to support RPi3 & 4 with the same U-Boot binary. >> >> Good point :) > > Yeah, then you only need to do the memory map dynamically as well and > the rest should all be handled by DT :). Which again means you don't > need a new config target at all! I like that. It will bring a little confusion though when using a rpi3 defconfig for rpi4. I guess we could just copy it.
On 26/07/2019 14:43, Andrei Gherzan wrote: > Hi, > > On 26/07/2019 13.04, Alexander Graf wrote: >> >> >> On 26.07.19 13:55, Matthias Brugger wrote: >>> >>> >>> On 26/07/2019 13:16, Alexander Graf wrote: >>>> >>>> >>>> On 24.07.19 16:39, Andrei Gherzan wrote: >>>>> From: Matthias Brugger <mbrugger@suse.com> >>>>> >>>>> Devices of bcm283x have different base address, depending if they >>>>> are on >>>>> bcm2835 or bcm2836/7. Use BCM283x_BASE depending on the SoC you >>>>> want to >>>>> build and only add the offset in the header files. >>>>> >>>>> Signed-off-by: Matthias Brugger <mbrugger@suse.com> >>>>> Signed-off-by: Andrei Gherzan <andrei@balena.io> >>>>> --- >>>>> arch/arm/mach-bcm283x/Kconfig | 5 +++++ >>>>> arch/arm/mach-bcm283x/include/mach/mbox.h | 6 +----- >>>>> arch/arm/mach-bcm283x/include/mach/sdhci.h | 6 +----- >>>>> arch/arm/mach-bcm283x/include/mach/timer.h | 6 +----- >>>>> arch/arm/mach-bcm283x/include/mach/wdog.h | 6 +----- >>>>> 5 files changed, 9 insertions(+), 20 deletions(-) >>>>> >>>>> diff --git a/arch/arm/mach-bcm283x/Kconfig >>>>> b/arch/arm/mach-bcm283x/Kconfig >>>>> index 3eb5a9a897..8e69914a83 100644 >>>>> --- a/arch/arm/mach-bcm283x/Kconfig >>>>> +++ b/arch/arm/mach-bcm283x/Kconfig >>>>> @@ -141,4 +141,9 @@ config SYS_SOC >>>>> config SYS_CONFIG_NAME >>>>> default "rpi" >>>>> +config BCM283x_BASE >>>>> + hex >>>>> + default "0x20000000" if BCM2835 >>>>> + default "0x3f000000" if BCM2836 || BCM2837 >>>> >>>> How hard would it be to make the base a global variable instead and >>>> just set it >>>> early on board init based on the FDT or maybe even CPU core revision >>>> registers? >>> >>> Might be possible. Candidates to implement this are >>> board_early_init_f or >>> misc_init_f, I think. >>> >>>> >>>> That would allow us to support RPi3 & 4 with the same U-Boot binary. >>> >>> Good point :) >> >> Yeah, then you only need to do the memory map dynamically as well and >> the rest should all be handled by DT :). Which again means you don't >> need a new config target at all! > I like that. It will bring a little confusion though when using a rpi3 > defconfig for rpi4. I guess we could just copy it. > I have a working POC of this feature, but it needs more time. I propose to merge RPi4 support now, so that it can get accepted for v2019.10. Afterwards we can implement a unified u-boot binary for RPi[34] and maybe even RPi[12] in the future. If nobody shouts I'll merge this series fixing the two comments I had. Please let me know if you disagree. Regards, Matthias
diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig index 3eb5a9a897..8e69914a83 100644 --- a/arch/arm/mach-bcm283x/Kconfig +++ b/arch/arm/mach-bcm283x/Kconfig @@ -141,4 +141,9 @@ config SYS_SOC config SYS_CONFIG_NAME default "rpi" +config BCM283x_BASE + hex + default "0x20000000" if BCM2835 + default "0x3f000000" if BCM2836 || BCM2837 + endmenu diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h index e3a893e49c..e44c7577da 100644 --- a/arch/arm/mach-bcm283x/include/mach/mbox.h +++ b/arch/arm/mach-bcm283x/include/mach/mbox.h @@ -37,11 +37,7 @@ /* Raw mailbox HW */ -#ifndef CONFIG_BCM2835 -#define BCM2835_MBOX_PHYSADDR 0x3f00b880 -#else -#define BCM2835_MBOX_PHYSADDR 0x2000b880 -#endif +#define BCM2835_MBOX_PHYSADDR (CONFIG_BCM283x_BASE + 0x0000b880) struct bcm2835_mbox_regs { u32 read; diff --git a/arch/arm/mach-bcm283x/include/mach/sdhci.h b/arch/arm/mach-bcm283x/include/mach/sdhci.h index 5cb6ec3340..b443c379d8 100644 --- a/arch/arm/mach-bcm283x/include/mach/sdhci.h +++ b/arch/arm/mach-bcm283x/include/mach/sdhci.h @@ -6,11 +6,7 @@ #ifndef _BCM2835_SDHCI_H_ #define _BCM2835_SDHCI_H_ -#ifndef CONFIG_BCM2835 -#define BCM2835_SDHCI_BASE 0x3f300000 -#else -#define BCM2835_SDHCI_BASE 0x20300000 -#endif +#define BCM2835_SDHCI_BASE (CONFIG_BCM283x_BASE + 0x00300000) int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq); diff --git a/arch/arm/mach-bcm283x/include/mach/timer.h b/arch/arm/mach-bcm283x/include/mach/timer.h index 56b0c356bb..014355e759 100644 --- a/arch/arm/mach-bcm283x/include/mach/timer.h +++ b/arch/arm/mach-bcm283x/include/mach/timer.h @@ -6,11 +6,7 @@ #ifndef _BCM2835_TIMER_H #define _BCM2835_TIMER_H -#ifndef CONFIG_BCM2835 -#define BCM2835_TIMER_PHYSADDR 0x3f003000 -#else -#define BCM2835_TIMER_PHYSADDR 0x20003000 -#endif +#define BCM2835_TIMER_PHYSADDR (CONFIG_BCM283x_BASE + 0x00003000) #define BCM2835_TIMER_CS_M3 (1 << 3) #define BCM2835_TIMER_CS_M2 (1 << 2) diff --git a/arch/arm/mach-bcm283x/include/mach/wdog.h b/arch/arm/mach-bcm283x/include/mach/wdog.h index 99c88e5df7..8292b3cf1f 100644 --- a/arch/arm/mach-bcm283x/include/mach/wdog.h +++ b/arch/arm/mach-bcm283x/include/mach/wdog.h @@ -6,11 +6,7 @@ #ifndef _BCM2835_WDOG_H #define _BCM2835_WDOG_H -#ifndef CONFIG_BCM2835 -#define BCM2835_WDOG_PHYSADDR 0x3f100000 -#else -#define BCM2835_WDOG_PHYSADDR 0x20100000 -#endif +#define BCM2835_WDOG_PHYSADDR (CONFIG_BCM283x_BASE + 0x00100000) struct bcm2835_wdog_regs { u32 unknown0[7];