Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: add infra-structure for BCM2835 and Raspberry Pi

The BCM2835 is an ARM SoC from Broadcom. This patch adds very basic
support for this SoC.

http://www.broadcom.com/products/BCM2835
http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

Note that the documentation in the latter .pdf assumes the MMU setup
that's used on the "VideoCore" companion processor, and does not document
physical peripheral addresses. Subtract 0x5e000000 to obtain the physical
addresses. This is accounted for by the ranges property in the /soc node
in the device tree.

The BCM2835 SoC is used in the Raspberry Pi. This patch also adds a
minimal device tree for this board; enough to see some very early kernel
boot messages through earlyprintk. However, this patch does not yet
provide a useful booting system.

http://www.raspberrypi.org/.

This patch was extracted from git://github.com/lp0/linux.git branch
rpi-split from 3-4 months ago, and significantly stripped down and
modified since.

Signed-off-by: Chris Boot <bootc@bootc.net>
Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Signed-off-by: Dom Cobley <dc4@broadcom.com>
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>

authored by

Simon Arlott and committed by
Stephen Warren
ec9653b8 55d512e2

+355
+8
Documentation/devicetree/bindings/arm/bcm2835.txt
··· 1 + Broadcom BCM2835 device tree bindings 2 + ------------------------------------------- 3 + 4 + Boards with the BCM2835 SoC shall have the following properties: 5 + 6 + Required root node property: 7 + 8 + compatible = "brcm,bcm2835";
+1
Documentation/devicetree/bindings/vendor-prefixes.txt
··· 10 10 arm ARM Ltd. 11 11 atmel Atmel Corporation 12 12 bosch Bosch Sensortec GmbH 13 + brcm Broadcom Corporation 13 14 cavium Cavium, Inc. 14 15 chrp Common Hardware Reference Platform 15 16 cortina Cortina Systems, Inc.
+17
arch/arm/Kconfig
··· 350 350 This enables support for systems based on Atmel 351 351 AT91RM9200 and AT91SAM9* processors. 352 352 353 + config ARCH_BCM2835 354 + bool "Broadcom BCM2835 family" 355 + select ARCH_WANT_OPTIONAL_GPIOLIB 356 + select ARM_AMBA 357 + select ARM_ERRATA_411920 358 + select ARM_TIMER_SP804 359 + select CLKDEV_LOOKUP 360 + select COMMON_CLK 361 + select CPU_V6 362 + select GENERIC_CLOCKEVENTS 363 + select MULTI_IRQ_HANDLER 364 + select SPARSE_IRQ 365 + select USE_OF 366 + help 367 + This enables support for the Broadcom BCM2835 SoC. This SoC is 368 + use in the Raspberry Pi, and Roku 2 devices. 369 + 353 370 config ARCH_BCMRING 354 371 bool "Broadcom BCMRING" 355 372 depends on MMU
+1
arch/arm/Makefile
··· 136 136 # Machine directory name. This list is sorted alphanumerically 137 137 # by CONFIG_* macro name. 138 138 machine-$(CONFIG_ARCH_AT91) := at91 139 + machine-$(CONFIG_ARCH_BCM2835) := bcm2835 139 140 machine-$(CONFIG_ARCH_BCMRING) := bcmring 140 141 machine-$(CONFIG_ARCH_CLPS711X) := clps711x 141 142 machine-$(CONFIG_ARCH_CNS3XXX) := cns3xxx
+12
arch/arm/boot/dts/bcm2835-rpi-b.dts
··· 1 + /dts-v1/; 2 + /memreserve/ 0x0c000000 0x04000000; 3 + /include/ "bcm2835.dtsi" 4 + 5 + / { 6 + compatible = "raspberrypi,model-b", "brcm,bcm2835"; 7 + model = "Raspberry Pi Model B"; 8 + 9 + memory { 10 + reg = <0 0x10000000>; 11 + }; 12 + };
+17
arch/arm/boot/dts/bcm2835.dtsi
··· 1 + /include/ "skeleton.dtsi" 2 + 3 + / { 4 + compatible = "brcm,bcm2835"; 5 + model = "BCM2835"; 6 + 7 + chosen { 8 + bootargs = "earlyprintk"; 9 + }; 10 + 11 + soc { 12 + compatible = "simple-bus"; 13 + #address-cells = <1>; 14 + #size-cells = <1>; 15 + ranges = <0x7e000000 0x20000000 0x02000000>; 16 + }; 17 + };
+95
arch/arm/configs/bcm2835_defconfig
··· 1 + CONFIG_EXPERIMENTAL=y 2 + # CONFIG_LOCALVERSION_AUTO is not set 3 + CONFIG_SYSVIPC=y 4 + CONFIG_BSD_PROCESS_ACCT=y 5 + CONFIG_BSD_PROCESS_ACCT_V3=y 6 + CONFIG_FHANDLE=y 7 + CONFIG_NO_HZ=y 8 + CONFIG_HIGH_RES_TIMERS=y 9 + CONFIG_LOG_BUF_SHIFT=18 10 + CONFIG_CGROUP_FREEZER=y 11 + CONFIG_CGROUP_DEVICE=y 12 + CONFIG_CPUSETS=y 13 + CONFIG_CGROUP_CPUACCT=y 14 + CONFIG_RESOURCE_COUNTERS=y 15 + CONFIG_CGROUP_PERF=y 16 + CONFIG_CFS_BANDWIDTH=y 17 + CONFIG_RT_GROUP_SCHED=y 18 + CONFIG_NAMESPACES=y 19 + CONFIG_SCHED_AUTOGROUP=y 20 + CONFIG_RELAY=y 21 + CONFIG_BLK_DEV_INITRD=y 22 + CONFIG_RD_BZIP2=y 23 + CONFIG_RD_LZMA=y 24 + CONFIG_RD_XZ=y 25 + CONFIG_RD_LZO=y 26 + CONFIG_CC_OPTIMIZE_FOR_SIZE=y 27 + CONFIG_KALLSYMS_ALL=y 28 + CONFIG_EMBEDDED=y 29 + # CONFIG_COMPAT_BRK is not set 30 + CONFIG_PROFILING=y 31 + CONFIG_OPROFILE=y 32 + CONFIG_JUMP_LABEL=y 33 + # CONFIG_BLOCK is not set 34 + CONFIG_ARCH_BCM2835=y 35 + CONFIG_PREEMPT_VOLUNTARY=y 36 + CONFIG_AEABI=y 37 + CONFIG_COMPACTION=y 38 + CONFIG_KSM=y 39 + CONFIG_DEFAULT_MMAP_MIN_ADDR=65536 40 + CONFIG_CLEANCACHE=y 41 + CONFIG_SECCOMP=y 42 + CONFIG_CC_STACKPROTECTOR=y 43 + CONFIG_KEXEC=y 44 + CONFIG_CRASH_DUMP=y 45 + CONFIG_VFP=y 46 + # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 47 + # CONFIG_SUSPEND is not set 48 + CONFIG_DEVTMPFS=y 49 + CONFIG_DEVTMPFS_MOUNT=y 50 + # CONFIG_STANDALONE is not set 51 + # CONFIG_INPUT_MOUSEDEV is not set 52 + # CONFIG_INPUT_KEYBOARD is not set 53 + # CONFIG_INPUT_MOUSE is not set 54 + # CONFIG_SERIO is not set 55 + # CONFIG_VT is not set 56 + # CONFIG_UNIX98_PTYS is not set 57 + # CONFIG_LEGACY_PTYS is not set 58 + # CONFIG_DEVKMEM is not set 59 + CONFIG_SERIAL_AMBA_PL011=y 60 + CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 61 + CONFIG_TTY_PRINTK=y 62 + # CONFIG_HW_RANDOM is not set 63 + # CONFIG_HWMON is not set 64 + # CONFIG_USB_SUPPORT is not set 65 + # CONFIG_IOMMU_SUPPORT is not set 66 + # CONFIG_FILE_LOCKING is not set 67 + # CONFIG_DNOTIFY is not set 68 + # CONFIG_INOTIFY_USER is not set 69 + # CONFIG_PROC_FS is not set 70 + # CONFIG_SYSFS is not set 71 + # CONFIG_MISC_FILESYSTEMS is not set 72 + CONFIG_PRINTK_TIME=y 73 + # CONFIG_ENABLE_WARN_DEPRECATED is not set 74 + # CONFIG_ENABLE_MUST_CHECK is not set 75 + CONFIG_UNUSED_SYMBOLS=y 76 + CONFIG_LOCKUP_DETECTOR=y 77 + CONFIG_DEBUG_INFO=y 78 + CONFIG_DEBUG_MEMORY_INIT=y 79 + CONFIG_BOOT_PRINTK_DELAY=y 80 + CONFIG_SCHED_TRACER=y 81 + CONFIG_STACK_TRACER=y 82 + CONFIG_FUNCTION_PROFILER=y 83 + CONFIG_DYNAMIC_DEBUG=y 84 + CONFIG_KGDB=y 85 + CONFIG_KGDB_KDB=y 86 + CONFIG_TEST_KSTRTOX=y 87 + CONFIG_STRICT_DEVMEM=y 88 + CONFIG_DEBUG_LL=y 89 + CONFIG_EARLY_PRINTK=y 90 + # CONFIG_XZ_DEC_X86 is not set 91 + # CONFIG_XZ_DEC_POWERPC is not set 92 + # CONFIG_XZ_DEC_IA64 is not set 93 + # CONFIG_XZ_DEC_ARM is not set 94 + # CONFIG_XZ_DEC_ARMTHUMB is not set 95 + # CONFIG_XZ_DEC_SPARC is not set
+1
arch/arm/mach-bcm2835/Makefile
··· 1 + obj-y += bcm2835.o
+5
arch/arm/mach-bcm2835/Makefile.boot
··· 1 + zreladdr-y := 0x00008000 2 + params_phys-y := 0x00000100 3 + initrd_phys-y := 0x00800000 4 + 5 + dtb-y += bcm2835-rpi-b.dtb
+77
arch/arm/mach-bcm2835/bcm2835.c
··· 1 + /* 2 + * Copyright (C) 2010 Broadcom 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + * 9 + * This program is distributed in the hope that it will be useful, 10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License for more details. 13 + */ 14 + 15 + #include <linux/init.h> 16 + #include <linux/of_platform.h> 17 + 18 + #include <asm/mach/arch.h> 19 + #include <asm/mach/map.h> 20 + #include <asm/mach/time.h> 21 + #include <asm/exception.h> 22 + 23 + #include <mach/bcm2835_soc.h> 24 + 25 + static struct map_desc io_map __initdata = { 26 + .virtual = BCM2835_PERIPH_VIRT, 27 + .pfn = __phys_to_pfn(BCM2835_PERIPH_PHYS), 28 + .length = BCM2835_PERIPH_SIZE, 29 + .type = MT_DEVICE 30 + }; 31 + 32 + void __init bcm2835_map_io(void) 33 + { 34 + iotable_init(&io_map, 1); 35 + } 36 + 37 + void __init bcm2835_init_irq(void) 38 + { 39 + } 40 + 41 + asmlinkage void __exception_irq_entry bcm2835_handle_irq(struct pt_regs *regs) 42 + { 43 + } 44 + 45 + void __init bcm2835_init(void) 46 + { 47 + int ret; 48 + 49 + ret = of_platform_populate(NULL, of_default_bus_match_table, NULL, 50 + NULL); 51 + if (ret) { 52 + pr_err("of_platform_populate failed: %d\n", ret); 53 + BUG(); 54 + } 55 + } 56 + 57 + static void __init bcm2835_timer_init(void) 58 + { 59 + } 60 + 61 + struct sys_timer bcm2835_timer = { 62 + .init = bcm2835_timer_init 63 + }; 64 + 65 + static const char * const bcm2835_compat[] = { 66 + "brcm,bcm2835", 67 + NULL 68 + }; 69 + 70 + DT_MACHINE_START(BCM2835, "BCM2835") 71 + .map_io = bcm2835_map_io, 72 + .init_irq = bcm2835_init_irq, 73 + .handle_irq = bcm2835_handle_irq, 74 + .init_machine = bcm2835_init, 75 + .timer = &bcm2835_timer, 76 + .dt_compat = bcm2835_compat 77 + MACHINE_END
+29
arch/arm/mach-bcm2835/include/mach/bcm2835_soc.h
··· 1 + /* 2 + * Copyright (C) 2012 Stephen Warren 3 + * 4 + * Derived from code: 5 + * Copyright (C) 2010 Broadcom 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License as published by 9 + * the Free Software Foundation; either version 2 of the License, or 10 + * (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + */ 17 + 18 + #ifndef __MACH_BCM2835_BCM2835_SOC_H__ 19 + #define __MACH_BCM2835_BCM2835_SOC_H__ 20 + 21 + #include <asm/sizes.h> 22 + 23 + #define BCM2835_PERIPH_PHYS 0x20000000 24 + #define BCM2835_PERIPH_VIRT 0xf0000000 25 + #define BCM2835_PERIPH_SIZE SZ_16M 26 + #define BCM2835_DEBUG_PHYS 0x20201000 27 + #define BCM2835_DEBUG_VIRT 0xf0201000 28 + 29 + #endif
+21
arch/arm/mach-bcm2835/include/mach/debug-macro.S
··· 1 + /* 2 + * Debugging macro include header 3 + * 4 + * Copyright (C) 2010 Broadcom 5 + * Copyright (C) 1994-1999 Russell King 6 + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + */ 13 + 14 + #include <mach/bcm2835_soc.h> 15 + 16 + .macro addruart, rp, rv, tmp 17 + ldr \rp, =BCM2835_DEBUG_PHYS 18 + ldr \rv, =BCM2835_DEBUG_VIRT 19 + .endm 20 + 21 + #include <asm/hardware/debug-pl01x.S>
+26
arch/arm/mach-bcm2835/include/mach/timex.h
··· 1 + /* 2 + * BCM2835 system clock frequency 3 + * 4 + * Copyright (C) 2010 Broadcom 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + * 16 + * You should have received a copy of the GNU General Public License 17 + * along with this program; if not, write to the Free Software 18 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 + */ 20 + 21 + #ifndef __ASM_ARCH_TIMEX_H 22 + #define __ASM_ARCH_TIMEX_H 23 + 24 + #define CLOCK_TICK_RATE (1000000) 25 + 26 + #endif
+45
arch/arm/mach-bcm2835/include/mach/uncompress.h
··· 1 + /* 2 + * Copyright (C) 2010 Broadcom 3 + * Copyright (C) 2003 ARM Limited 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/io.h> 17 + #include <linux/amba/serial.h> 18 + #include <mach/bcm2835_soc.h> 19 + 20 + #define UART0_BASE BCM2835_DEBUG_PHYS 21 + 22 + #define BCM2835_UART_DR IOMEM(UART0_BASE + UART01x_DR) 23 + #define BCM2835_UART_FR IOMEM(UART0_BASE + UART01x_FR) 24 + #define BCM2835_UART_CR IOMEM(UART0_BASE + UART011_CR) 25 + 26 + static inline void putc(int c) 27 + { 28 + while (__raw_readl(BCM2835_UART_FR) & UART01x_FR_TXFF) 29 + barrier(); 30 + 31 + __raw_writel(c, BCM2835_UART_DR); 32 + } 33 + 34 + static inline void flush(void) 35 + { 36 + int fr; 37 + 38 + do { 39 + fr = __raw_readl(BCM2835_UART_FR); 40 + barrier(); 41 + } while ((fr & (UART011_FR_TXFE | UART01x_FR_BUSY)) != UART011_FR_TXFE); 42 + } 43 + 44 + #define arch_decomp_setup() 45 + #define arch_decomp_wdog()