bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0140-arm-bcm2835-Fix-FIQ-early-ioremap.patch
1 From d9deb3700dd28463c329494f76870c6784e50309 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Wed, 20 Feb 2019 08:49:39 +0000
4 Subject: [PATCH] arm: bcm2835: Fix FIQ early ioremap
5
6 The ioremapping creates mappings within the vmalloc area. The
7 equivalent early function, create_mapping, now checks that the
8 requested explicit virtual address is between VMALLOC_START and
9 VMALLOC_END. As there is no reason to have any correlation between
10 the physical and virtual addresses, put the required mappings at
11 VMALLOC_START and above.
12
13 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
14 ---
15 arch/arm/mach-bcm/board_bcm2835.c | 21 +++++++++++++++------
16 1 file changed, 15 insertions(+), 6 deletions(-)
17
18 --- a/arch/arm/mach-bcm/board_bcm2835.c
19 +++ b/arch/arm/mach-bcm/board_bcm2835.c
20 @@ -5,17 +5,20 @@
21
22 #include <linux/init.h>
23 #include <linux/irqchip.h>
24 +#include <linux/mm.h>
25 #include <linux/of_address.h>
26 #include <linux/of_fdt.h>
27 #include <asm/system_info.h>
28
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 +#include <asm/memory.h>
32 +#include <asm/pgtable.h>
33
34 #include "platsmp.h"
35
36 -#define BCM2835_USB_VIRT_BASE 0xf0980000
37 -#define BCM2835_USB_VIRT_MPHI 0xf0006000
38 +#define BCM2835_USB_VIRT_BASE (VMALLOC_START)
39 +#define BCM2835_USB_VIRT_MPHI (VMALLOC_START + 0x10000)
40
41 static void __init bcm2835_init(void)
42 {
43 @@ -74,20 +77,26 @@ static int __init bcm2835_map_usb(unsign
44
45 static void __init bcm2835_map_io(void)
46 {
47 - const __be32 *ranges;
48 + const __be32 *ranges, *address_cells;
49 + unsigned long root, addr_cells;
50 int soc, len;
51 unsigned long p2b_offset;
52
53 debug_ll_io_init();
54
55 + root = of_get_flat_dt_root();
56 /* Find out how to map bus to physical address first from soc/ranges */
57 - soc = of_get_flat_dt_subnode_by_name(of_get_flat_dt_root(), "soc");
58 + soc = of_get_flat_dt_subnode_by_name(root, "soc");
59 if (soc < 0)
60 return;
61 + address_cells = of_get_flat_dt_prop(root, "#address-cells", &len);
62 + if (!address_cells || len < (sizeof(unsigned long)))
63 + return;
64 + addr_cells = be32_to_cpu(address_cells[0]);
65 ranges = of_get_flat_dt_prop(soc, "ranges", &len);
66 - if (!ranges || len < (sizeof(unsigned long) * 3))
67 + if (!ranges || len < (sizeof(unsigned long) * (2 + addr_cells)))
68 return;
69 - p2b_offset = be32_to_cpu(ranges[0]) - be32_to_cpu(ranges[1]);
70 + p2b_offset = be32_to_cpu(ranges[0]) - be32_to_cpu(ranges[addr_cells]);
71
72 /* Now search for bcm2708-usb node in device tree */
73 of_scan_flat_dt(bcm2835_map_usb, &p2b_offset);