1 From 50d8450a9fd5b05873e3b404e2089067920d53c1 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Sun, 12 May 2013 12:24:19 +0100
4 Subject: [PATCH 027/423] Main bcm2708/bcm2709 linux port
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Signed-off-by: popcornmix <popcornmix@gmail.com>
10 Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
12 arch/arm/Kconfig | 49 +++
13 arch/arm/Kconfig.debug | 8 +
14 arch/arm/Makefile | 2 +
15 arch/arm/kernel/head.S | 8 +
16 arch/arm/kernel/process.c | 10 +
17 arch/arm/mach-bcm2708/Kconfig | 23 ++
18 arch/arm/mach-bcm2708/Makefile | 5 +
19 arch/arm/mach-bcm2708/Makefile.boot | 3 +
20 arch/arm/mach-bcm2708/bcm2708.c | 231 ++++++++++++
21 arch/arm/mach-bcm2708/include/mach/debug-macro.S | 22 ++
22 arch/arm/mach-bcm2708/include/mach/io.h | 27 ++
23 arch/arm/mach-bcm2708/include/mach/memory.h | 57 +++
24 arch/arm/mach-bcm2708/include/mach/platform.h | 112 ++++++
25 arch/arm/mach-bcm2708/include/mach/system.h | 37 ++
26 arch/arm/mach-bcm2708/include/mach/uncompress.h | 84 +++++
27 arch/arm/mach-bcm2708/include/mach/vmalloc.h | 20 ++
28 arch/arm/mach-bcm2709/Kconfig | 16 +
29 arch/arm/mach-bcm2709/Makefile | 5 +
30 arch/arm/mach-bcm2709/Makefile.boot | 3 +
31 arch/arm/mach-bcm2709/bcm2709.c | 380 ++++++++++++++++++++
32 arch/arm/mach-bcm2709/include/mach/debug-macro.S | 22 ++
33 arch/arm/mach-bcm2709/include/mach/entry-macro.S | 123 +++++++
34 arch/arm/mach-bcm2709/include/mach/io.h | 27 ++
35 arch/arm/mach-bcm2709/include/mach/memory.h | 57 +++
36 arch/arm/mach-bcm2709/include/mach/platform.h | 188 ++++++++++
37 arch/arm/mach-bcm2709/include/mach/system.h | 37 ++
38 arch/arm/mach-bcm2709/include/mach/uncompress.h | 84 +++++
39 arch/arm/mach-bcm2709/include/mach/vc_mem.h | 35 ++
40 arch/arm/mach-bcm2709/include/mach/vmalloc.h | 20 ++
41 arch/arm/mach-bcm2709/vc_mem.c | 431 +++++++++++++++++++++++
42 arch/arm/mm/Kconfig | 2 +-
43 arch/arm/mm/proc-v6.S | 15 +-
44 arch/arm/mm/proc-v7.S | 1 +
45 arch/arm/tools/mach-types | 2 +
46 drivers/clocksource/Makefile | 2 +-
47 drivers/irqchip/Makefile | 3 +
48 include/linux/mmc/host.h | 1 +
49 37 files changed, 2147 insertions(+), 5 deletions(-)
50 create mode 100644 arch/arm/mach-bcm2708/Kconfig
51 create mode 100644 arch/arm/mach-bcm2708/Makefile
52 create mode 100644 arch/arm/mach-bcm2708/Makefile.boot
53 create mode 100644 arch/arm/mach-bcm2708/bcm2708.c
54 create mode 100644 arch/arm/mach-bcm2708/include/mach/debug-macro.S
55 create mode 100644 arch/arm/mach-bcm2708/include/mach/io.h
56 create mode 100644 arch/arm/mach-bcm2708/include/mach/memory.h
57 create mode 100644 arch/arm/mach-bcm2708/include/mach/platform.h
58 create mode 100644 arch/arm/mach-bcm2708/include/mach/system.h
59 create mode 100644 arch/arm/mach-bcm2708/include/mach/uncompress.h
60 create mode 100644 arch/arm/mach-bcm2708/include/mach/vmalloc.h
61 create mode 100644 arch/arm/mach-bcm2709/Kconfig
62 create mode 100644 arch/arm/mach-bcm2709/Makefile
63 create mode 100644 arch/arm/mach-bcm2709/Makefile.boot
64 create mode 100644 arch/arm/mach-bcm2709/bcm2709.c
65 create mode 100644 arch/arm/mach-bcm2709/include/mach/debug-macro.S
66 create mode 100644 arch/arm/mach-bcm2709/include/mach/entry-macro.S
67 create mode 100644 arch/arm/mach-bcm2709/include/mach/io.h
68 create mode 100644 arch/arm/mach-bcm2709/include/mach/memory.h
69 create mode 100644 arch/arm/mach-bcm2709/include/mach/platform.h
70 create mode 100644 arch/arm/mach-bcm2709/include/mach/system.h
71 create mode 100644 arch/arm/mach-bcm2709/include/mach/uncompress.h
72 create mode 100644 arch/arm/mach-bcm2709/include/mach/vc_mem.h
73 create mode 100644 arch/arm/mach-bcm2709/include/mach/vmalloc.h
74 create mode 100644 arch/arm/mach-bcm2709/vc_mem.c
76 --- a/arch/arm/Kconfig
77 +++ b/arch/arm/Kconfig
78 @@ -318,6 +318,52 @@ choice
79 default ARCH_VERSATILE if !MMU
80 default ARCH_MULTIPLATFORM if MMU
83 + bool "Broadcom BCM2708 family"
87 + select CLKSRC_OF if OF
88 + select HAVE_SCHED_CLOCK
89 + select NEED_MACH_GPIO_H
90 + select NEED_MACH_MEMORY_H
92 + select ARCH_HAS_CPUFREQ
93 + select GENERIC_CLOCKEVENTS
94 + select ARM_ERRATA_411920
96 + select MULTI_IRQ_HANDLER
101 + This enables support for Broadcom BCM2708 boards.
104 + bool "Broadcom BCM2709 family"
108 + select MIGHT_HAVE_CACHE_L2X0
109 + select HAVE_SCHED_CLOCK
110 + select NEED_MACH_MEMORY_H
111 + select NEED_MACH_IO_H
113 + select ARCH_HAS_CPUFREQ
114 + select GENERIC_CLOCKEVENTS
115 + select MACH_BCM2709
116 + select MULTI_IRQ_HANDLER
122 + select ARCH_REQUIRE_GPIOLIB
124 + select PINCTRL_BCM2835
126 + This enables support for Broadcom BCM2709 boards.
128 config ARCH_MULTIPLATFORM
129 bool "Allow multiple platforms to be selected"
131 @@ -809,6 +855,9 @@ config ARCH_VIRT
132 # Kconfigs may be included either alphabetically (according to the
133 # plat- suffix) or along side the corresponding mach-* source.
135 +source "arch/arm/mach-bcm2708/Kconfig"
136 +source "arch/arm/mach-bcm2709/Kconfig"
138 source "arch/arm/mach-mvebu/Kconfig"
140 source "arch/arm/mach-alpine/Kconfig"
141 --- a/arch/arm/Kconfig.debug
142 +++ b/arch/arm/Kconfig.debug
143 @@ -1240,6 +1240,14 @@ choice
144 options; the platform specific options are deprecated
145 and will be soon removed.
147 + config DEBUG_BCM2708_UART0
148 + bool "Broadcom BCM270X UART0 (PL011)"
149 + depends on ARCH_BCM2708 || ARCH_BCM2709
151 + Say Y here if you want the debug print routines to direct
152 + their output to UART 0. The port must have been initialised
153 + by the boot-loader before use.
157 config DEBUG_EXYNOS_UART
158 --- a/arch/arm/Makefile
159 +++ b/arch/arm/Makefile
160 @@ -159,6 +159,8 @@ textofs-$(CONFIG_ARCH_AXXIA) := 0x003080
162 # Machine directory name. This list is sorted alphanumerically
163 # by CONFIG_* macro name.
164 +machine-$(CONFIG_ARCH_BCM2708) += bcm2708
165 +machine-$(CONFIG_ARCH_BCM2709) += bcm2709
166 machine-$(CONFIG_ARCH_ALPINE) += alpine
167 machine-$(CONFIG_ARCH_AT91) += at91
168 machine-$(CONFIG_ARCH_AXXIA) += axxia
169 --- a/arch/arm/kernel/head.S
170 +++ b/arch/arm/kernel/head.S
171 @@ -700,6 +700,14 @@ ARM_BE8(rev16 ip, ip)
172 ldrcc r7, [r4], #4 @ use branch for delay slot
184 ENDPROC(__fixup_a_pv_table)
186 --- a/arch/arm/kernel/process.c
187 +++ b/arch/arm/kernel/process.c
188 @@ -91,6 +91,16 @@ void arch_cpu_idle_exit(void)
189 ledtrig_cpu(CPU_LED_IDLE_END);
192 +char bcm2708_reboot_mode = 'h';
194 +int __init reboot_setup(char *str)
196 + bcm2708_reboot_mode = str[0];
200 +__setup("reboot=", reboot_setup);
202 void __show_regs(struct pt_regs *regs)
206 +++ b/arch/arm/mach-bcm2708/Kconfig
208 +menu "Broadcom BCM2708 Implementations"
209 + depends on ARCH_BCM2708
212 + bool "Broadcom BCM2708 Development Platform"
213 + select NEED_MACH_MEMORY_H
214 + select NEED_MACH_IO_H
217 + select ARCH_REQUIRE_GPIOLIB
219 + select PINCTRL_BCM2835
221 + Include support for the Broadcom(R) BCM2708 platform.
223 +config BCM2708_NOL2CACHE
224 + bool "Videocore L2 cache disable"
225 + depends on MACH_BCM2708
228 + Do not allow ARM to use GPU's L2 cache. Requires disable_l2cache in config.txt.
232 +++ b/arch/arm/mach-bcm2708/Makefile
235 +# Makefile for the linux kernel.
238 +obj-$(CONFIG_MACH_BCM2708) += bcm2708.o
240 +++ b/arch/arm/mach-bcm2708/Makefile.boot
242 + zreladdr-y := 0x00008000
243 +params_phys-y := 0x00000100
244 +initrd_phys-y := 0x00800000
246 +++ b/arch/arm/mach-bcm2708/bcm2708.c
249 + * linux/arch/arm/mach-bcm2708/bcm2708.c
251 + * Copyright (C) 2010 Broadcom
253 + * This program is free software; you can redistribute it and/or modify
254 + * it under the terms of the GNU General Public License as published by
255 + * the Free Software Foundation; either version 2 of the License, or
256 + * (at your option) any later version.
258 + * This program is distributed in the hope that it will be useful,
259 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
260 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
261 + * GNU General Public License for more details.
263 + * You should have received a copy of the GNU General Public License
264 + * along with this program; if not, write to the Free Software
265 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
268 +#include <linux/init.h>
269 +#include <linux/dma-mapping.h>
270 +#include <linux/module.h>
271 +#include <linux/of_platform.h>
272 +#include <asm/system_info.h>
273 +#include <asm/mach-types.h>
274 +#include <asm/mach/arch.h>
275 +#include <asm/mach/map.h>
277 +#include <mach/system.h>
279 +#include <linux/broadcom/vc_cma.h>
281 +/* Effectively we have an IOMMU (ARM<->VideoCore map) that is set up to
282 + * give us IO access only to 64Mbytes of physical memory (26 bits). We could
283 + * represent this window by setting our dmamasks to 26 bits but, in fact
284 + * we're not going to use addresses outside this range (they're not in real
285 + * memory) so we don't bother.
287 + * In the future we might include code to use this IOMMU to remap other
288 + * physical addresses onto VideoCore memory then the use of 32-bits would be
292 +/* command line parameters */
293 +static unsigned boardrev, serial;
294 +static unsigned reboot_part = 0;
296 +static struct map_desc bcm2708_io_desc[] __initdata = {
298 + .virtual = IO_ADDRESS(ARMCTRL_BASE),
299 + .pfn = __phys_to_pfn(ARMCTRL_BASE),
301 + .type = MT_DEVICE},
303 + .virtual = IO_ADDRESS(UART0_BASE),
304 + .pfn = __phys_to_pfn(UART0_BASE),
306 + .type = MT_DEVICE},
308 + .virtual = IO_ADDRESS(UART1_BASE),
309 + .pfn = __phys_to_pfn(UART1_BASE),
311 + .type = MT_DEVICE},
313 + .virtual = IO_ADDRESS(DMA_BASE),
314 + .pfn = __phys_to_pfn(DMA_BASE),
316 + .type = MT_DEVICE},
318 + .virtual = IO_ADDRESS(MCORE_BASE),
319 + .pfn = __phys_to_pfn(MCORE_BASE),
321 + .type = MT_DEVICE},
323 + .virtual = IO_ADDRESS(ST_BASE),
324 + .pfn = __phys_to_pfn(ST_BASE),
326 + .type = MT_DEVICE},
328 + .virtual = IO_ADDRESS(USB_BASE),
329 + .pfn = __phys_to_pfn(USB_BASE),
331 + .type = MT_DEVICE},
333 + .virtual = IO_ADDRESS(PM_BASE),
334 + .pfn = __phys_to_pfn(PM_BASE),
336 + .type = MT_DEVICE},
338 + .virtual = IO_ADDRESS(GPIO_BASE),
339 + .pfn = __phys_to_pfn(GPIO_BASE),
344 +void __init bcm2708_map_io(void)
346 + iotable_init(bcm2708_io_desc, ARRAY_SIZE(bcm2708_io_desc));
349 +int calc_rsts(int partition)
351 + return PM_PASSWORD |
352 + ((partition & (1 << 0)) << 0) |
353 + ((partition & (1 << 1)) << 1) |
354 + ((partition & (1 << 2)) << 2) |
355 + ((partition & (1 << 3)) << 3) |
356 + ((partition & (1 << 4)) << 4) |
357 + ((partition & (1 << 5)) << 5);
360 +static void bcm2708_restart(enum reboot_mode mode, const char *cmd)
362 + extern char bcm2708_reboot_mode;
363 + uint32_t pm_rstc, pm_wdog;
364 + uint32_t timeout = 10;
365 + uint32_t pm_rsts = 0;
367 + if(bcm2708_reboot_mode == 'q')
369 + // NOOBS < 1.3 booting with reboot=q
370 + pm_rsts = readl(__io_address(PM_RSTS));
371 + pm_rsts = PM_PASSWORD | pm_rsts | PM_RSTS_HADWRQ_SET;
373 + else if(bcm2708_reboot_mode == 'p')
375 + // NOOBS < 1.3 halting
376 + pm_rsts = readl(__io_address(PM_RSTS));
377 + pm_rsts = PM_PASSWORD | pm_rsts | PM_RSTS_HADWRH_SET;
381 + pm_rsts = calc_rsts(reboot_part);
384 + writel(pm_rsts, __io_address(PM_RSTS));
386 + /* Setup watchdog for reset */
387 + pm_rstc = readl(__io_address(PM_RSTC));
389 + pm_wdog = PM_PASSWORD | (timeout & PM_WDOG_TIME_SET); // watchdog timer = timer clock / 16; need password (31:16) + value (11:0)
390 + pm_rstc = PM_PASSWORD | (pm_rstc & PM_RSTC_WRCFG_CLR) | PM_RSTC_WRCFG_FULL_RESET;
392 + writel(pm_wdog, __io_address(PM_WDOG));
393 + writel(pm_rstc, __io_address(PM_RSTC));
396 +/* We can't really power off, but if we do the normal reset scheme, and indicate to bootcode.bin not to reboot, then most of the chip will be powered off */
397 +static void bcm2708_power_off(void)
399 + extern char bcm2708_reboot_mode;
400 + if(bcm2708_reboot_mode == 'q')
403 + bcm2708_restart('p', "");
407 + /* partition 63 is special code for HALT the bootloader knows not to boot*/
409 + /* continue with normal reset mechanism */
410 + bcm2708_restart(0, "");
414 +static void __init bcm2708_init_uart1(void)
416 + struct device_node *np;
418 + np = of_find_compatible_node(NULL, NULL, "brcm,bcm2835-aux-uart");
419 + if (of_device_is_available(np)) {
420 + pr_info("bcm2708: Mini UART enabled\n");
421 + writel(1, __io_address(UART1_BASE + 0x4));
425 +void __init bcm2708_init(void)
429 + vc_cma_early_init();
431 + pm_power_off = bcm2708_power_off;
433 + ret = of_platform_populate(NULL, of_default_bus_match_table, NULL,
436 + pr_err("of_platform_populate failed: %d\n", ret);
440 + bcm2708_init_uart1();
442 + system_rev = boardrev;
443 + system_serial_low = serial;
446 +void __init bcm2708_init_early(void)
449 + * Some devices allocate their coherent buffers from atomic
450 + * context. Increase size of atomic coherent pool to make sure such
451 + * the allocations won't fail.
453 + init_dma_coherent_pool_size(SZ_4M);
456 +static void __init board_reserve(void)
461 +static const char * const bcm2708_compat[] = {
466 +MACHINE_START(BCM2708, "BCM2708")
467 + /* Maintainer: Broadcom Europe Ltd. */
468 + .map_io = bcm2708_map_io,
469 + .init_machine = bcm2708_init,
470 + .init_early = bcm2708_init_early,
471 + .reserve = board_reserve,
472 + .restart = bcm2708_restart,
473 + .dt_compat = bcm2708_compat,
476 +module_param(boardrev, uint, 0644);
477 +module_param(serial, uint, 0644);
478 +module_param(reboot_part, uint, 0644);
480 +++ b/arch/arm/mach-bcm2708/include/mach/debug-macro.S
482 +/* arch/arm/mach-bcm2708/include/mach/debug-macro.S
484 + * Debugging macro include header
486 + * Copyright (C) 2010 Broadcom
487 + * Copyright (C) 1994-1999 Russell King
488 + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
490 + * This program is free software; you can redistribute it and/or modify
491 + * it under the terms of the GNU General Public License version 2 as
492 + * published by the Free Software Foundation.
496 +#include <mach/platform.h>
498 + .macro addruart, rp, rv, tmp
499 + ldr \rp, =UART0_BASE
500 + ldr \rv, =IO_ADDRESS(UART0_BASE)
503 +#include <debug/pl01x.S>
505 +++ b/arch/arm/mach-bcm2708/include/mach/io.h
508 + * arch/arm/mach-bcm2708/include/mach/io.h
510 + * Copyright (C) 2003 ARM Limited
512 + * This program is free software; you can redistribute it and/or modify
513 + * it under the terms of the GNU General Public License as published by
514 + * the Free Software Foundation; either version 2 of the License, or
515 + * (at your option) any later version.
517 + * This program is distributed in the hope that it will be useful,
518 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
519 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
520 + * GNU General Public License for more details.
522 + * You should have received a copy of the GNU General Public License
523 + * along with this program; if not, write to the Free Software
524 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
526 +#ifndef __ASM_ARM_ARCH_IO_H
527 +#define __ASM_ARM_ARCH_IO_H
529 +#define IO_SPACE_LIMIT 0xffffffff
531 +#define __io(a) __typesafe_io(a)
535 +++ b/arch/arm/mach-bcm2708/include/mach/memory.h
538 + * arch/arm/mach-bcm2708/include/mach/memory.h
540 + * Copyright (C) 2010 Broadcom
542 + * This program is free software; you can redistribute it and/or modify
543 + * it under the terms of the GNU General Public License as published by
544 + * the Free Software Foundation; either version 2 of the License, or
545 + * (at your option) any later version.
547 + * This program is distributed in the hope that it will be useful,
548 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
549 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
550 + * GNU General Public License for more details.
552 + * You should have received a copy of the GNU General Public License
553 + * along with this program; if not, write to the Free Software
554 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
556 +#ifndef __ASM_ARCH_MEMORY_H
557 +#define __ASM_ARCH_MEMORY_H
561 + [ARMcore] <--virtual addr-->
562 + [ARMmmu] <--physical addr-->
563 + [GERTmap] <--bus add-->
569 + * Physical DRAM offset.
571 +#define BCM_PLAT_PHYS_OFFSET UL(0x00000000)
572 +#define VC_ARMMEM_OFFSET UL(0x00000000) /* offset in VC of ARM memory */
574 +#ifdef CONFIG_BCM2708_NOL2CACHE
575 + #define _REAL_BUS_OFFSET UL(0xC0000000) /* don't use L1 or L2 caches */
577 + #define _REAL_BUS_OFFSET UL(0x40000000) /* use L2 cache */
580 +/* We're using the memory at 64M in the VideoCore for Linux - this adjustment
581 + * will provide the offset into this area as well as setting the bits that
582 + * stop the L1 and L2 cache from being used
584 + * WARNING: this only works because the ARM is given memory at a fixed location
587 +#define BUS_OFFSET (VC_ARMMEM_OFFSET + _REAL_BUS_OFFSET)
588 +#define __virt_to_bus(x) ((x) + (BUS_OFFSET - PAGE_OFFSET))
589 +#define __bus_to_virt(x) ((x) - (BUS_OFFSET - PAGE_OFFSET))
590 +#define __pfn_to_bus(x) (__pfn_to_phys(x) + (BUS_OFFSET - BCM_PLAT_PHYS_OFFSET))
591 +#define __bus_to_pfn(x) __phys_to_pfn((x) - (BUS_OFFSET - BCM_PLAT_PHYS_OFFSET))
595 +++ b/arch/arm/mach-bcm2708/include/mach/platform.h
598 + * arch/arm/mach-bcm2708/include/mach/platform.h
600 + * Copyright (C) 2010 Broadcom
602 + * This program is free software; you can redistribute it and/or modify
603 + * it under the terms of the GNU General Public License as published by
604 + * the Free Software Foundation; either version 2 of the License, or
605 + * (at your option) any later version.
607 + * This program is distributed in the hope that it will be useful,
608 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
609 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
610 + * GNU General Public License for more details.
612 + * You should have received a copy of the GNU General Public License
613 + * along with this program; if not, write to the Free Software
614 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
617 +#ifndef _BCM2708_PLATFORM_H
618 +#define _BCM2708_PLATFORM_H
621 +/* macros to get at IO space when running virtually */
622 +#define IO_ADDRESS(x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
624 +#define __io_address(n) IOMEM(IO_ADDRESS(n))
630 +#define BCM2708_SDRAM_BASE 0x00000000
633 + * Logic expansion modules
638 +/* ------------------------------------------------------------------------
639 + * BCM2708 ARMCTRL Registers
640 + * ------------------------------------------------------------------------
643 +#define HW_REGISTER_RW(addr) (addr)
644 +#define HW_REGISTER_RO(addr) (addr)
647 + * Definitions and addresses for the ARM CONTROL logic
648 + * This file is manually generated.
651 +#define BCM2708_PERI_BASE 0x20000000
652 +#define IC0_BASE (BCM2708_PERI_BASE + 0x2000)
653 +#define ST_BASE (BCM2708_PERI_BASE + 0x3000) /* System Timer */
654 +#define MPHI_BASE (BCM2708_PERI_BASE + 0x6000) /* Message -based Parallel Host Interface */
655 +#define DMA_BASE (BCM2708_PERI_BASE + 0x7000) /* DMA controller */
656 +#define ARM_BASE (BCM2708_PERI_BASE + 0xB000) /* BCM2708 ARM control block */
657 +#define PM_BASE (BCM2708_PERI_BASE + 0x100000) /* Power Management, Reset controller and Watchdog registers */
658 +#define PCM_CLOCK_BASE (BCM2708_PERI_BASE + 0x101098) /* PCM Clock */
659 +#define RNG_BASE (BCM2708_PERI_BASE + 0x104000) /* Hardware RNG */
660 +#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO */
661 +#define UART0_BASE (BCM2708_PERI_BASE + 0x201000) /* Uart 0 */
662 +#define MMCI0_BASE (BCM2708_PERI_BASE + 0x202000) /* MMC interface */
663 +#define I2S_BASE (BCM2708_PERI_BASE + 0x203000) /* I2S */
664 +#define SPI0_BASE (BCM2708_PERI_BASE + 0x204000) /* SPI0 */
665 +#define BSC0_BASE (BCM2708_PERI_BASE + 0x205000) /* BSC0 I2C/TWI */
666 +#define UART1_BASE (BCM2708_PERI_BASE + 0x215000) /* Uart 1 */
667 +#define EMMC_BASE (BCM2708_PERI_BASE + 0x300000) /* eMMC interface */
668 +#define SMI_BASE (BCM2708_PERI_BASE + 0x600000) /* SMI */
669 +#define BSC1_BASE (BCM2708_PERI_BASE + 0x804000) /* BSC1 I2C/TWI */
670 +#define USB_BASE (BCM2708_PERI_BASE + 0x980000) /* DTC_OTG USB controller */
671 +#define MCORE_BASE (BCM2708_PERI_BASE + 0x0000) /* Fake frame buffer device (actually the multicore sync block*/
673 +#define ARMCTRL_BASE (ARM_BASE + 0x000)
674 +#define ARMCTRL_IC_BASE (ARM_BASE + 0x200) /* ARM interrupt controller */
675 +#define ARMCTRL_TIMER0_1_BASE (ARM_BASE + 0x400) /* Timer 0 and 1 */
676 +#define ARMCTRL_0_SBM_BASE (ARM_BASE + 0x800) /* User 0 (ARM)'s Semaphores Doorbells and Mailboxes */
681 +#define PM_RSTC (PM_BASE+0x1c)
682 +#define PM_RSTS (PM_BASE+0x20)
683 +#define PM_WDOG (PM_BASE+0x24)
685 +#define PM_WDOG_RESET 0000000000
686 +#define PM_PASSWORD 0x5a000000
687 +#define PM_WDOG_TIME_SET 0x000fffff
688 +#define PM_RSTC_WRCFG_CLR 0xffffffcf
689 +#define PM_RSTC_WRCFG_SET 0x00000030
690 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020
691 +#define PM_RSTC_RESET 0x00000102
693 +#define PM_RSTS_HADPOR_SET 0x00001000
694 +#define PM_RSTS_HADSRH_SET 0x00000400
695 +#define PM_RSTS_HADSRF_SET 0x00000200
696 +#define PM_RSTS_HADSRQ_SET 0x00000100
697 +#define PM_RSTS_HADWRH_SET 0x00000040
698 +#define PM_RSTS_HADWRF_SET 0x00000020
699 +#define PM_RSTS_HADWRQ_SET 0x00000010
700 +#define PM_RSTS_HADDRH_SET 0x00000004
701 +#define PM_RSTS_HADDRF_SET 0x00000002
702 +#define PM_RSTS_HADDRQ_SET 0x00000001
704 +#define UART0_CLOCK 3000000
710 +++ b/arch/arm/mach-bcm2708/include/mach/system.h
713 + * arch/arm/mach-bcm2708/include/mach/system.h
715 + * Copyright (C) 2010 Broadcom
716 + * Copyright (C) 2003 ARM Limited
717 + * Copyright (C) 2000 Deep Blue Solutions Ltd
719 + * This program is free software; you can redistribute it and/or modify
720 + * it under the terms of the GNU General Public License as published by
721 + * the Free Software Foundation; either version 2 of the License, or
722 + * (at your option) any later version.
724 + * This program is distributed in the hope that it will be useful,
725 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
726 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
727 + * GNU General Public License for more details.
729 + * You should have received a copy of the GNU General Public License
730 + * along with this program; if not, write to the Free Software
731 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
733 +#ifndef __ASM_ARCH_SYSTEM_H
734 +#define __ASM_ARCH_SYSTEM_H
736 +#include <linux/io.h>
737 +#include <mach/platform.h>
739 +static inline void arch_idle(void)
742 + * This should do all the clock switching
743 + * and wait for interrupt tricks
750 +++ b/arch/arm/mach-bcm2708/include/mach/uncompress.h
753 + * arch/arm/mach-bcn2708/include/mach/uncompress.h
755 + * Copyright (C) 2010 Broadcom
756 + * Copyright (C) 2003 ARM Limited
758 + * This program is free software; you can redistribute it and/or modify
759 + * it under the terms of the GNU General Public License as published by
760 + * the Free Software Foundation; either version 2 of the License, or
761 + * (at your option) any later version.
763 + * This program is distributed in the hope that it will be useful,
764 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
765 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
766 + * GNU General Public License for more details.
768 + * You should have received a copy of the GNU General Public License
769 + * along with this program; if not, write to the Free Software
770 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
773 +#include <linux/io.h>
774 +#include <linux/amba/serial.h>
775 +#include <mach/platform.h>
777 +#define UART_BAUD 115200
779 +#define BCM2708_UART_DR __io(UART0_BASE + UART01x_DR)
780 +#define BCM2708_UART_FR __io(UART0_BASE + UART01x_FR)
781 +#define BCM2708_UART_IBRD __io(UART0_BASE + UART011_IBRD)
782 +#define BCM2708_UART_FBRD __io(UART0_BASE + UART011_FBRD)
783 +#define BCM2708_UART_LCRH __io(UART0_BASE + UART011_LCRH)
784 +#define BCM2708_UART_CR __io(UART0_BASE + UART011_CR)
787 + * This does not append a newline
789 +static inline void putc(int c)
791 + while (__raw_readl(BCM2708_UART_FR) & UART01x_FR_TXFF)
794 + __raw_writel(c, BCM2708_UART_DR);
797 +static inline void flush(void)
802 + fr = __raw_readl(BCM2708_UART_FR);
804 + } while ((fr & (UART011_FR_TXFE | UART01x_FR_BUSY)) != UART011_FR_TXFE);
807 +static inline void arch_decomp_setup(void)
809 + int temp, div, rem, frac;
811 + temp = 16 * UART_BAUD;
812 + div = UART0_CLOCK / temp;
813 + rem = UART0_CLOCK % temp;
814 + temp = (8 * rem) / UART_BAUD;
815 + frac = (temp >> 1) + (temp & 1);
817 + /* Make sure the UART is disabled before we start */
818 + __raw_writel(0, BCM2708_UART_CR);
820 + /* Set the baud rate */
821 + __raw_writel(div, BCM2708_UART_IBRD);
822 + __raw_writel(frac, BCM2708_UART_FBRD);
824 + /* Set the UART to 8n1, FIFO enabled */
825 + __raw_writel(UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN, BCM2708_UART_LCRH);
827 + /* Enable the UART */
828 + __raw_writel(UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_RXE,
835 +#define arch_decomp_wdog()
837 +++ b/arch/arm/mach-bcm2708/include/mach/vmalloc.h
840 + * arch/arm/mach-bcm2708/include/mach/vmalloc.h
842 + * Copyright (C) 2010 Broadcom
844 + * This program is free software; you can redistribute it and/or modify
845 + * it under the terms of the GNU General Public License as published by
846 + * the Free Software Foundation; either version 2 of the License, or
847 + * (at your option) any later version.
849 + * This program is distributed in the hope that it will be useful,
850 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
851 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
852 + * GNU General Public License for more details.
854 + * You should have received a copy of the GNU General Public License
855 + * along with this program; if not, write to the Free Software
856 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
858 +#define VMALLOC_END (0xe8000000)
860 +++ b/arch/arm/mach-bcm2709/Kconfig
862 +menu "Broadcom BCM2709 Implementations"
863 + depends on ARCH_BCM2709
866 + bool "Broadcom BCM2709 Development Platform"
868 + Include support for the Broadcom(R) BCM2709 platform.
870 +config BCM2708_NOL2CACHE
871 + bool "Videocore L2 cache disable"
872 + depends on MACH_BCM2709
875 + Do not allow ARM to use GPU's L2 cache. Requires disable_l2cache in config.txt.
879 +++ b/arch/arm/mach-bcm2709/Makefile
882 +# Makefile for the linux kernel.
885 +obj-$(CONFIG_MACH_BCM2709) += bcm2709.o
887 +++ b/arch/arm/mach-bcm2709/Makefile.boot
889 + zreladdr-y := 0x00008000
890 +params_phys-y := 0x00000100
891 +initrd_phys-y := 0x00800000
893 +++ b/arch/arm/mach-bcm2709/bcm2709.c
896 + * linux/arch/arm/mach-bcm2709/bcm2709.c
898 + * Copyright (C) 2010 Broadcom
900 + * This program is free software; you can redistribute it and/or modify
901 + * it under the terms of the GNU General Public License as published by
902 + * the Free Software Foundation; either version 2 of the License, or
903 + * (at your option) any later version.
905 + * This program is distributed in the hope that it will be useful,
906 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
907 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
908 + * GNU General Public License for more details.
910 + * You should have received a copy of the GNU General Public License
911 + * along with this program; if not, write to the Free Software
912 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
915 +#include <linux/init.h>
916 +#include <linux/dma-mapping.h>
917 +#include <linux/interrupt.h>
918 +#include <linux/clk-provider.h>
919 +#include <linux/clocksource.h>
920 +#include <linux/io.h>
921 +#include <linux/module.h>
922 +#include <linux/of_platform.h>
924 +#include <asm/system_info.h>
925 +#include <asm/mach-types.h>
926 +#include <asm/cputype.h>
928 +#include <asm/mach/arch.h>
929 +#include <asm/mach/map.h>
931 +#include <mach/system.h>
933 +#include <linux/broadcom/vc_cma.h>
935 +/* Effectively we have an IOMMU (ARM<->VideoCore map) that is set up to
936 + * give us IO access only to 64Mbytes of physical memory (26 bits). We could
937 + * represent this window by setting our dmamasks to 26 bits but, in fact
938 + * we're not going to use addresses outside this range (they're not in real
939 + * memory) so we don't bother.
941 + * In the future we might include code to use this IOMMU to remap other
942 + * physical addresses onto VideoCore memory then the use of 32-bits would be
946 +/* command line parameters */
947 +static unsigned boardrev, serial;
948 +static unsigned reboot_part = 0;
950 +static struct map_desc bcm2709_io_desc[] __initdata = {
952 + .virtual = IO_ADDRESS(ARMCTRL_BASE),
953 + .pfn = __phys_to_pfn(ARMCTRL_BASE),
955 + .type = MT_DEVICE},
957 + .virtual = IO_ADDRESS(UART0_BASE),
958 + .pfn = __phys_to_pfn(UART0_BASE),
960 + .type = MT_DEVICE},
962 + .virtual = IO_ADDRESS(UART1_BASE),
963 + .pfn = __phys_to_pfn(UART1_BASE),
965 + .type = MT_DEVICE},
967 + .virtual = IO_ADDRESS(DMA_BASE),
968 + .pfn = __phys_to_pfn(DMA_BASE),
970 + .type = MT_DEVICE},
972 + .virtual = IO_ADDRESS(MCORE_BASE),
973 + .pfn = __phys_to_pfn(MCORE_BASE),
975 + .type = MT_DEVICE},
977 + .virtual = IO_ADDRESS(ST_BASE),
978 + .pfn = __phys_to_pfn(ST_BASE),
980 + .type = MT_DEVICE},
982 + .virtual = IO_ADDRESS(USB_BASE),
983 + .pfn = __phys_to_pfn(USB_BASE),
985 + .type = MT_DEVICE},
987 + .virtual = IO_ADDRESS(PM_BASE),
988 + .pfn = __phys_to_pfn(PM_BASE),
990 + .type = MT_DEVICE},
992 + .virtual = IO_ADDRESS(GPIO_BASE),
993 + .pfn = __phys_to_pfn(GPIO_BASE),
995 + .type = MT_DEVICE},
997 + .virtual = IO_ADDRESS(ARM_LOCAL_BASE),
998 + .pfn = __phys_to_pfn(ARM_LOCAL_BASE),
1000 + .type = MT_DEVICE},
1003 +void __init bcm2709_map_io(void)
1005 + iotable_init(bcm2709_io_desc, ARRAY_SIZE(bcm2709_io_desc));
1008 +int calc_rsts(int partition)
1010 + return PM_PASSWORD |
1011 + ((partition & (1 << 0)) << 0) |
1012 + ((partition & (1 << 1)) << 1) |
1013 + ((partition & (1 << 2)) << 2) |
1014 + ((partition & (1 << 3)) << 3) |
1015 + ((partition & (1 << 4)) << 4) |
1016 + ((partition & (1 << 5)) << 5);
1019 +static void bcm2709_restart(enum reboot_mode mode, const char *cmd)
1021 + extern char bcm2708_reboot_mode;
1022 + uint32_t pm_rstc, pm_wdog;
1023 + uint32_t timeout = 10;
1024 + uint32_t pm_rsts = 0;
1026 + if(bcm2708_reboot_mode == 'q')
1028 + // NOOBS < 1.3 booting with reboot=q
1029 + pm_rsts = readl(__io_address(PM_RSTS));
1030 + pm_rsts = PM_PASSWORD | pm_rsts | PM_RSTS_HADWRQ_SET;
1032 + else if(bcm2708_reboot_mode == 'p')
1034 + // NOOBS < 1.3 halting
1035 + pm_rsts = readl(__io_address(PM_RSTS));
1036 + pm_rsts = PM_PASSWORD | pm_rsts | PM_RSTS_HADWRH_SET;
1040 + pm_rsts = calc_rsts(reboot_part);
1043 + writel(pm_rsts, __io_address(PM_RSTS));
1045 + /* Setup watchdog for reset */
1046 + pm_rstc = readl(__io_address(PM_RSTC));
1048 + pm_wdog = PM_PASSWORD | (timeout & PM_WDOG_TIME_SET); // watchdog timer = timer clock / 16; need password (31:16) + value (11:0)
1049 + pm_rstc = PM_PASSWORD | (pm_rstc & PM_RSTC_WRCFG_CLR) | PM_RSTC_WRCFG_FULL_RESET;
1051 + writel(pm_wdog, __io_address(PM_WDOG));
1052 + writel(pm_rstc, __io_address(PM_RSTC));
1055 +/* We can't really power off, but if we do the normal reset scheme, and indicate to bootcode.bin not to reboot, then most of the chip will be powered off */
1056 +static void bcm2709_power_off(void)
1058 + extern char bcm2708_reboot_mode;
1059 + if(bcm2708_reboot_mode == 'q')
1062 + bcm2709_restart('p', "");
1066 + /* partition 63 is special code for HALT the bootloader knows not to boot*/
1068 + /* continue with normal reset mechanism */
1069 + bcm2709_restart(0, "");
1073 +static void __init bcm2709_init_uart1(void)
1075 + struct device_node *np;
1077 + np = of_find_compatible_node(NULL, NULL, "brcm,bcm2835-aux-uart");
1078 + if (of_device_is_available(np)) {
1079 + pr_info("bcm2709: Mini UART enabled\n");
1080 + writel(1, __io_address(UART1_BASE + 0x4));
1084 +void __init bcm2709_init(void)
1088 + vc_cma_early_init();
1090 + pm_power_off = bcm2709_power_off;
1092 + ret = of_platform_populate(NULL, of_default_bus_match_table, NULL,
1095 + pr_err("of_platform_populate failed: %d\n", ret);
1099 + bcm2709_init_uart1();
1101 + system_rev = boardrev;
1102 + system_serial_low = serial;
1105 +static void __init bcm2709_timer_init(void)
1108 + writel(0, __io_address(ARM_LOCAL_CONTROL));
1109 + // timer pre_scaler
1110 + writel(0x80000000, __io_address(ARM_LOCAL_PRESCALER)); // 19.2MHz
1111 + //writel(0x06AAAAAB, __io_address(ARM_LOCAL_PRESCALER)); // 1MHz
1113 + of_clk_init(NULL);
1114 + clocksource_probe();
1118 +void __init bcm2709_init_early(void)
1121 + * Some devices allocate their coherent buffers from atomic
1122 + * context. Increase size of atomic coherent pool to make sure such
1123 + * the allocations won't fail.
1125 + init_dma_coherent_pool_size(SZ_4M);
1128 +static void __init board_reserve(void)
1135 +#include <linux/smp.h>
1137 +#include <asm/cacheflush.h>
1138 +#include <asm/smp_plat.h>
1140 +//void dc4_log(unsigned x) { if (dc4) writel((x), __io_address(ST_BASE+10 + raw_smp_processor_id()*4)); }
1141 +void dc4_log_dead(unsigned x) { if (dc4) writel((readl(__io_address(ST_BASE+0x10 + raw_smp_processor_id()*4)) & 0xffff) | ((x)<<16), __io_address(ST_BASE+0x10 + raw_smp_processor_id()*4)); }
1143 +static void bcm2835_send_doorbell(const struct cpumask *mask, unsigned int irq)
1147 + * Ensure that stores to Normal memory are visible to the
1148 + * other CPUs before issuing the IPI.
1152 + /* Convert our logical CPU mask into a physical one. */
1153 + for_each_cpu(cpu, mask)
1155 + /* submit softirq */
1156 + writel(1<<irq, __io_address(ARM_LOCAL_MAILBOX0_SET0 + 0x10 * MPIDR_AFFINITY_LEVEL(cpu_logical_map(cpu), 0)));
1160 +void __init bcm2709_smp_init_cpus(void)
1162 + void secondary_startup(void);
1163 + unsigned int i, ncores;
1165 + ncores = 4; // xxx scu_get_core_count(NULL);
1166 + printk("[%s] enter (%x->%x)\n", __FUNCTION__, (unsigned)virt_to_phys((void *)secondary_startup), (unsigned)__io_address(ST_BASE + 0x10));
1167 + printk("[%s] ncores=%d\n", __FUNCTION__, ncores);
1169 + for (i = 0; i < ncores; i++) {
1170 + set_cpu_possible(i, true);
1171 + /* enable IRQ (not FIQ) */
1172 + writel(0x1, __io_address(ARM_LOCAL_MAILBOX_INT_CONTROL0 + 0x4 * i));
1173 + //writel(0xf, __io_address(ARM_LOCAL_TIMER_INT_CONTROL0 + 0x4 * i));
1175 + set_smp_cross_call(bcm2835_send_doorbell);
1179 + * for arch/arm/kernel/smp.c:smp_prepare_cpus(unsigned int max_cpus)
1181 +void __init bcm2709_smp_prepare_cpus(unsigned int max_cpus)
1183 + //void __iomem *scu_base;
1185 + printk("[%s] enter\n", __FUNCTION__);
1186 + //scu_base = scu_base_addr();
1187 + //scu_enable(scu_base);
1191 + * for linux/arch/arm/kernel/smp.c:secondary_start_kernel(void)
1193 +void __init bcm2709_secondary_init(unsigned int cpu)
1195 + printk("[%s] enter cpu:%d\n", __FUNCTION__, cpu);
1196 + //gic_secondary_init(0);
1200 + * for linux/arch/arm/kernel/smp.c:__cpu_up(..)
1202 +int __init bcm2709_boot_secondary(unsigned int cpu, struct task_struct *idle)
1204 + void secondary_startup(void);
1205 + void *mbox_set = __io_address(ARM_LOCAL_MAILBOX3_SET0 + 0x10 * MPIDR_AFFINITY_LEVEL(cpu_logical_map(cpu), 0));
1206 + void *mbox_clr = __io_address(ARM_LOCAL_MAILBOX3_CLR0 + 0x10 * MPIDR_AFFINITY_LEVEL(cpu_logical_map(cpu), 0));
1207 + unsigned secondary_boot = (unsigned)virt_to_phys((void *)secondary_startup);
1210 + //printk("[%s] enter cpu:%d (%x->%p) %x\n", __FUNCTION__, cpu, secondary_boot, wake, readl(wake));
1213 + BUG_ON(readl(mbox_clr) != 0);
1214 + writel(secondary_boot, mbox_set);
1216 + while (--timeout > 0) {
1217 + t = readl(mbox_clr);
1218 + if (t == 0) break;
1222 + printk("[%s] cpu:%d failed to start (%x)\n", __FUNCTION__, cpu, t);
1224 + printk("[%s] cpu:%d started (%x) %d\n", __FUNCTION__, cpu, t, timeout);
1230 +struct smp_operations bcm2709_smp_ops __initdata = {
1231 + .smp_init_cpus = bcm2709_smp_init_cpus,
1232 + .smp_prepare_cpus = bcm2709_smp_prepare_cpus,
1233 + .smp_secondary_init = bcm2709_secondary_init,
1234 + .smp_boot_secondary = bcm2709_boot_secondary,
1238 +static const char * const bcm2709_compat[] = {
1240 + "brcm,bcm2708", /* Could use bcm2708 in a pinch */
1244 +MACHINE_START(BCM2709, "BCM2709")
1245 + /* Maintainer: Broadcom Europe Ltd. */
1247 + .smp = smp_ops(bcm2709_smp_ops),
1249 + .map_io = bcm2709_map_io,
1250 + .init_time = bcm2709_timer_init,
1251 + .init_machine = bcm2709_init,
1252 + .init_early = bcm2709_init_early,
1253 + .reserve = board_reserve,
1254 + .restart = bcm2709_restart,
1255 + .dt_compat = bcm2709_compat,
1258 +MACHINE_START(BCM2708, "BCM2709")
1259 + /* Maintainer: Broadcom Europe Ltd. */
1261 + .smp = smp_ops(bcm2709_smp_ops),
1263 + .map_io = bcm2709_map_io,
1264 + .init_time = bcm2709_timer_init,
1265 + .init_machine = bcm2709_init,
1266 + .init_early = bcm2709_init_early,
1267 + .reserve = board_reserve,
1268 + .restart = bcm2709_restart,
1269 + .dt_compat = bcm2709_compat,
1272 +module_param(boardrev, uint, 0644);
1273 +module_param(serial, uint, 0644);
1274 +module_param(reboot_part, uint, 0644);
1276 +++ b/arch/arm/mach-bcm2709/include/mach/debug-macro.S
1278 +/* arch/arm/mach-bcm2708/include/mach/debug-macro.S
1280 + * Debugging macro include header
1282 + * Copyright (C) 2010 Broadcom
1283 + * Copyright (C) 1994-1999 Russell King
1284 + * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
1286 + * This program is free software; you can redistribute it and/or modify
1287 + * it under the terms of the GNU General Public License version 2 as
1288 + * published by the Free Software Foundation.
1292 +#include <mach/platform.h>
1294 + .macro addruart, rp, rv, tmp
1295 + ldr \rp, =UART0_BASE
1296 + ldr \rv, =IO_ADDRESS(UART0_BASE)
1299 +#include <debug/pl01x.S>
1301 +++ b/arch/arm/mach-bcm2709/include/mach/entry-macro.S
1304 + * arch/arm/mach-bcm2708/include/mach/entry-macro.S
1306 + * Low-level IRQ helper macros for BCM2708 platforms
1308 + * Copyright (C) 2010 Broadcom
1310 + * This program is free software; you can redistribute it and/or modify
1311 + * it under the terms of the GNU General Public License as published by
1312 + * the Free Software Foundation; either version 2 of the License, or
1313 + * (at your option) any later version.
1315 + * This program is distributed in the hope that it will be useful,
1316 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1317 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1318 + * GNU General Public License for more details.
1320 + * You should have received a copy of the GNU General Public License
1321 + * along with this program; if not, write to the Free Software
1322 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1324 +#include <mach/hardware.h>
1325 +#include <mach/irqs.h>
1327 + .macro disable_fiq
1330 + .macro get_irqnr_preamble, base, tmp
1331 + ldr \base, =IO_ADDRESS(ARMCTRL_IC_BASE)
1334 + .macro arch_ret_to_user, tmp1, tmp2
1337 + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
1338 + /* get core number */
1339 + mrc p15, 0, \tmp, c0, c0, 5
1340 + ubfx \tmp, \tmp, #0, #2
1342 + /* get core's local interrupt controller */
1343 + ldr \irqstat, = __io_address(ARM_LOCAL_IRQ_PENDING0) @ local interrupt source
1344 + add \irqstat, \irqstat, \tmp, lsl #2
1345 + ldr \tmp, [\irqstat]
1346 + /* ignore gpu interrupt */
1348 + /* ignore mailbox interrupts */
1352 + @ For non-zero x, LSB(x) = 31 - CLZ(x^(x-1))
1353 + @ N.B. CLZ is an ARM5 instruction.
1354 + mov \irqnr, #(ARM_IRQ_LOCAL_BASE + 31)
1355 + sub \irqstat, \tmp, #1
1356 + eor \irqstat, \irqstat, \tmp
1357 + clz \tmp, \irqstat
1361 + /* get core number */
1362 + mrc p15, 0, \tmp, c0, c0, 5
1363 + ubfx \tmp, \tmp, #0, #2
1372 + /* get masked status */
1373 + ldr \irqstat, [\base, #(ARM_IRQ_PEND0 - ARMCTRL_IC_BASE)]
1374 + mov \irqnr, #(ARM_IRQ0_BASE + 31)
1375 + and \tmp, \irqstat, #0x300 @ save bits 8 and 9
1376 + /* clear bits 8 and 9, and test */
1377 + bics \irqstat, \irqstat, #0x300
1381 + ldrne \irqstat, [\base, #(ARM_IRQ_PEND1 - ARMCTRL_IC_BASE)]
1382 + movne \irqnr, #(ARM_IRQ1_BASE + 31)
1383 + @ Mask out the interrupts also present in PEND0 - see SW-5809
1384 + bicne \irqstat, #((1<<7) | (1<<9) | (1<<10))
1385 + bicne \irqstat, #((1<<18) | (1<<19))
1389 + ldrne \irqstat, [\base, #(ARM_IRQ_PEND2 - ARMCTRL_IC_BASE)]
1390 + movne \irqnr, #(ARM_IRQ2_BASE + 31)
1391 + @ Mask out the interrupts also present in PEND0 - see SW-5809
1392 + bicne \irqstat, #((1<<21) | (1<<22) | (1<<23) | (1<<24) | (1<<25))
1393 + bicne \irqstat, #((1<<30))
1397 + @ For non-zero x, LSB(x) = 31 - CLZ(x^(x-1))
1398 + @ N.B. CLZ is an ARM5 instruction.
1399 + sub \tmp, \irqstat, #1
1400 + eor \irqstat, \irqstat, \tmp
1401 + clz \tmp, \irqstat
1404 +1020: @ EQ will be set if no irqs pending
1408 + .macro test_for_ipi, irqnr, irqstat, base, tmp
1409 + /* get core number */
1410 + mrc p15, 0, \tmp, c0, c0, 5
1411 + ubfx \tmp, \tmp, #0, #2
1412 + /* get core's mailbox interrupt control */
1413 + ldr \irqstat, = __io_address(ARM_LOCAL_MAILBOX0_CLR0) @ mbox_clr
1414 + add \irqstat, \irqstat, \tmp, lsl #4
1415 + ldr \tmp, [\irqstat]
1419 + rsb \irqnr, \tmp, #31
1422 + str \tmp, [\irqstat] @ clear interrupt source
1424 +1030: @ EQ will be set if no irqs pending
1427 +++ b/arch/arm/mach-bcm2709/include/mach/io.h
1430 + * arch/arm/mach-bcm2708/include/mach/io.h
1432 + * Copyright (C) 2003 ARM Limited
1434 + * This program is free software; you can redistribute it and/or modify
1435 + * it under the terms of the GNU General Public License as published by
1436 + * the Free Software Foundation; either version 2 of the License, or
1437 + * (at your option) any later version.
1439 + * This program is distributed in the hope that it will be useful,
1440 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1441 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1442 + * GNU General Public License for more details.
1444 + * You should have received a copy of the GNU General Public License
1445 + * along with this program; if not, write to the Free Software
1446 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1448 +#ifndef __ASM_ARM_ARCH_IO_H
1449 +#define __ASM_ARM_ARCH_IO_H
1451 +#define IO_SPACE_LIMIT 0xffffffff
1453 +#define __io(a) __typesafe_io(a)
1457 +++ b/arch/arm/mach-bcm2709/include/mach/memory.h
1460 + * arch/arm/mach-bcm2708/include/mach/memory.h
1462 + * Copyright (C) 2010 Broadcom
1464 + * This program is free software; you can redistribute it and/or modify
1465 + * it under the terms of the GNU General Public License as published by
1466 + * the Free Software Foundation; either version 2 of the License, or
1467 + * (at your option) any later version.
1469 + * This program is distributed in the hope that it will be useful,
1470 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1471 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1472 + * GNU General Public License for more details.
1474 + * You should have received a copy of the GNU General Public License
1475 + * along with this program; if not, write to the Free Software
1476 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1478 +#ifndef __ASM_ARCH_MEMORY_H
1479 +#define __ASM_ARCH_MEMORY_H
1481 +/* Memory overview:
1483 + [ARMcore] <--virtual addr-->
1484 + [ARMmmu] <--physical addr-->
1485 + [GERTmap] <--bus add-->
1491 + * Physical DRAM offset.
1493 +#define BCM_PLAT_PHYS_OFFSET UL(0x00000000)
1494 +#define VC_ARMMEM_OFFSET UL(0x00000000) /* offset in VC of ARM memory */
1496 +#ifdef CONFIG_BCM2708_NOL2CACHE
1497 + #define _REAL_BUS_OFFSET UL(0xC0000000) /* don't use L1 or L2 caches */
1499 + #define _REAL_BUS_OFFSET UL(0x40000000) /* use L2 cache */
1502 +/* We're using the memory at 64M in the VideoCore for Linux - this adjustment
1503 + * will provide the offset into this area as well as setting the bits that
1504 + * stop the L1 and L2 cache from being used
1506 + * WARNING: this only works because the ARM is given memory at a fixed location
1509 +#define BUS_OFFSET (VC_ARMMEM_OFFSET + _REAL_BUS_OFFSET)
1510 +#define __virt_to_bus(x) ((x) + (BUS_OFFSET - PAGE_OFFSET))
1511 +#define __bus_to_virt(x) ((x) - (BUS_OFFSET - PAGE_OFFSET))
1512 +#define __pfn_to_bus(x) (__pfn_to_phys(x) + (BUS_OFFSET - BCM_PLAT_PHYS_OFFSET))
1513 +#define __bus_to_pfn(x) __phys_to_pfn((x) - (BUS_OFFSET - BCM_PLAT_PHYS_OFFSET))
1517 +++ b/arch/arm/mach-bcm2709/include/mach/platform.h
1520 + * arch/arm/mach-bcm2708/include/mach/platform.h
1522 + * Copyright (C) 2010 Broadcom
1524 + * This program is free software; you can redistribute it and/or modify
1525 + * it under the terms of the GNU General Public License as published by
1526 + * the Free Software Foundation; either version 2 of the License, or
1527 + * (at your option) any later version.
1529 + * This program is distributed in the hope that it will be useful,
1530 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1531 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1532 + * GNU General Public License for more details.
1534 + * You should have received a copy of the GNU General Public License
1535 + * along with this program; if not, write to the Free Software
1536 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1539 +#ifndef _BCM2708_PLATFORM_H
1540 +#define _BCM2708_PLATFORM_H
1543 +/* macros to get at IO space when running virtually */
1544 +#define IO_ADDRESS(x) (((x) & 0x00ffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
1546 +#define __io_address(n) IOMEM(IO_ADDRESS(n))
1552 +#define BCM2708_SDRAM_BASE 0x00000000
1555 + * Logic expansion modules
1560 +/* ------------------------------------------------------------------------
1561 + * BCM2708 ARMCTRL Registers
1562 + * ------------------------------------------------------------------------
1565 +#define HW_REGISTER_RW(addr) (addr)
1566 +#define HW_REGISTER_RO(addr) (addr)
1569 + * Definitions and addresses for the ARM CONTROL logic
1570 + * This file is manually generated.
1573 +#define BCM2708_PERI_BASE 0x3F000000
1574 +#define IC0_BASE (BCM2708_PERI_BASE + 0x2000)
1575 +#define ST_BASE (BCM2708_PERI_BASE + 0x3000) /* System Timer */
1576 +#define MPHI_BASE (BCM2708_PERI_BASE + 0x6000) /* Message -based Parallel Host Interface */
1577 +#define DMA_BASE (BCM2708_PERI_BASE + 0x7000) /* DMA controller */
1578 +#define ARM_BASE (BCM2708_PERI_BASE + 0xB000) /* BCM2708 ARM control block */
1579 +#define PM_BASE (BCM2708_PERI_BASE + 0x100000) /* Power Management, Reset controller and Watchdog registers */
1580 +#define PCM_CLOCK_BASE (BCM2708_PERI_BASE + 0x101098) /* PCM Clock */
1581 +#define RNG_BASE (BCM2708_PERI_BASE + 0x104000) /* Hardware RNG */
1582 +#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000) /* GPIO */
1583 +#define UART0_BASE (BCM2708_PERI_BASE + 0x201000) /* Uart 0 */
1584 +#define MMCI0_BASE (BCM2708_PERI_BASE + 0x202000) /* MMC interface */
1585 +#define I2S_BASE (BCM2708_PERI_BASE + 0x203000) /* I2S */
1586 +#define SPI0_BASE (BCM2708_PERI_BASE + 0x204000) /* SPI0 */
1587 +#define BSC0_BASE (BCM2708_PERI_BASE + 0x205000) /* BSC0 I2C/TWI */
1588 +#define UART1_BASE (BCM2708_PERI_BASE + 0x215000) /* Uart 1 */
1589 +#define EMMC_BASE (BCM2708_PERI_BASE + 0x300000) /* eMMC interface */
1590 +#define SMI_BASE (BCM2708_PERI_BASE + 0x600000) /* SMI */
1591 +#define BSC1_BASE (BCM2708_PERI_BASE + 0x804000) /* BSC1 I2C/TWI */
1592 +#define USB_BASE (BCM2708_PERI_BASE + 0x980000) /* DTC_OTG USB controller */
1593 +#define MCORE_BASE (BCM2708_PERI_BASE + 0x0000) /* Fake frame buffer device (actually the multicore sync block*/
1595 +#define ARMCTRL_BASE (ARM_BASE + 0x000)
1596 +#define ARMCTRL_IC_BASE (ARM_BASE + 0x200) /* ARM interrupt controller */
1597 +#define ARMCTRL_TIMER0_1_BASE (ARM_BASE + 0x400) /* Timer 0 and 1 */
1598 +#define ARMCTRL_0_SBM_BASE (ARM_BASE + 0x800) /* User 0 (ARM)'s Semaphores Doorbells and Mailboxes */
1603 +#define PM_RSTC (PM_BASE+0x1c)
1604 +#define PM_RSTS (PM_BASE+0x20)
1605 +#define PM_WDOG (PM_BASE+0x24)
1607 +#define PM_WDOG_RESET 0000000000
1608 +#define PM_PASSWORD 0x5a000000
1609 +#define PM_WDOG_TIME_SET 0x000fffff
1610 +#define PM_RSTC_WRCFG_CLR 0xffffffcf
1611 +#define PM_RSTC_WRCFG_SET 0x00000030
1612 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020
1613 +#define PM_RSTC_RESET 0x00000102
1615 +#define PM_RSTS_HADPOR_SET 0x00001000
1616 +#define PM_RSTS_HADSRH_SET 0x00000400
1617 +#define PM_RSTS_HADSRF_SET 0x00000200
1618 +#define PM_RSTS_HADSRQ_SET 0x00000100
1619 +#define PM_RSTS_HADWRH_SET 0x00000040
1620 +#define PM_RSTS_HADWRF_SET 0x00000020
1621 +#define PM_RSTS_HADWRQ_SET 0x00000010
1622 +#define PM_RSTS_HADDRH_SET 0x00000004
1623 +#define PM_RSTS_HADDRF_SET 0x00000002
1624 +#define PM_RSTS_HADDRQ_SET 0x00000001
1626 +#define UART0_CLOCK 3000000
1628 +#define ARM_LOCAL_BASE 0x40000000
1629 +#define ARM_LOCAL_CONTROL HW_REGISTER_RW(ARM_LOCAL_BASE+0x000)
1631 +#define ARM_LOCAL_CONTROL HW_REGISTER_RW(ARM_LOCAL_BASE+0x000)
1632 +#define ARM_LOCAL_PRESCALER HW_REGISTER_RW(ARM_LOCAL_BASE+0x008)
1633 +#define ARM_LOCAL_GPU_INT_ROUTING HW_REGISTER_RW(ARM_LOCAL_BASE+0x00C)
1634 +#define ARM_LOCAL_PM_ROUTING_SET HW_REGISTER_RW(ARM_LOCAL_BASE+0x010)
1635 +#define ARM_LOCAL_PM_ROUTING_CLR HW_REGISTER_RW(ARM_LOCAL_BASE+0x014)
1636 +#define ARM_LOCAL_TIMER_LS HW_REGISTER_RW(ARM_LOCAL_BASE+0x01C)
1637 +#define ARM_LOCAL_TIMER_MS HW_REGISTER_RW(ARM_LOCAL_BASE+0x020)
1638 +#define ARM_LOCAL_INT_ROUTING HW_REGISTER_RW(ARM_LOCAL_BASE+0x024)
1639 +#define ARM_LOCAL_AXI_COUNT HW_REGISTER_RW(ARM_LOCAL_BASE+0x02C)
1640 +#define ARM_LOCAL_AXI_IRQ HW_REGISTER_RW(ARM_LOCAL_BASE+0x030)
1641 +#define ARM_LOCAL_TIMER_CONTROL HW_REGISTER_RW(ARM_LOCAL_BASE+0x034)
1642 +#define ARM_LOCAL_TIMER_WRITE HW_REGISTER_RW(ARM_LOCAL_BASE+0x038)
1644 +#define ARM_LOCAL_TIMER_INT_CONTROL0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x040)
1645 +#define ARM_LOCAL_TIMER_INT_CONTROL1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x044)
1646 +#define ARM_LOCAL_TIMER_INT_CONTROL2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x048)
1647 +#define ARM_LOCAL_TIMER_INT_CONTROL3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x04C)
1649 +#define ARM_LOCAL_MAILBOX_INT_CONTROL0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x050)
1650 +#define ARM_LOCAL_MAILBOX_INT_CONTROL1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x054)
1651 +#define ARM_LOCAL_MAILBOX_INT_CONTROL2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x058)
1652 +#define ARM_LOCAL_MAILBOX_INT_CONTROL3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x05C)
1654 +#define ARM_LOCAL_IRQ_PENDING0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x060)
1655 +#define ARM_LOCAL_IRQ_PENDING1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x064)
1656 +#define ARM_LOCAL_IRQ_PENDING2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x068)
1657 +#define ARM_LOCAL_IRQ_PENDING3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x06C)
1659 +#define ARM_LOCAL_FIQ_PENDING0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x070)
1660 +#define ARM_LOCAL_FIQ_PENDING1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x074)
1661 +#define ARM_LOCAL_FIQ_PENDING2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x078)
1662 +#define ARM_LOCAL_FIQ_PENDING3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x07C)
1664 +#define ARM_LOCAL_MAILBOX0_SET0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x080)
1665 +#define ARM_LOCAL_MAILBOX1_SET0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x084)
1666 +#define ARM_LOCAL_MAILBOX2_SET0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x088)
1667 +#define ARM_LOCAL_MAILBOX3_SET0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x08C)
1669 +#define ARM_LOCAL_MAILBOX0_SET1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x090)
1670 +#define ARM_LOCAL_MAILBOX1_SET1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x094)
1671 +#define ARM_LOCAL_MAILBOX2_SET1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x098)
1672 +#define ARM_LOCAL_MAILBOX3_SET1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x09C)
1674 +#define ARM_LOCAL_MAILBOX0_SET2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0A0)
1675 +#define ARM_LOCAL_MAILBOX1_SET2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0A4)
1676 +#define ARM_LOCAL_MAILBOX2_SET2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0A8)
1677 +#define ARM_LOCAL_MAILBOX3_SET2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0AC)
1679 +#define ARM_LOCAL_MAILBOX0_SET3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0B0)
1680 +#define ARM_LOCAL_MAILBOX1_SET3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0B4)
1681 +#define ARM_LOCAL_MAILBOX2_SET3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0B8)
1682 +#define ARM_LOCAL_MAILBOX3_SET3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0BC)
1684 +#define ARM_LOCAL_MAILBOX0_CLR0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0C0)
1685 +#define ARM_LOCAL_MAILBOX1_CLR0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0C4)
1686 +#define ARM_LOCAL_MAILBOX2_CLR0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0C8)
1687 +#define ARM_LOCAL_MAILBOX3_CLR0 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0CC)
1689 +#define ARM_LOCAL_MAILBOX0_CLR1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0D0)
1690 +#define ARM_LOCAL_MAILBOX1_CLR1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0D4)
1691 +#define ARM_LOCAL_MAILBOX2_CLR1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0D8)
1692 +#define ARM_LOCAL_MAILBOX3_CLR1 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0DC)
1694 +#define ARM_LOCAL_MAILBOX0_CLR2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0E0)
1695 +#define ARM_LOCAL_MAILBOX1_CLR2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0E4)
1696 +#define ARM_LOCAL_MAILBOX2_CLR2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0E8)
1697 +#define ARM_LOCAL_MAILBOX3_CLR2 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0EC)
1699 +#define ARM_LOCAL_MAILBOX0_CLR3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0F0)
1700 +#define ARM_LOCAL_MAILBOX1_CLR3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0F4)
1701 +#define ARM_LOCAL_MAILBOX2_CLR3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0F8)
1702 +#define ARM_LOCAL_MAILBOX3_CLR3 HW_REGISTER_RW(ARM_LOCAL_BASE+0x0FC)
1708 +++ b/arch/arm/mach-bcm2709/include/mach/system.h
1711 + * arch/arm/mach-bcm2708/include/mach/system.h
1713 + * Copyright (C) 2010 Broadcom
1714 + * Copyright (C) 2003 ARM Limited
1715 + * Copyright (C) 2000 Deep Blue Solutions Ltd
1717 + * This program is free software; you can redistribute it and/or modify
1718 + * it under the terms of the GNU General Public License as published by
1719 + * the Free Software Foundation; either version 2 of the License, or
1720 + * (at your option) any later version.
1722 + * This program is distributed in the hope that it will be useful,
1723 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1724 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1725 + * GNU General Public License for more details.
1727 + * You should have received a copy of the GNU General Public License
1728 + * along with this program; if not, write to the Free Software
1729 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1731 +#ifndef __ASM_ARCH_SYSTEM_H
1732 +#define __ASM_ARCH_SYSTEM_H
1734 +#include <linux/io.h>
1735 +#include <mach/platform.h>
1737 +static inline void arch_idle(void)
1740 + * This should do all the clock switching
1741 + * and wait for interrupt tricks
1748 +++ b/arch/arm/mach-bcm2709/include/mach/uncompress.h
1751 + * arch/arm/mach-bcn2708/include/mach/uncompress.h
1753 + * Copyright (C) 2010 Broadcom
1754 + * Copyright (C) 2003 ARM Limited
1756 + * This program is free software; you can redistribute it and/or modify
1757 + * it under the terms of the GNU General Public License as published by
1758 + * the Free Software Foundation; either version 2 of the License, or
1759 + * (at your option) any later version.
1761 + * This program is distributed in the hope that it will be useful,
1762 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1763 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1764 + * GNU General Public License for more details.
1766 + * You should have received a copy of the GNU General Public License
1767 + * along with this program; if not, write to the Free Software
1768 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1771 +#include <linux/io.h>
1772 +#include <linux/amba/serial.h>
1773 +#include <mach/platform.h>
1775 +#define UART_BAUD 115200
1777 +#define BCM2708_UART_DR __io(UART0_BASE + UART01x_DR)
1778 +#define BCM2708_UART_FR __io(UART0_BASE + UART01x_FR)
1779 +#define BCM2708_UART_IBRD __io(UART0_BASE + UART011_IBRD)
1780 +#define BCM2708_UART_FBRD __io(UART0_BASE + UART011_FBRD)
1781 +#define BCM2708_UART_LCRH __io(UART0_BASE + UART011_LCRH)
1782 +#define BCM2708_UART_CR __io(UART0_BASE + UART011_CR)
1785 + * This does not append a newline
1787 +static inline void putc(int c)
1789 + while (__raw_readl(BCM2708_UART_FR) & UART01x_FR_TXFF)
1792 + __raw_writel(c, BCM2708_UART_DR);
1795 +static inline void flush(void)
1800 + fr = __raw_readl(BCM2708_UART_FR);
1802 + } while ((fr & (UART011_FR_TXFE | UART01x_FR_BUSY)) != UART011_FR_TXFE);
1805 +static inline void arch_decomp_setup(void)
1807 + int temp, div, rem, frac;
1809 + temp = 16 * UART_BAUD;
1810 + div = UART0_CLOCK / temp;
1811 + rem = UART0_CLOCK % temp;
1812 + temp = (8 * rem) / UART_BAUD;
1813 + frac = (temp >> 1) + (temp & 1);
1815 + /* Make sure the UART is disabled before we start */
1816 + __raw_writel(0, BCM2708_UART_CR);
1818 + /* Set the baud rate */
1819 + __raw_writel(div, BCM2708_UART_IBRD);
1820 + __raw_writel(frac, BCM2708_UART_FBRD);
1822 + /* Set the UART to 8n1, FIFO enabled */
1823 + __raw_writel(UART01x_LCRH_WLEN_8 | UART01x_LCRH_FEN, BCM2708_UART_LCRH);
1825 + /* Enable the UART */
1826 + __raw_writel(UART01x_CR_UARTEN | UART011_CR_TXE | UART011_CR_RXE,
1833 +#define arch_decomp_wdog()
1835 +++ b/arch/arm/mach-bcm2709/include/mach/vc_mem.h
1837 +/*****************************************************************************
1838 +* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
1840 +* Unless you and Broadcom execute a separate written software license
1841 +* agreement governing use of this software, this software is licensed to you
1842 +* under the terms of the GNU General Public License version 2, available at
1843 +* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
1845 +* Notwithstanding the above, under no circumstances may you combine this
1846 +* software in any way with any other Broadcom software provided under a
1847 +* license other than the GPL, without Broadcom's express prior written
1849 +*****************************************************************************/
1851 +#if !defined( VC_MEM_H )
1854 +#include <linux/ioctl.h>
1856 +#define VC_MEM_IOC_MAGIC 'v'
1858 +#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR( VC_MEM_IOC_MAGIC, 0, unsigned long )
1859 +#define VC_MEM_IOC_MEM_SIZE _IOR( VC_MEM_IOC_MAGIC, 1, unsigned int )
1860 +#define VC_MEM_IOC_MEM_BASE _IOR( VC_MEM_IOC_MAGIC, 2, unsigned int )
1861 +#define VC_MEM_IOC_MEM_LOAD _IOR( VC_MEM_IOC_MAGIC, 3, unsigned int )
1863 +#if defined( __KERNEL__ )
1864 +#define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
1866 +extern unsigned long mm_vc_mem_phys_addr;
1867 +extern unsigned int mm_vc_mem_size;
1868 +extern int vc_mem_get_current_size( void );
1871 +#endif /* VC_MEM_H */
1873 +++ b/arch/arm/mach-bcm2709/include/mach/vmalloc.h
1876 + * arch/arm/mach-bcm2708/include/mach/vmalloc.h
1878 + * Copyright (C) 2010 Broadcom
1880 + * This program is free software; you can redistribute it and/or modify
1881 + * it under the terms of the GNU General Public License as published by
1882 + * the Free Software Foundation; either version 2 of the License, or
1883 + * (at your option) any later version.
1885 + * This program is distributed in the hope that it will be useful,
1886 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1887 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1888 + * GNU General Public License for more details.
1890 + * You should have received a copy of the GNU General Public License
1891 + * along with this program; if not, write to the Free Software
1892 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1894 +#define VMALLOC_END (0xff000000)
1896 +++ b/arch/arm/mach-bcm2709/vc_mem.c
1898 +/*****************************************************************************
1899 +* Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
1901 +* Unless you and Broadcom execute a separate written software license
1902 +* agreement governing use of this software, this software is licensed to you
1903 +* under the terms of the GNU General Public License version 2, available at
1904 +* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
1906 +* Notwithstanding the above, under no circumstances may you combine this
1907 +* software in any way with any other Broadcom software provided under a
1908 +* license other than the GPL, without Broadcom's express prior written
1910 +*****************************************************************************/
1912 +#include <linux/kernel.h>
1913 +#include <linux/module.h>
1914 +#include <linux/fs.h>
1915 +#include <linux/device.h>
1916 +#include <linux/cdev.h>
1917 +#include <linux/mm.h>
1918 +#include <linux/slab.h>
1919 +#include <linux/debugfs.h>
1920 +#include <asm/uaccess.h>
1921 +#include <linux/dma-mapping.h>
1922 +#include <linux/platform_data/mailbox-bcm2708.h>
1924 +#ifdef CONFIG_ARCH_KONA
1925 +#include <chal/chal_ipc.h>
1926 +#elif defined(CONFIG_ARCH_BCM2708) || defined(CONFIG_ARCH_BCM2709)
1928 +#include <csp/chal_ipc.h>
1931 +#include "mach/vc_mem.h"
1933 +#define DRIVER_NAME "vc-mem"
1935 +// Device (/dev) related variables
1936 +static dev_t vc_mem_devnum = 0;
1937 +static struct class *vc_mem_class = NULL;
1938 +static struct cdev vc_mem_cdev;
1939 +static int vc_mem_inited = 0;
1941 +#ifdef CONFIG_DEBUG_FS
1942 +static struct dentry *vc_mem_debugfs_entry;
1946 + * Videocore memory addresses and size
1948 + * Drivers that wish to know the videocore memory addresses and sizes should
1949 + * use these variables instead of the MM_IO_BASE and MM_ADDR_IO defines in
1950 + * headers. This allows the other drivers to not be tied down to a a certain
1951 + * address/size at compile time.
1953 + * In the future, the goal is to have the videocore memory virtual address and
1954 + * size be calculated at boot time rather than at compile time. The decision of
1955 + * where the videocore memory resides and its size would be in the hands of the
1956 + * bootloader (and/or kernel). When that happens, the values of these variables
1957 + * would be calculated and assigned in the init function.
1959 +// in the 2835 VC in mapped above ARM, but ARM has full access to VC space
1960 +unsigned long mm_vc_mem_phys_addr = 0x00000000;
1961 +unsigned int mm_vc_mem_size = 0;
1962 +unsigned int mm_vc_mem_base = 0;
1964 +EXPORT_SYMBOL(mm_vc_mem_phys_addr);
1965 +EXPORT_SYMBOL(mm_vc_mem_size);
1966 +EXPORT_SYMBOL(mm_vc_mem_base);
1968 +static uint phys_addr = 0;
1969 +static uint mem_size = 0;
1970 +static uint mem_base = 0;
1973 +/****************************************************************************
1977 +***************************************************************************/
1980 +vc_mem_open(struct inode *inode, struct file *file)
1985 + pr_debug("%s: called file = 0x%p\n", __func__, file);
1990 +/****************************************************************************
1994 +***************************************************************************/
1997 +vc_mem_release(struct inode *inode, struct file *file)
2002 + pr_debug("%s: called file = 0x%p\n", __func__, file);
2007 +/****************************************************************************
2011 +***************************************************************************/
2014 +vc_mem_get_size(void)
2018 +/****************************************************************************
2022 +***************************************************************************/
2025 +vc_mem_get_base(void)
2029 +/****************************************************************************
2031 +* vc_mem_get_current_size
2033 +***************************************************************************/
2036 +vc_mem_get_current_size(void)
2038 + return mm_vc_mem_size;
2041 +EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
2043 +/****************************************************************************
2047 +***************************************************************************/
2050 +vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2057 + pr_debug("%s: called file = 0x%p\n", __func__, file);
2060 + case VC_MEM_IOC_MEM_PHYS_ADDR:
2062 + pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR=0x%p\n",
2063 + __func__, (void *) mm_vc_mem_phys_addr);
2065 + if (copy_to_user((void *) arg, &mm_vc_mem_phys_addr,
2066 + sizeof (mm_vc_mem_phys_addr)) != 0) {
2071 + case VC_MEM_IOC_MEM_SIZE:
2073 + // Get the videocore memory size first
2074 + vc_mem_get_size();
2076 + pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%u\n", __func__,
2079 + if (copy_to_user((void *) arg, &mm_vc_mem_size,
2080 + sizeof (mm_vc_mem_size)) != 0) {
2085 + case VC_MEM_IOC_MEM_BASE:
2087 + // Get the videocore memory base
2088 + vc_mem_get_base();
2090 + pr_debug("%s: VC_MEM_IOC_MEM_BASE=%u\n", __func__,
2093 + if (copy_to_user((void *) arg, &mm_vc_mem_base,
2094 + sizeof (mm_vc_mem_base)) != 0) {
2099 + case VC_MEM_IOC_MEM_LOAD:
2101 + // Get the videocore memory base
2102 + vc_mem_get_base();
2104 + pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%u\n", __func__,
2107 + if (copy_to_user((void *) arg, &mm_vc_mem_base,
2108 + sizeof (mm_vc_mem_base)) != 0) {
2118 + pr_debug("%s: file = 0x%p returning %d\n", __func__, file, rc);
2123 +/****************************************************************************
2127 +***************************************************************************/
2130 +vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
2133 + unsigned long length = vma->vm_end - vma->vm_start;
2134 + unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
2136 + pr_debug("%s: vm_start = 0x%08lx vm_end = 0x%08lx vm_pgoff = 0x%08lx\n",
2137 + __func__, (long) vma->vm_start, (long) vma->vm_end,
2138 + (long) vma->vm_pgoff);
2140 + if (offset + length > mm_vc_mem_size) {
2141 + pr_err("%s: length %ld is too big\n", __func__, length);
2144 + // Do not cache the memory map
2145 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
2147 + rc = remap_pfn_range(vma, vma->vm_start,
2148 + (mm_vc_mem_phys_addr >> PAGE_SHIFT) +
2149 + vma->vm_pgoff, length, vma->vm_page_prot);
2151 + pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
2157 +/****************************************************************************
2159 +* File Operations for the driver.
2161 +***************************************************************************/
2163 +static const struct file_operations vc_mem_fops = {
2164 + .owner = THIS_MODULE,
2165 + .open = vc_mem_open,
2166 + .release = vc_mem_release,
2167 + .unlocked_ioctl = vc_mem_ioctl,
2168 + .mmap = vc_mem_mmap,
2171 +#ifdef CONFIG_DEBUG_FS
2172 +static void vc_mem_debugfs_deinit(void)
2174 + debugfs_remove_recursive(vc_mem_debugfs_entry);
2175 + vc_mem_debugfs_entry = NULL;
2179 +static int vc_mem_debugfs_init(
2180 + struct device *dev)
2182 + vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
2183 + if (!vc_mem_debugfs_entry) {
2184 + dev_warn(dev, "could not create debugfs entry\n");
2188 + if (!debugfs_create_x32("vc_mem_phys_addr",
2190 + vc_mem_debugfs_entry,
2191 + (u32 *)&mm_vc_mem_phys_addr)) {
2192 + dev_warn(dev, "%s:could not create vc_mem_phys entry\n",
2197 + if (!debugfs_create_x32("vc_mem_size",
2199 + vc_mem_debugfs_entry,
2200 + (u32 *)&mm_vc_mem_size)) {
2201 + dev_warn(dev, "%s:could not create vc_mem_size entry\n",
2206 + if (!debugfs_create_x32("vc_mem_base",
2208 + vc_mem_debugfs_entry,
2209 + (u32 *)&mm_vc_mem_base)) {
2210 + dev_warn(dev, "%s:could not create vc_mem_base entry\n",
2218 + vc_mem_debugfs_deinit();
2222 +#endif /* CONFIG_DEBUG_FS */
2225 +/****************************************************************************
2229 +***************************************************************************/
2235 + struct device *dev;
2237 + pr_debug("%s: called\n", __func__);
2239 + mm_vc_mem_phys_addr = phys_addr;
2240 + mm_vc_mem_size = mem_size;
2241 + mm_vc_mem_base = mem_base;
2243 + vc_mem_get_size();
2245 + pr_info("vc-mem: phys_addr:0x%08lx mem_base=0x%08x mem_size:0x%08x(%u MiB)\n",
2246 + mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size, mm_vc_mem_size / (1024 * 1024));
2248 + if ((rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME)) < 0) {
2249 + pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
2254 + cdev_init(&vc_mem_cdev, &vc_mem_fops);
2255 + if ((rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1)) != 0) {
2256 + pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
2257 + goto out_unregister;
2260 + vc_mem_class = class_create(THIS_MODULE, DRIVER_NAME);
2261 + if (IS_ERR(vc_mem_class)) {
2262 + rc = PTR_ERR(vc_mem_class);
2263 + pr_err("%s: class_create failed (rc=%d)\n", __func__, rc);
2264 + goto out_cdev_del;
2267 + dev = device_create(vc_mem_class, NULL, vc_mem_devnum, NULL,
2269 + if (IS_ERR(dev)) {
2270 + rc = PTR_ERR(dev);
2271 + pr_err("%s: device_create failed (rc=%d)\n", __func__, rc);
2272 + goto out_class_destroy;
2275 +#ifdef CONFIG_DEBUG_FS
2276 + /* don't fail if the debug entries cannot be created */
2277 + vc_mem_debugfs_init(dev);
2280 + vc_mem_inited = 1;
2283 + device_destroy(vc_mem_class, vc_mem_devnum);
2285 + out_class_destroy:
2286 + class_destroy(vc_mem_class);
2287 + vc_mem_class = NULL;
2290 + cdev_del(&vc_mem_cdev);
2293 + unregister_chrdev_region(vc_mem_devnum, 1);
2299 +/****************************************************************************
2303 +***************************************************************************/
2308 + pr_debug("%s: called\n", __func__);
2310 + if (vc_mem_inited) {
2311 +#if CONFIG_DEBUG_FS
2312 + vc_mem_debugfs_deinit();
2314 + device_destroy(vc_mem_class, vc_mem_devnum);
2315 + class_destroy(vc_mem_class);
2316 + cdev_del(&vc_mem_cdev);
2317 + unregister_chrdev_region(vc_mem_devnum, 1);
2321 +module_init(vc_mem_init);
2322 +module_exit(vc_mem_exit);
2323 +MODULE_LICENSE("GPL");
2324 +MODULE_AUTHOR("Broadcom Corporation");
2326 +module_param(phys_addr, uint, 0644);
2327 +module_param(mem_size, uint, 0644);
2328 +module_param(mem_base, uint, 0644);
2329 --- a/arch/arm/mm/Kconfig
2330 +++ b/arch/arm/mm/Kconfig
2331 @@ -358,7 +358,7 @@ config CPU_PJ4B
2335 - bool "Support ARM V6 processor" if (!ARCH_MULTIPLATFORM || ARCH_MULTI_V6) && (ARCH_INTEGRATOR || MACH_REALVIEW_EB || MACH_REALVIEW_PBX)
2336 + bool "Support ARM V6 processor" if (!ARCH_MULTIPLATFORM || ARCH_MULTI_V6) && (ARCH_INTEGRATOR || MACH_REALVIEW_EB || MACH_REALVIEW_PBX || MACH_BCM2708)
2340 --- a/arch/arm/mm/proc-v6.S
2341 +++ b/arch/arm/mm/proc-v6.S
2342 @@ -73,10 +73,19 @@ ENDPROC(cpu_v6_reset)
2344 * IRQs are already disabled.
2347 +/* See jira SW-5991 for details of this workaround */
2348 ENTRY(cpu_v6_do_idle)
2350 - mcr p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
2351 - mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
2356 + mcreq p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
2357 + mcreq p15, 0, r1, c7, c0, 4 @ wait for interrupt
2364 ENTRY(cpu_v6_dcache_clean_area)
2365 --- a/arch/arm/mm/proc-v7.S
2366 +++ b/arch/arm/mm/proc-v7.S
2367 @@ -480,6 +480,7 @@ __errata_finish:
2368 orr r0, r0, r6 @ set them
2369 THUMB( orr r0, r0, #1 << 30 ) @ Thumb exceptions
2370 ret lr @ return to head.S:__ret
2375 --- a/arch/arm/tools/mach-types
2376 +++ b/arch/arm/tools/mach-types
2377 @@ -522,6 +522,8 @@ torbreck MACH_TORBRECK TORBRECK 3090
2378 prima2_evb MACH_PRIMA2_EVB PRIMA2_EVB 3103
2379 paz00 MACH_PAZ00 PAZ00 3128
2380 acmenetusfoxg20 MACH_ACMENETUSFOXG20 ACMENETUSFOXG20 3129
2381 +bcm2708 MACH_BCM2708 BCM2708 3138
2382 +bcm2709 MACH_BCM2709 BCM2709 3139
2383 ag5evm MACH_AG5EVM AG5EVM 3189
2384 ics_if_voip MACH_ICS_IF_VOIP ICS_IF_VOIP 3206
2385 wlf_cragg_6410 MACH_WLF_CRAGG_6410 WLF_CRAGG_6410 3207
2386 --- a/drivers/clocksource/Makefile
2387 +++ b/drivers/clocksource/Makefile
2388 @@ -19,7 +19,7 @@ obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += noma
2389 obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o
2390 obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o
2391 obj-$(CONFIG_ORION_TIMER) += time-orion.o
2392 -obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o
2393 +obj-$(CONFIG_ARCH_BCM2835)$(CONFIG_ARCH_BCM2708) += bcm2835_timer.o
2394 obj-$(CONFIG_ARCH_CLPS711X) += clps711x-timer.o
2395 obj-$(CONFIG_ARCH_ATLAS7) += timer-atlas7.o
2396 obj-$(CONFIG_ARCH_MOXART) += moxart_timer.o
2397 --- a/drivers/irqchip/Makefile
2398 +++ b/drivers/irqchip/Makefile
2399 @@ -2,6 +2,9 @@ obj-$(CONFIG_IRQCHIP) += irqchip.o
2401 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
2402 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2836.o
2403 +obj-$(CONFIG_ARCH_BCM2708) += irq-bcm2835.o
2404 +obj-$(CONFIG_ARCH_BCM2709) += irq-bcm2835.o
2405 +obj-$(CONFIG_ARCH_BCM2709) += irq-bcm2836.o
2406 obj-$(CONFIG_ARCH_EXYNOS) += exynos-combiner.o
2407 obj-$(CONFIG_ARCH_HIP04) += irq-hip04.o
2408 obj-$(CONFIG_ARCH_MMP) += irq-mmp.o
2409 --- a/include/linux/mmc/host.h
2410 +++ b/include/linux/mmc/host.h
2411 @@ -289,6 +289,7 @@ struct mmc_host {
2412 #define MMC_CAP2_HSX00_1_2V (MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V)
2413 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17)
2414 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */
2415 +#define MMC_CAP2_FORCE_MULTIBLOCK (1 << 31) /* Always use multiblock transfers */
2417 mmc_pm_flag_t pm_caps; /* supported pm features */