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

Merge tag 'rpi-for-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-rpi into next/soc

ARM: add basic BCM2835 SoC and Raspberry Pi board support

The BCM2835 is an ARM SoC from Broadcom. This patch adds very basic
support for this SoC; enough to boot the system into an initrd with
UART console, interrupt controller, timers, and a stub clock driver.

Also provided is a similarly basic device tree for the Raspberry Pi
Model B board.

This series was written by Simon Arlott, Chris Boot, and Dom Cobley
downstream, with reference to a Broadcom tree, and modified for upstream
and submitted by Stephen Warren.

* tag 'rpi-for-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-rpi:
MAINTAINERS: add an entry for the BCM2835 ARM sub-architecture
ARM: bcm2835: instantiate console UART
ARM: bcm2835: add stub clock driver
ARM: bcm2835: add system timer
ARM: bcm2835: add interrupt controller driver
ARM: add infra-structure for BCM2835 and Raspberry Pi

+1031
+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";
+110
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
··· 1 + BCM2835 Top-Level ("ARMCTRL") Interrupt Controller 2 + 3 + The BCM2835 contains a custom top-level interrupt controller, which supports 4 + 72 interrupt sources using a 2-level register scheme. The interrupt 5 + controller, or the HW block containing it, is referred to occasionally 6 + as "armctrl" in the SoC documentation, hence naming of this binding. 7 + 8 + Required properties: 9 + 10 + - compatible : should be "brcm,bcm2835-armctrl-ic.txt" 11 + - reg : Specifies base physical address and size of the registers. 12 + - interrupt-controller : Identifies the node as an interrupt controller 13 + - #interrupt-cells : Specifies the number of cells needed to encode an 14 + interrupt source. The value shall be 2. 15 + 16 + The 1st cell is the interrupt bank; 0 for interrupts in the "IRQ basic 17 + pending" register, or 1/2 respectively for interrupts in the "IRQ pending 18 + 1/2" register. 19 + 20 + The 2nd cell contains the interrupt number within the bank. Valid values 21 + are 0..7 for bank 0, and 0..31 for bank 1. 22 + 23 + The interrupt sources are as follows: 24 + 25 + Bank 0: 26 + 0: ARM_TIMER 27 + 1: ARM_MAILBOX 28 + 2: ARM_DOORBELL_0 29 + 3: ARM_DOORBELL_1 30 + 4: VPU0_HALTED 31 + 5: VPU1_HALTED 32 + 6: ILLEGAL_TYPE0 33 + 7: ILLEGAL_TYPE1 34 + 35 + Bank 1: 36 + 0: TIMER0 37 + 1: TIMER1 38 + 2: TIMER2 39 + 3: TIMER3 40 + 4: CODEC0 41 + 5: CODEC1 42 + 6: CODEC2 43 + 7: VC_JPEG 44 + 8: ISP 45 + 9: VC_USB 46 + 10: VC_3D 47 + 11: TRANSPOSER 48 + 12: MULTICORESYNC0 49 + 13: MULTICORESYNC1 50 + 14: MULTICORESYNC2 51 + 15: MULTICORESYNC3 52 + 16: DMA0 53 + 17: DMA1 54 + 18: VC_DMA2 55 + 19: VC_DMA3 56 + 20: DMA4 57 + 21: DMA5 58 + 22: DMA6 59 + 23: DMA7 60 + 24: DMA8 61 + 25: DMA9 62 + 26: DMA10 63 + 27: DMA11 64 + 28: DMA12 65 + 29: AUX 66 + 30: ARM 67 + 31: VPUDMA 68 + 69 + Bank 2: 70 + 0: HOSTPORT 71 + 1: VIDEOSCALER 72 + 2: CCP2TX 73 + 3: SDC 74 + 4: DSI0 75 + 5: AVE 76 + 6: CAM0 77 + 7: CAM1 78 + 8: HDMI0 79 + 9: HDMI1 80 + 10: PIXELVALVE1 81 + 11: I2CSPISLV 82 + 12: DSI1 83 + 13: PWA0 84 + 14: PWA1 85 + 15: CPR 86 + 16: SMI 87 + 17: GPIO0 88 + 18: GPIO1 89 + 19: GPIO2 90 + 20: GPIO3 91 + 21: VC_I2C 92 + 22: VC_SPI 93 + 23: VC_I2SPCM 94 + 24: VC_SDIO 95 + 25: VC_UART 96 + 26: SLIMBUS 97 + 27: VEC 98 + 28: CPG 99 + 29: RNG 100 + 30: VC_ARASANSDIO 101 + 31: AVSPMON 102 + 103 + Example: 104 + 105 + intc: interrupt-controller { 106 + compatible = "brcm,bcm2835-armctrl-ic"; 107 + reg = <0x7e00b200 0x200>; 108 + interrupt-controller; 109 + #interrupt-cells = <2>; 110 + };
+22
Documentation/devicetree/bindings/timer/brcm,bcm2835-system-timer.txt
··· 1 + BCM2835 System Timer 2 + 3 + The System Timer peripheral provides four 32-bit timer channels and a 4 + single 64-bit free running counter. Each channel has an output compare 5 + register, which is compared against the 32 least significant bits of the 6 + free running counter values, and generates an interrupt. 7 + 8 + Required properties: 9 + 10 + - compatible : should be "brcm,bcm2835-system-timer.txt" 11 + - reg : Specifies base physical address and size of the registers. 12 + - interrupts : A list of 4 interrupt sinks; one per timer channel. 13 + - clock-frequency : The frequency of the clock that drives the counter, in Hz. 14 + 15 + Example: 16 + 17 + timer { 18 + compatible = "brcm,bcm2835-system-timer"; 19 + reg = <0x7e003000 0x1000>; 20 + interrupts = <1 0>, <1 1>, <1 2>, <1 3>; 21 + clock-frequency = <1000000>; 22 + };
+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.
+10
MAINTAINERS
··· 1612 1612 S: Supported 1613 1613 F: drivers/net/ethernet/broadcom/bnx2x/ 1614 1614 1615 + BROADCOM BCM2835 ARM ARCHICTURE 1616 + M: Stephen Warren <swarren@wwwdotorg.org> 1617 + L: linux-rpi-kernel@lists.infradead.org (moderated for non-subscribers) 1618 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-rpi.git 1619 + S: Maintained 1620 + F: arch/arm/mach-bcm2835/ 1621 + F: arch/arm/boot/dts/bcm2835* 1622 + F: arch/arm/configs/bcm2835_defconfig 1623 + F: drivers/*/*bcm2835* 1624 + 1615 1625 BROADCOM TG3 GIGABIT ETHERNET DRIVER 1616 1626 M: Matt Carlson <mcarlson@broadcom.com> 1617 1627 M: Michael Chan <mchan@broadcom.com>
+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 + };
+39
arch/arm/boot/dts/bcm2835.dtsi
··· 1 + /include/ "skeleton.dtsi" 2 + 3 + / { 4 + compatible = "brcm,bcm2835"; 5 + model = "BCM2835"; 6 + interrupt-parent = <&intc>; 7 + 8 + chosen { 9 + bootargs = "earlyprintk console=ttyAMA0"; 10 + }; 11 + 12 + soc { 13 + compatible = "simple-bus"; 14 + #address-cells = <1>; 15 + #size-cells = <1>; 16 + ranges = <0x7e000000 0x20000000 0x02000000>; 17 + 18 + timer { 19 + compatible = "brcm,bcm2835-system-timer"; 20 + reg = <0x7e003000 0x1000>; 21 + interrupts = <1 0>, <1 1>, <1 2>, <1 3>; 22 + clock-frequency = <1000000>; 23 + }; 24 + 25 + intc: interrupt-controller { 26 + compatible = "brcm,bcm2835-armctrl-ic"; 27 + reg = <0x7e00b200 0x200>; 28 + interrupt-controller; 29 + #interrupt-cells = <2>; 30 + }; 31 + 32 + uart@20201000 { 33 + compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell"; 34 + reg = <0x7e201000 0x1000>; 35 + interrupts = <2 25>; 36 + clock-frequency = <3000000>; 37 + }; 38 + }; 39 + };
+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
+64
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/irqchip/bcm2835.h> 17 + #include <linux/of_platform.h> 18 + #include <linux/bcm2835_timer.h> 19 + #include <linux/clk/bcm2835.h> 20 + 21 + #include <asm/mach/arch.h> 22 + #include <asm/mach/map.h> 23 + 24 + #include <mach/bcm2835_soc.h> 25 + 26 + static struct map_desc io_map __initdata = { 27 + .virtual = BCM2835_PERIPH_VIRT, 28 + .pfn = __phys_to_pfn(BCM2835_PERIPH_PHYS), 29 + .length = BCM2835_PERIPH_SIZE, 30 + .type = MT_DEVICE 31 + }; 32 + 33 + void __init bcm2835_map_io(void) 34 + { 35 + iotable_init(&io_map, 1); 36 + } 37 + 38 + void __init bcm2835_init(void) 39 + { 40 + int ret; 41 + 42 + bcm2835_init_clocks(); 43 + 44 + ret = of_platform_populate(NULL, of_default_bus_match_table, NULL, 45 + NULL); 46 + if (ret) { 47 + pr_err("of_platform_populate failed: %d\n", ret); 48 + BUG(); 49 + } 50 + } 51 + 52 + static const char * const bcm2835_compat[] = { 53 + "brcm,bcm2835", 54 + NULL 55 + }; 56 + 57 + DT_MACHINE_START(BCM2835, "BCM2835") 58 + .map_io = bcm2835_map_io, 59 + .init_irq = bcm2835_init_irq, 60 + .handle_irq = bcm2835_handle_irq, 61 + .init_machine = bcm2835_init, 62 + .timer = &bcm2835_timer, 63 + .dt_compat = bcm2835_compat 64 + 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()
+2
drivers/Kconfig
··· 152 152 153 153 source "drivers/pwm/Kconfig" 154 154 155 + source "drivers/irqchip/Kconfig" 156 + 155 157 endmenu
+2
drivers/Makefile
··· 5 5 # Rewritten to use lists instead of if-statements. 6 6 # 7 7 8 + obj-y += irqchip/ 9 + 8 10 # GPIO must come after pinctrl as gpios may need to mux pins etc 9 11 obj-y += pinctrl/ 10 12 obj-y += gpio/
+1
drivers/clk/Makefile
··· 3 3 obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \ 4 4 clk-mux.o clk-divider.o clk-fixed-factor.o 5 5 # SoCs specific 6 + obj-$(CONFIG_ARCH_BCM2835) += clk-bcm2835.o 6 7 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o 7 8 obj-$(CONFIG_ARCH_HIGHBANK) += clk-highbank.o 8 9 obj-$(CONFIG_ARCH_MXS) += mxs/
+59
drivers/clk/clk-bcm2835.c
··· 1 + /* 2 + * Copyright (C) 2010 Broadcom 3 + * Copyright (C) 2012 Stephen Warren 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 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 + */ 19 + 20 + #include <linux/clk-provider.h> 21 + #include <linux/clkdev.h> 22 + #include <linux/clk/bcm2835.h> 23 + 24 + /* 25 + * These are fixed clocks. They're probably not all root clocks and it may 26 + * be possible to turn them on and off but until this is mapped out better 27 + * it's the only way they can be used. 28 + */ 29 + void __init bcm2835_init_clocks(void) 30 + { 31 + struct clk *clk; 32 + int ret; 33 + 34 + clk = clk_register_fixed_rate(NULL, "sys_pclk", NULL, CLK_IS_ROOT, 35 + 250000000); 36 + if (!clk) 37 + pr_err("sys_pclk not registered\n"); 38 + 39 + clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, CLK_IS_ROOT, 40 + 126000000); 41 + if (!clk) 42 + pr_err("apb_pclk not registered\n"); 43 + 44 + clk = clk_register_fixed_rate(NULL, "uart0_pclk", NULL, CLK_IS_ROOT, 45 + 3000000); 46 + if (!clk) 47 + pr_err("uart0_pclk not registered\n"); 48 + ret = clk_register_clkdev(clk, NULL, "20201000.uart"); 49 + if (ret) 50 + pr_err("uart0_pclk alias not registered\n"); 51 + 52 + clk = clk_register_fixed_rate(NULL, "uart1_pclk", NULL, CLK_IS_ROOT, 53 + 125000000); 54 + if (!clk) 55 + pr_err("uart1_pclk not registered\n"); 56 + ret = clk_register_clkdev(clk, NULL, "20215000.uart"); 57 + if (ret) 58 + pr_err("uart0_pclk alias not registered\n"); 59 + }
+1
drivers/clocksource/Makefile
··· 13 13 obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o 14 14 obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o 15 15 obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o 16 + obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o
+161
drivers/clocksource/bcm2835_timer.c
··· 1 + /* 2 + * Copyright 2012 Simon Arlott 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 + * You should have received a copy of the GNU General Public License 15 + * along with this program; if not, write to the Free Software 16 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 + */ 18 + 19 + #include <linux/bcm2835_timer.h> 20 + #include <linux/bitops.h> 21 + #include <linux/clockchips.h> 22 + #include <linux/clocksource.h> 23 + #include <linux/interrupt.h> 24 + #include <linux/irqreturn.h> 25 + #include <linux/kernel.h> 26 + #include <linux/module.h> 27 + #include <linux/of_address.h> 28 + #include <linux/of_irq.h> 29 + #include <linux/of_platform.h> 30 + #include <linux/slab.h> 31 + #include <linux/string.h> 32 + 33 + #include <asm/sched_clock.h> 34 + #include <asm/irq.h> 35 + 36 + #define REG_CONTROL 0x00 37 + #define REG_COUNTER_LO 0x04 38 + #define REG_COUNTER_HI 0x08 39 + #define REG_COMPARE(n) (0x0c + (n) * 4) 40 + #define MAX_TIMER 3 41 + #define DEFAULT_TIMER 3 42 + 43 + struct bcm2835_timer { 44 + void __iomem *control; 45 + void __iomem *compare; 46 + int match_mask; 47 + struct clock_event_device evt; 48 + struct irqaction act; 49 + }; 50 + 51 + static void __iomem *system_clock __read_mostly; 52 + 53 + static u32 notrace bcm2835_sched_read(void) 54 + { 55 + return readl_relaxed(system_clock); 56 + } 57 + 58 + static void bcm2835_time_set_mode(enum clock_event_mode mode, 59 + struct clock_event_device *evt_dev) 60 + { 61 + switch (mode) { 62 + case CLOCK_EVT_MODE_ONESHOT: 63 + case CLOCK_EVT_MODE_UNUSED: 64 + case CLOCK_EVT_MODE_SHUTDOWN: 65 + case CLOCK_EVT_MODE_RESUME: 66 + break; 67 + default: 68 + WARN(1, "%s: unhandled event mode %d\n", __func__, mode); 69 + break; 70 + } 71 + } 72 + 73 + static int bcm2835_time_set_next_event(unsigned long event, 74 + struct clock_event_device *evt_dev) 75 + { 76 + struct bcm2835_timer *timer = container_of(evt_dev, 77 + struct bcm2835_timer, evt); 78 + writel_relaxed(readl_relaxed(system_clock) + event, 79 + timer->compare); 80 + return 0; 81 + } 82 + 83 + static irqreturn_t bcm2835_time_interrupt(int irq, void *dev_id) 84 + { 85 + struct bcm2835_timer *timer = dev_id; 86 + void (*event_handler)(struct clock_event_device *); 87 + if (readl_relaxed(timer->control) & timer->match_mask) { 88 + writel_relaxed(timer->match_mask, timer->control); 89 + 90 + event_handler = ACCESS_ONCE(timer->evt.event_handler); 91 + if (event_handler) 92 + event_handler(&timer->evt); 93 + return IRQ_HANDLED; 94 + } else { 95 + return IRQ_NONE; 96 + } 97 + } 98 + 99 + static struct of_device_id bcm2835_time_match[] __initconst = { 100 + { .compatible = "brcm,bcm2835-system-timer" }, 101 + {} 102 + }; 103 + 104 + static void __init bcm2835_time_init(void) 105 + { 106 + struct device_node *node; 107 + void __iomem *base; 108 + u32 freq; 109 + int irq; 110 + struct bcm2835_timer *timer; 111 + 112 + node = of_find_matching_node(NULL, bcm2835_time_match); 113 + if (!node) 114 + panic("No bcm2835 timer node"); 115 + 116 + base = of_iomap(node, 0); 117 + if (!base) 118 + panic("Can't remap registers"); 119 + 120 + if (of_property_read_u32(node, "clock-frequency", &freq)) 121 + panic("Can't read clock-frequency"); 122 + 123 + system_clock = base + REG_COUNTER_LO; 124 + setup_sched_clock(bcm2835_sched_read, 32, freq); 125 + 126 + clocksource_mmio_init(base + REG_COUNTER_LO, node->name, 127 + freq, 300, 32, clocksource_mmio_readl_up); 128 + 129 + irq = irq_of_parse_and_map(node, DEFAULT_TIMER); 130 + if (irq <= 0) 131 + panic("Can't parse IRQ"); 132 + 133 + timer = kzalloc(sizeof(*timer), GFP_KERNEL); 134 + if (!timer) 135 + panic("Can't allocate timer struct\n"); 136 + 137 + timer->control = base + REG_CONTROL; 138 + timer->compare = base + REG_COMPARE(DEFAULT_TIMER); 139 + timer->match_mask = BIT(DEFAULT_TIMER); 140 + timer->evt.name = node->name; 141 + timer->evt.rating = 300; 142 + timer->evt.features = CLOCK_EVT_FEAT_ONESHOT; 143 + timer->evt.set_mode = bcm2835_time_set_mode; 144 + timer->evt.set_next_event = bcm2835_time_set_next_event; 145 + timer->evt.cpumask = cpumask_of(0); 146 + timer->act.name = node->name; 147 + timer->act.flags = IRQF_TIMER | IRQF_SHARED; 148 + timer->act.dev_id = timer; 149 + timer->act.handler = bcm2835_time_interrupt; 150 + 151 + if (setup_irq(irq, &timer->act)) 152 + panic("Can't set up timer IRQ\n"); 153 + 154 + clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); 155 + 156 + pr_info("bcm2835: system timer (irq = %d)\n", irq); 157 + } 158 + 159 + struct sys_timer bcm2835_timer = { 160 + .init = bcm2835_time_init, 161 + };
drivers/irqchip/Kconfig
+1
drivers/irqchip/Makefile
··· 1 + obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
+223
drivers/irqchip/irq-bcm2835.c
··· 1 + /* 2 + * Copyright 2010 Broadcom 3 + * Copyright 2012 Simon Arlott, Chris Boot, Stephen Warren 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 + * Quirk 1: Shortcut interrupts don't set the bank 1/2 register pending bits 16 + * 17 + * If an interrupt fires on bank 1 that isn't in the shortcuts list, bit 8 18 + * on bank 0 is set to signify that an interrupt in bank 1 has fired, and 19 + * to look in the bank 1 status register for more information. 20 + * 21 + * If an interrupt fires on bank 1 that _is_ in the shortcuts list, its 22 + * shortcut bit in bank 0 is set as well as its interrupt bit in the bank 1 23 + * status register, but bank 0 bit 8 is _not_ set. 24 + * 25 + * Quirk 2: You can't mask the register 1/2 pending interrupts 26 + * 27 + * In a proper cascaded interrupt controller, the interrupt lines with 28 + * cascaded interrupt controllers on them are just normal interrupt lines. 29 + * You can mask the interrupts and get on with things. With this controller 30 + * you can't do that. 31 + * 32 + * Quirk 3: The shortcut interrupts can't be (un)masked in bank 0 33 + * 34 + * Those interrupts that have shortcuts can only be masked/unmasked in 35 + * their respective banks' enable/disable registers. Doing so in the bank 0 36 + * enable/disable registers has no effect. 37 + * 38 + * The FIQ control register: 39 + * Bits 0-6: IRQ (index in order of interrupts from banks 1, 2, then 0) 40 + * Bit 7: Enable FIQ generation 41 + * Bits 8+: Unused 42 + * 43 + * An interrupt must be disabled before configuring it for FIQ generation 44 + * otherwise both handlers will fire at the same time! 45 + */ 46 + 47 + #include <linux/io.h> 48 + #include <linux/slab.h> 49 + #include <linux/of_address.h> 50 + #include <linux/of_irq.h> 51 + #include <linux/irqdomain.h> 52 + #include <linux/irqchip/bcm2835.h> 53 + 54 + #include <asm/exception.h> 55 + 56 + /* Put the bank and irq (32 bits) into the hwirq */ 57 + #define MAKE_HWIRQ(b, n) ((b << 5) | (n)) 58 + #define HWIRQ_BANK(i) (i >> 5) 59 + #define HWIRQ_BIT(i) BIT(i & 0x1f) 60 + 61 + #define NR_IRQS_BANK0 8 62 + #define BANK0_HWIRQ_MASK 0xff 63 + /* Shortcuts can't be disabled so any unknown new ones need to be masked */ 64 + #define SHORTCUT1_MASK 0x00007c00 65 + #define SHORTCUT2_MASK 0x001f8000 66 + #define SHORTCUT_SHIFT 10 67 + #define BANK1_HWIRQ BIT(8) 68 + #define BANK2_HWIRQ BIT(9) 69 + #define BANK0_VALID_MASK (BANK0_HWIRQ_MASK | BANK1_HWIRQ | BANK2_HWIRQ \ 70 + | SHORTCUT1_MASK | SHORTCUT2_MASK) 71 + 72 + #define REG_FIQ_CONTROL 0x0c 73 + 74 + #define NR_BANKS 3 75 + #define IRQS_PER_BANK 32 76 + 77 + static int reg_pending[] __initconst = { 0x00, 0x04, 0x08 }; 78 + static int reg_enable[] __initconst = { 0x18, 0x10, 0x14 }; 79 + static int reg_disable[] __initconst = { 0x24, 0x1c, 0x20 }; 80 + static int bank_irqs[] __initconst = { 8, 32, 32 }; 81 + 82 + static const int shortcuts[] = { 83 + 7, 9, 10, 18, 19, /* Bank 1 */ 84 + 21, 22, 23, 24, 25, 30 /* Bank 2 */ 85 + }; 86 + 87 + struct armctrl_ic { 88 + void __iomem *base; 89 + void __iomem *pending[NR_BANKS]; 90 + void __iomem *enable[NR_BANKS]; 91 + void __iomem *disable[NR_BANKS]; 92 + struct irq_domain *domain; 93 + }; 94 + 95 + static struct armctrl_ic intc __read_mostly; 96 + 97 + static void armctrl_mask_irq(struct irq_data *d) 98 + { 99 + writel_relaxed(HWIRQ_BIT(d->hwirq), intc.disable[HWIRQ_BANK(d->hwirq)]); 100 + } 101 + 102 + static void armctrl_unmask_irq(struct irq_data *d) 103 + { 104 + writel_relaxed(HWIRQ_BIT(d->hwirq), intc.enable[HWIRQ_BANK(d->hwirq)]); 105 + } 106 + 107 + static struct irq_chip armctrl_chip = { 108 + .name = "ARMCTRL-level", 109 + .irq_mask = armctrl_mask_irq, 110 + .irq_unmask = armctrl_unmask_irq 111 + }; 112 + 113 + static int armctrl_xlate(struct irq_domain *d, struct device_node *ctrlr, 114 + const u32 *intspec, unsigned int intsize, 115 + unsigned long *out_hwirq, unsigned int *out_type) 116 + { 117 + if (WARN_ON(intsize != 2)) 118 + return -EINVAL; 119 + 120 + if (WARN_ON(intspec[0] >= NR_BANKS)) 121 + return -EINVAL; 122 + 123 + if (WARN_ON(intspec[1] >= IRQS_PER_BANK)) 124 + return -EINVAL; 125 + 126 + if (WARN_ON(intspec[0] == 0 && intspec[1] >= NR_IRQS_BANK0)) 127 + return -EINVAL; 128 + 129 + *out_hwirq = MAKE_HWIRQ(intspec[0], intspec[1]); 130 + *out_type = IRQ_TYPE_NONE; 131 + return 0; 132 + } 133 + 134 + static struct irq_domain_ops armctrl_ops = { 135 + .xlate = armctrl_xlate 136 + }; 137 + 138 + static int __init armctrl_of_init(struct device_node *node, 139 + struct device_node *parent) 140 + { 141 + void __iomem *base; 142 + int irq, b, i; 143 + 144 + base = of_iomap(node, 0); 145 + if (!base) 146 + panic("%s: unable to map IC registers\n", 147 + node->full_name); 148 + 149 + intc.domain = irq_domain_add_linear(node, MAKE_HWIRQ(NR_BANKS, 0), 150 + &armctrl_ops, NULL); 151 + if (!intc.domain) 152 + panic("%s: unable to create IRQ domain\n", node->full_name); 153 + 154 + for (b = 0; b < NR_BANKS; b++) { 155 + intc.pending[b] = base + reg_pending[b]; 156 + intc.enable[b] = base + reg_enable[b]; 157 + intc.disable[b] = base + reg_disable[b]; 158 + 159 + for (i = 0; i < bank_irqs[b]; i++) { 160 + irq = irq_create_mapping(intc.domain, MAKE_HWIRQ(b, i)); 161 + BUG_ON(irq <= 0); 162 + irq_set_chip_and_handler(irq, &armctrl_chip, 163 + handle_level_irq); 164 + set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 165 + } 166 + } 167 + return 0; 168 + } 169 + 170 + static struct of_device_id irq_of_match[] __initconst = { 171 + { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init } 172 + }; 173 + 174 + void __init bcm2835_init_irq(void) 175 + { 176 + of_irq_init(irq_of_match); 177 + } 178 + 179 + /* 180 + * Handle each interrupt across the entire interrupt controller. This reads the 181 + * status register before handling each interrupt, which is necessary given that 182 + * handle_IRQ may briefly re-enable interrupts for soft IRQ handling. 183 + */ 184 + 185 + static void armctrl_handle_bank(int bank, struct pt_regs *regs) 186 + { 187 + u32 stat, irq; 188 + 189 + while ((stat = readl_relaxed(intc.pending[bank]))) { 190 + irq = MAKE_HWIRQ(bank, ffs(stat) - 1); 191 + handle_IRQ(irq_linear_revmap(intc.domain, irq), regs); 192 + } 193 + } 194 + 195 + static void armctrl_handle_shortcut(int bank, struct pt_regs *regs, 196 + u32 stat) 197 + { 198 + u32 irq = MAKE_HWIRQ(bank, shortcuts[ffs(stat >> SHORTCUT_SHIFT) - 1]); 199 + handle_IRQ(irq_linear_revmap(intc.domain, irq), regs); 200 + } 201 + 202 + asmlinkage void __exception_irq_entry bcm2835_handle_irq( 203 + struct pt_regs *regs) 204 + { 205 + u32 stat, irq; 206 + 207 + while ((stat = readl_relaxed(intc.pending[0]) & BANK0_VALID_MASK)) { 208 + if (stat & BANK0_HWIRQ_MASK) { 209 + irq = MAKE_HWIRQ(0, ffs(stat & BANK0_HWIRQ_MASK) - 1); 210 + handle_IRQ(irq_linear_revmap(intc.domain, irq), regs); 211 + } else if (stat & SHORTCUT1_MASK) { 212 + armctrl_handle_shortcut(1, regs, stat & SHORTCUT1_MASK); 213 + } else if (stat & SHORTCUT2_MASK) { 214 + armctrl_handle_shortcut(2, regs, stat & SHORTCUT2_MASK); 215 + } else if (stat & BANK1_HWIRQ) { 216 + armctrl_handle_bank(1, regs); 217 + } else if (stat & BANK2_HWIRQ) { 218 + armctrl_handle_bank(2, regs); 219 + } else { 220 + BUG(); 221 + } 222 + } 223 + }
+22
include/linux/bcm2835_timer.h
··· 1 + /* 2 + * Copyright 2012 Simon Arlott 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 + #ifndef __BCM2835_TIMER_H 16 + #define __BCM2835_TIMER_H 17 + 18 + #include <asm/mach/time.h> 19 + 20 + extern struct sys_timer bcm2835_timer; 21 + 22 + #endif
+24
include/linux/clk/bcm2835.h
··· 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 + * You should have received a copy of the GNU General Public License 15 + * along with this program; if not, write to the Free Software 16 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 + */ 18 + 19 + #ifndef __LINUX_CLK_BCM2835_H_ 20 + #define __LINUX_CLK_BCM2835_H_ 21 + 22 + void __init bcm2835_init_clocks(void); 23 + 24 + #endif
+29
include/linux/irqchip/bcm2835.h
··· 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 + * You should have received a copy of the GNU General Public License 15 + * along with this program; if not, write to the Free Software 16 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 + */ 18 + 19 + #ifndef __LINUX_IRQCHIP_BCM2835_H_ 20 + #define __LINUX_IRQCHIP_BCM2835_H_ 21 + 22 + #include <asm/exception.h> 23 + 24 + extern void bcm2835_init_irq(void); 25 + 26 + extern asmlinkage void __exception_irq_entry bcm2835_handle_irq( 27 + struct pt_regs *regs); 28 + 29 + #endif