diff mbox

[1/2] arm: bcm2835: move to the multiplatform support

Message ID 1351419853-25146-1-git-send-email-thomas.petazzoni@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Petazzoni Oct. 28, 2012, 10:24 a.m. UTC
This commit integrates the bcm2835 into the list of platforms
supported by the multiplatform mechanism, which makes it possible to
build a single kernel binary image that boots on various SoCs.

In order to make this happen, we have to:

 * Move the ARCH_BCM2835 Kconfig option down to
   arch/arm/mach-bcm2835/Kconfig and make a few adjustements.

 * Move the DEBUG_LL/earlyprintk support from
   arch/arm/mach-bcm2835/include/mach/ to arch/arm/include/debug/

 * Remove files that have become useless (timex.h, uncompress.h)

 * Move the last remaining header file bcm2835_soc.h down to
   arch/arm/mach-bcm2835/.

The resulting binary kernel has been successfully booted on both the
Rasberry Pi platform and the Globalscale Mirabox (a Marvell Armada 370
based platform).

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
Note that if you have CONFIG_VFP enabled, you need "[PATCH v3] ARM:
vfp: fix save and restore when running on pre-VFPv3 and CONFIG_VFPv3
set" to be applied in order to avoid a VFP-related kernel panic when
starting the first userspace application. Thanks to Albin Tonnerre for
pointing me to the right fix for this problem!
---
 arch/arm/Kconfig                                   |   20 +--------
 arch/arm/Kconfig.debug                             |    8 ++++
 .../mach/debug-macro.S => include/debug/bcm2835.S} |    3 +-
 arch/arm/mach-bcm2835/Kconfig                      |   18 ++++++++
 arch/arm/mach-bcm2835/Makefile.boot                |    3 --
 arch/arm/mach-bcm2835/bcm2835.c                    |    2 +-
 .../{include/mach/bcm2835_soc.h => bcm2835.h}      |    2 -
 arch/arm/mach-bcm2835/include/mach/timex.h         |   26 -----------
 arch/arm/mach-bcm2835/include/mach/uncompress.h    |   45 --------------------
 9 files changed, 31 insertions(+), 96 deletions(-)
 rename arch/arm/{mach-bcm2835/include/mach/debug-macro.S => include/debug/bcm2835.S} (86%)
 create mode 100644 arch/arm/mach-bcm2835/Kconfig
 delete mode 100644 arch/arm/mach-bcm2835/Makefile.boot
 rename arch/arm/mach-bcm2835/{include/mach/bcm2835_soc.h => bcm2835.h} (91%)
 delete mode 100644 arch/arm/mach-bcm2835/include/mach/timex.h
 delete mode 100644 arch/arm/mach-bcm2835/include/mach/uncompress.h

Comments

Stephen Warren Oct. 30, 2012, 2:31 a.m. UTC | #1
On 10/28/2012 04:24 AM, Thomas Petazzoni wrote:
> This commit integrates the bcm2835 into the list of platforms
> supported by the multiplatform mechanism, which makes it possible to
> build a single kernel binary image that boots on various SoCs.
...
> Note that if you have CONFIG_VFP enabled, you need "[PATCH v3] ARM:
> vfp: fix save and restore when running on pre-VFPv3 and CONFIG_VFPv3
> set" to be applied in order to avoid a VFP-related kernel panic when
> starting the first userspace application. Thanks to Albin Tonnerre for
> pointing me to the right fix for this problem!

Since CONFIG_VFP is enabled in bcm2835_defconfig (or in general, could
be enabled in anyone's .config), I guess that means I can't apply the
patch yet, because the VFP fix you mention above doesn't seem to have
been applied anywhere, so applying it would cause bcm2835_defconfig to
be unbootable. To apply this, I'd need to merge in a branch containing
the VFP fix first.

What branch is this patch series based on? Neither "git am" not "git am
-3" will apply the series; apparently my repo doesn't have the blobs to
perform the 3-way merge -3 invokes even though I have a remote for
linux-next which should pick up most blob sources.

A couple minor comments on the code itself:

> diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug

> +	config DEBUG_BCM2835_UART
> +		bool "Kernel low-level debugging messages via BCM2835 UART"
> +		depends on ARCH_BCM2835
> +		help
> +		  Say Y here if you want kernel low-level debugging support
> +		  on BCM2835 based platforms.
> +

Since the SoC has multiple UARTs, does it make sense to rename that
something like DEBUG_BM2835_PL011_UART?

> diff --git a/arch/arm/mach-bcm2835/include/mach/debug-macro.S b/arch/arm/include/debug/bcm2835.S

> -#include <mach/bcm2835_soc.h>
> +#define BCM2835_DEBUG_PHYS	0x20201000
> +#define BCM2835_DEBUG_VIRT	0xf0201000

Especially since I have to wait to apply this anyway, I'd prefer to
avoid that part of this patch, by calling debug_ll_io_init() from
bcm2835_map_io(). That patch unfortunately also isn't checked in yet,
but I'll try to chase it down.
Thomas Petazzoni Oct. 30, 2012, 8:20 a.m. UTC | #2
Stephen,

Thanks for taking the time to look at this patch.

On Mon, 29 Oct 2012 20:31:27 -0600, Stephen Warren wrote:

> Since CONFIG_VFP is enabled in bcm2835_defconfig (or in general, could
> be enabled in anyone's .config), I guess that means I can't apply the
> patch yet, because the VFP fix you mention above doesn't seem to have
> been applied anywhere, so applying it would cause bcm2835_defconfig to
> be unbootable. To apply this, I'd need to merge in a branch containing
> the VFP fix first.

I'm pretty sure the VFP fix will land somewhere at some point, we can
wait this moment to merge this multiplatform bcm2835 support patch.

> What branch is this patch series based on? Neither "git am" not "git am
> -3" will apply the series; apparently my repo doesn't have the blobs to
> perform the 3-way merge -3 invokes even though I have a remote for
> linux-next which should pick up most blob sources.

This is my fault, sorry. I based this patch on a branch that contains
the VFP fix + the irqchip changes I've been proposing. I can resend a
new version based on 3.7-rc3, or arm-soc/for-next, at your preference.

> A couple minor comments on the code itself:
> 
> > diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
> 
> > +	config DEBUG_BCM2835_UART
> > +		bool "Kernel low-level debugging messages via BCM2835 UART"
> > +		depends on ARCH_BCM2835
> > +		help
> > +		  Say Y here if you want kernel low-level debugging support
> > +		  on BCM2835 based platforms.
> > +
> 
> Since the SoC has multiple UARTs, does it make sense to rename that
> something like DEBUG_BM2835_PL011_UART?

Agreed.

> > diff --git a/arch/arm/mach-bcm2835/include/mach/debug-macro.S b/arch/arm/include/debug/bcm2835.S
> 
> > -#include <mach/bcm2835_soc.h>
> > +#define BCM2835_DEBUG_PHYS	0x20201000
> > +#define BCM2835_DEBUG_VIRT	0xf0201000
> 
> Especially since I have to wait to apply this anyway, I'd prefer to
> avoid that part of this patch, by calling debug_ll_io_init() from
> bcm2835_map_io(). That patch unfortunately also isn't checked in yet,
> but I'll try to chase it down.

Ok, fine with that. I can respin this multiplatform patch once VFP and
debug_ll_io_init() are available.

Thanks,

Thomas
Stephen Warren Oct. 30, 2012, 4:53 p.m. UTC | #3
On 10/30/2012 02:20 AM, Thomas Petazzoni wrote:
> Stephen,
> 
> Thanks for taking the time to look at this patch.
> 
> On Mon, 29 Oct 2012 20:31:27 -0600, Stephen Warren wrote:
> 
>> Since CONFIG_VFP is enabled in bcm2835_defconfig (or in general, could
>> be enabled in anyone's .config), I guess that means I can't apply the
>> patch yet, because the VFP fix you mention above doesn't seem to have
>> been applied anywhere, so applying it would cause bcm2835_defconfig to
>> be unbootable. To apply this, I'd need to merge in a branch containing
>> the VFP fix first.
> 
> I'm pretty sure the VFP fix will land somewhere at some point, we can
> wait this moment to merge this multiplatform bcm2835 support patch.
> 
>> What branch is this patch series based on? Neither "git am" not "git am
>> -3" will apply the series; apparently my repo doesn't have the blobs to
>> perform the 3-way merge -3 invokes even though I have a remote for
>> linux-next which should pick up most blob sources.
> 
> This is my fault, sorry. I based this patch on a branch that contains
> the VFP fix + the irqchip changes I've been proposing. I can resend a
> new version based on 3.7-rc3, or arm-soc/for-next, at your preference.

(Once the dependencies are in arm-soc somewhere...) It'd be best to base
it on v3.7-rcN, either with/without the VFP and debug_ll_io_init()
patches merged (since I'll apply the patch only on top of those two
patches anyway.

Thanks.
Stephen Warren Nov. 9, 2012, 3:03 a.m. UTC | #4
On 10/28/2012 04:24 AM, Thomas Petazzoni wrote:
> This commit integrates the bcm2835 into the list of platforms
> supported by the multiplatform mechanism, which makes it possible to
> build a single kernel binary image that boots on various SoCs.
...
> ---
> Note that if you have CONFIG_VFP enabled, you need "[PATCH v3] ARM:
> vfp: fix save and restore when running on pre-VFPv3 and CONFIG_VFPv3
> set" to be applied in order to avoid a VFP-related kernel panic when
> starting the first userspace application. Thanks to Albin Tonnerre for
> pointing me to the right fix for this problem!

Thomas, just a heads up - the VFP commit you mention above should show
up in v3.7-rc5 which I imagine will be released this weekend, and the
debug_ll_io_init feature I mentioned in another response is already
available is arm-soc branch devel/debug_ll_init. If you rebase this
patch on a merge of those two branches, it should be in good shape for
me to apply it.

Thanks.
Thomas Petazzoni Nov. 9, 2012, 8:05 a.m. UTC | #5
Stephen,

On Thu, 08 Nov 2012 20:03:12 -0700, Stephen Warren wrote:

> Thomas, just a heads up - the VFP commit you mention above should show
> up in v3.7-rc5 which I imagine will be released this weekend, and the
> debug_ll_io_init feature I mentioned in another response is already
> available is arm-soc branch devel/debug_ll_init. If you rebase this
> patch on a merge of those two branches, it should be in good shape for
> me to apply it.

Excellent, thanks for the heads up! As I've said in another e-mail, I
was at ELCE this week, which obviously means I wasn't able to do any
sort of kernel development. I'm back now, and planning to work on this
and the irqchip things.

Thanks,

Thomas
diff mbox

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7030500..7681840 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -334,24 +334,6 @@  config ARCH_AT91
 	  This enables support for systems based on Atmel
 	  AT91RM9200 and AT91SAM9* processors.
 
-config ARCH_BCM2835
-	bool "Broadcom BCM2835 family"
-	select ARCH_WANT_OPTIONAL_GPIOLIB
-	select ARM_AMBA
-	select ARM_ERRATA_411920
-	select ARM_TIMER_SP804
-	select CLKDEV_LOOKUP
-	select COMMON_CLK
-	select CPU_V6
-	select GENERIC_CLOCKEVENTS
-	select MULTI_IRQ_HANDLER
-	select SPARSE_IRQ
-	select USE_OF
-	select USE_IRQCHIP
-	help
-	  This enables support for the Broadcom BCM2835 SoC. This SoC is
-	  use in the Raspberry Pi, and Roku 2 devices.
-
 config ARCH_CNS3XXX
 	bool "Cavium Networks CNS3XXX family"
 	select ARM_GIC
@@ -1023,6 +1005,8 @@  source "arch/arm/mach-mvebu/Kconfig"
 
 source "arch/arm/mach-at91/Kconfig"
 
+source "arch/arm/mach-bcm2835/Kconfig"
+
 source "arch/arm/mach-clps711x/Kconfig"
 
 source "arch/arm/mach-cns3xxx/Kconfig"
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index b0f3857..23495b3 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -89,6 +89,13 @@  choice
 		bool "Kernel low-level debugging on 9263 and 9g45"
 		depends on HAVE_AT91_DBGU1
 
+	config DEBUG_BCM2835_UART
+		bool "Kernel low-level debugging messages via BCM2835 UART"
+		depends on ARCH_BCM2835
+		help
+		  Say Y here if you want kernel low-level debugging support
+		  on BCM2835 based platforms.
+
 	config DEBUG_CLPS711X_UART1
 		bool "Kernel low-level debugging messages via UART1"
 		depends on ARCH_CLPS711X
@@ -411,6 +418,7 @@  endchoice
 
 config DEBUG_LL_INCLUDE
 	string
+	default "debug/bcm2835.S" if DEBUG_BCM2835_UART
 	default "debug/icedcc.S" if DEBUG_ICEDCC
 	default "debug/highbank.S" if DEBUG_HIGHBANK_UART
 	default "debug/mvebu.S" if DEBUG_MVEBU_UART
diff --git a/arch/arm/mach-bcm2835/include/mach/debug-macro.S b/arch/arm/include/debug/bcm2835.S
similarity index 86%
rename from arch/arm/mach-bcm2835/include/mach/debug-macro.S
rename to arch/arm/include/debug/bcm2835.S
index 8a161e4..afe8e04 100644
--- a/arch/arm/mach-bcm2835/include/mach/debug-macro.S
+++ b/arch/arm/include/debug/bcm2835.S
@@ -11,7 +11,8 @@ 
  *
  */
 
-#include <mach/bcm2835_soc.h>
+#define BCM2835_DEBUG_PHYS	0x20201000
+#define BCM2835_DEBUG_VIRT	0xf0201000
 
 	.macro	addruart, rp, rv, tmp
 	ldr	\rp, =BCM2835_DEBUG_PHYS
diff --git a/arch/arm/mach-bcm2835/Kconfig b/arch/arm/mach-bcm2835/Kconfig
new file mode 100644
index 0000000..e9bb58d
--- /dev/null
+++ b/arch/arm/mach-bcm2835/Kconfig
@@ -0,0 +1,18 @@ 
+config ARCH_BCM2835
+	bool "Broadcom BCM2835 family" if ARCH_MULTI_V6
+	select ARCH_WANT_OPTIONAL_GPIOLIB
+	select ARM_AMBA
+	select ARM_ERRATA_411920
+	select ARM_TIMER_SP804
+	select CLKDEV_LOOKUP
+	select COMMON_CLK
+	select CPU_V6
+	select GENERIC_CLOCKEVENTS
+	select MULTI_IRQ_HANDLER
+	select SPARSE_IRQ
+	select USE_OF
+	select USE_IRQCHIP
+	help
+	  This enables support for the Broadcom BCM2835 SoC. This SoC is
+	  use in the Raspberry Pi, and Roku 2 devices.
+
diff --git a/arch/arm/mach-bcm2835/Makefile.boot b/arch/arm/mach-bcm2835/Makefile.boot
deleted file mode 100644
index 2d30e17..0000000
--- a/arch/arm/mach-bcm2835/Makefile.boot
+++ /dev/null
@@ -1,3 +0,0 @@ 
-   zreladdr-y := 0x00008000
-params_phys-y := 0x00000100
-initrd_phys-y := 0x00800000
diff --git a/arch/arm/mach-bcm2835/bcm2835.c b/arch/arm/mach-bcm2835/bcm2835.c
index ab1bccd..cb2f963 100644
--- a/arch/arm/mach-bcm2835/bcm2835.c
+++ b/arch/arm/mach-bcm2835/bcm2835.c
@@ -21,7 +21,7 @@ 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#include <mach/bcm2835_soc.h>
+#include "bcm2835.h"
 
 static struct map_desc io_map __initdata = {
 	.virtual = BCM2835_PERIPH_VIRT,
diff --git a/arch/arm/mach-bcm2835/include/mach/bcm2835_soc.h b/arch/arm/mach-bcm2835/bcm2835.h
similarity index 91%
rename from arch/arm/mach-bcm2835/include/mach/bcm2835_soc.h
rename to arch/arm/mach-bcm2835/bcm2835.h
index d4dfcf7..8fbad3a 100644
--- a/arch/arm/mach-bcm2835/include/mach/bcm2835_soc.h
+++ b/arch/arm/mach-bcm2835/bcm2835.h
@@ -23,7 +23,5 @@ 
 #define BCM2835_PERIPH_PHYS	0x20000000
 #define BCM2835_PERIPH_VIRT	0xf0000000
 #define BCM2835_PERIPH_SIZE	SZ_16M
-#define BCM2835_DEBUG_PHYS	0x20201000
-#define BCM2835_DEBUG_VIRT	0xf0201000
 
 #endif
diff --git a/arch/arm/mach-bcm2835/include/mach/timex.h b/arch/arm/mach-bcm2835/include/mach/timex.h
deleted file mode 100644
index 6d021e1..0000000
--- a/arch/arm/mach-bcm2835/include/mach/timex.h
+++ /dev/null
@@ -1,26 +0,0 @@ 
-/*
- *  BCM2835 system clock frequency
- *
- *  Copyright (C) 2010 Broadcom
- *
- * 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_ARCH_TIMEX_H
-#define __ASM_ARCH_TIMEX_H
-
-#define CLOCK_TICK_RATE		(1000000)
-
-#endif
diff --git a/arch/arm/mach-bcm2835/include/mach/uncompress.h b/arch/arm/mach-bcm2835/include/mach/uncompress.h
deleted file mode 100644
index cc46dcc..0000000
--- a/arch/arm/mach-bcm2835/include/mach/uncompress.h
+++ /dev/null
@@ -1,45 +0,0 @@ 
-/*
- * Copyright (C) 2010 Broadcom
- * Copyright (C) 2003 ARM Limited
- *
- * 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.
- */
-
-#include <linux/io.h>
-#include <linux/amba/serial.h>
-#include <mach/bcm2835_soc.h>
-
-#define UART0_BASE BCM2835_DEBUG_PHYS
-
-#define BCM2835_UART_DR IOMEM(UART0_BASE + UART01x_DR)
-#define BCM2835_UART_FR IOMEM(UART0_BASE + UART01x_FR)
-#define BCM2835_UART_CR IOMEM(UART0_BASE + UART011_CR)
-
-static inline void putc(int c)
-{
-	while (__raw_readl(BCM2835_UART_FR) & UART01x_FR_TXFF)
-		barrier();
-
-	__raw_writel(c, BCM2835_UART_DR);
-}
-
-static inline void flush(void)
-{
-	int fr;
-
-	do {
-		fr = __raw_readl(BCM2835_UART_FR);
-		barrier();
-	} while ((fr & (UART011_FR_TXFE | UART01x_FR_BUSY)) != UART011_FR_TXFE);
-}
-
-#define arch_decomp_setup()
-#define arch_decomp_wdog()