Mon Dec 30 16:19:27 2019 UTC ()
Fix up ARM_LOCAL for 2711 so that it works now.


(skrll)
diff -r1.28 -r1.29 src/sys/arch/arm/broadcom/bcm2835reg.h
diff -r1.30 -r1.31 src/sys/arch/arm/broadcom/bcm283x_platform.c
diff -r1.4 -r1.5 src/sys/arch/arm/broadcom/bcm283x_platform.h

cvs diff -r1.28 -r1.29 src/sys/arch/arm/broadcom/bcm2835reg.h (switch to unified diff)

--- src/sys/arch/arm/broadcom/bcm2835reg.h 2019/12/26 11:09:11 1.28
+++ src/sys/arch/arm/broadcom/bcm2835reg.h 2019/12/30 16:19:27 1.29
@@ -1,250 +1,256 @@ @@ -1,250 +1,256 @@
1/* $NetBSD: bcm2835reg.h,v 1.28 2019/12/26 11:09:11 skrll Exp $ */ 1/* $NetBSD: bcm2835reg.h,v 1.29 2019/12/30 16:19:27 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nick Hudson 8 * by Nick Hudson
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * Reference: BCM2835 ARM Periperhals 33 * Reference: BCM2835 ARM Periperhals
34 * 34 *
35 * http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf 35 * http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
36 */ 36 */
37 37
38#ifndef _BCM2835REG_H_ 38#ifndef _BCM2835REG_H_
39#define _BCM2835REG_H_ 39#define _BCM2835REG_H_
40 40
41#include "opt_bcm283x.h" 41#include "opt_bcm283x.h"
42 42
43#if defined(SOC_BCM2835) + defined(SOC_BCM2836) != 1 43#if defined(SOC_BCM2835) + defined(SOC_BCM2836) != 1
44#error Must define SOC_BCM2835 or SOC_BCM2836, and not both 44#error Must define SOC_BCM2835 or SOC_BCM2836, and not both
45#endif 45#endif
46 46
47#define BCM2711_PERIPHERALS_BASE 0xfe000000 47#define BCM2711_PERIPHERALS_BASE 0xfe000000
48#define BCM2836_PERIPHERALS_BASE 0x3f000000 48#define BCM2836_PERIPHERALS_BASE 0x3f000000
49#define BCM2835_PERIPHERALS_BASE 0x20000000 49#define BCM2835_PERIPHERALS_BASE 0x20000000
50#define BCM283X_PERIPHERALS_SIZE 0x01000000 /* 16MBytes */ 50#define BCM283X_PERIPHERALS_SIZE 0x01000000 /* 16MBytes */
51#define BCM283X_PERIPHERALS_BASE_BUS 0x7e000000 51#define BCM283X_PERIPHERALS_BASE_BUS 0x7e000000
52 52
53#define BCM2711_PERIPHERALS_PHYS_TO_BUS(a) \ 53#define BCM2711_PERIPHERALS_PHYS_TO_BUS(a) \
54 ((a) - BCM2711_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS) 54 ((a) - BCM2711_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
55#define BCM2711_PERIPHERALS_BUS_TO_PHYS(a) \ 55#define BCM2711_PERIPHERALS_BUS_TO_PHYS(a) \
56 ((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2711_PERIPHERALS_BASE) 56 ((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2711_PERIPHERALS_BASE)
57 57
58#define BCM2836_PERIPHERALS_PHYS_TO_BUS(a) \ 58#define BCM2836_PERIPHERALS_PHYS_TO_BUS(a) \
59 ((a) - BCM2836_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS) 59 ((a) - BCM2836_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
60#define BCM2836_PERIPHERALS_BUS_TO_PHYS(a) \ 60#define BCM2836_PERIPHERALS_BUS_TO_PHYS(a) \
61 ((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2836_PERIPHERALS_BASE) 61 ((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2836_PERIPHERALS_BASE)
62 62
63#define BCM2835_PERIPHERALS_PHYS_TO_BUS(a) \ 63#define BCM2835_PERIPHERALS_PHYS_TO_BUS(a) \
64 ((a) - BCM2835_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS) 64 ((a) - BCM2835_PERIPHERALS_BASE + BCM283X_PERIPHERALS_BASE_BUS)
65#define BCM2835_PERIPHERALS_BUS_TO_PHYS(a) \ 65#define BCM2835_PERIPHERALS_BUS_TO_PHYS(a) \
66 ((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2835_PERIPHERALS_BASE) 66 ((a) - BCM283X_PERIPHERALS_BASE_BUS + BCM2835_PERIPHERALS_BASE)
67 67
68#define BCM2835_STIMER_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00003000) 68#define BCM2835_STIMER_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00003000)
69#define BCM2835_DMA0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00007000) 69#define BCM2835_DMA0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00007000)
70#define BCM2835_ARM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x0000B000) 70#define BCM2835_ARM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x0000B000)
71#define BCM2835_PM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00100000) 71#define BCM2835_PM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00100000)
72#define BCM2835_CM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00101000) 72#define BCM2835_CM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00101000)
73#define BCM2835_RNG_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00104000) 73#define BCM2835_RNG_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00104000)
74#define BCM2835_GPIO_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00200000) 74#define BCM2835_GPIO_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00200000)
75#define BCM2835_UART0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00201000) 75#define BCM2835_UART0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00201000)
76#define BCM2835_SDHOST_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00202000) 76#define BCM2835_SDHOST_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00202000)
77#define BCM2835_PCM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00203000) 77#define BCM2835_PCM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00203000)
78#define BCM2835_SPI0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00204000) 78#define BCM2835_SPI0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00204000)
79#define BCM2835_BSC0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00205000) 79#define BCM2835_BSC0_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00205000)
80#define BCM2835_PWM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x0020C000) 80#define BCM2835_PWM_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x0020C000)
81#define BCM2835_BSCSPISLV_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00214000) 81#define BCM2835_BSCSPISLV_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00214000)
82#define BCM2835_AUX_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00215000) 82#define BCM2835_AUX_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00215000)
83#define BCM2835_AUX_UART_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00215040) 83#define BCM2835_AUX_UART_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00215040)
84#define BCM2835_EMMC_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00300000) 84#define BCM2835_EMMC_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00300000)
85#define BCM2835_BSC1_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00804000) 85#define BCM2835_BSC1_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00804000)
86#define BCM2835_BSC2_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00805000) 86#define BCM2835_BSC2_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00805000)
87#define BCM2835_USB_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00980000) 87#define BCM2835_USB_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00980000)
88#define BCM2835_DMA15_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00E05000) 88#define BCM2835_DMA15_BASE (BCM283X_PERIPHERALS_BASE_BUS + 0x00E05000)
89 89
90#define BCM2835_STIMER_SIZE 0x1c 90#define BCM2835_STIMER_SIZE 0x1c
91#define BCM2835_DMA0_SIZE 0x1000 91#define BCM2835_DMA0_SIZE 0x1000
92#define BCM2835_ARM_SIZE 0x1000 92#define BCM2835_ARM_SIZE 0x1000
93#define BCM2835_PM_SIZE 0x1000 93#define BCM2835_PM_SIZE 0x1000
94#define BCM2835_CM_SIZE 0xa8 94#define BCM2835_CM_SIZE 0xa8
95#define BCM2835_RNG_SIZE 0x1000 95#define BCM2835_RNG_SIZE 0x1000
96#define BCM2835_GPIO_SIZE 0x1000 96#define BCM2835_GPIO_SIZE 0x1000
97#define BCM2835_UART0_SIZE 0x90 97#define BCM2835_UART0_SIZE 0x90
98#define BCM2835_PCM_SIZE 0x1000 98#define BCM2835_PCM_SIZE 0x1000
99#define BCM2835_SPI0_SIZE 0x1000 99#define BCM2835_SPI0_SIZE 0x1000
100#define BCM2835_BSC_SIZE 0x1000 100#define BCM2835_BSC_SIZE 0x1000
101#define BCM2835_PWM_SIZE 0x28 101#define BCM2835_PWM_SIZE 0x28
102#define BCM2835_AUX_SIZE 0x8 102#define BCM2835_AUX_SIZE 0x8
103#define BCM2835_AUX_UART_SIZE 0x40 103#define BCM2835_AUX_UART_SIZE 0x40
104#define BCM2835_SDHOST_SIZE 0x1000 104#define BCM2835_SDHOST_SIZE 0x1000
105#define BCM2835_EMMC_SIZE 0x1000 105#define BCM2835_EMMC_SIZE 0x1000
106#define BCM2835_USB_SIZE 0x20000 106#define BCM2835_USB_SIZE 0x20000
107#define BCM2835_DMA15_SIZE 0x100 107#define BCM2835_DMA15_SIZE 0x100
108 108
109 109
110#define BCM2835_BUSADDR_CACHE_MASK 0xc0000000 110#define BCM2835_BUSADDR_CACHE_MASK 0xc0000000
111#define BCM2835_BUSADDR_CACHE_COHERENT 0x40000000 111#define BCM2835_BUSADDR_CACHE_COHERENT 0x40000000
112#define BCM2835_BUSADDR_CACHE_L1L2 0x00000000 112#define BCM2835_BUSADDR_CACHE_L1L2 0x00000000
113#define BCM2835_BUSADDR_CACHE_L2ONLY 0x80000000 113#define BCM2835_BUSADDR_CACHE_L2ONLY 0x80000000
114#define BCM2835_BUSADDR_CACHE_DIRECT 0xc0000000 114#define BCM2835_BUSADDR_CACHE_DIRECT 0xc0000000
115 115
116#define BCM2835_ARMICU_BASE (BCM2835_ARM_BASE + 0x0200) 116#define BCM2835_ARMICU_BASE (BCM2835_ARM_BASE + 0x0200)
117#define BCM2835_ARMICU_SIZE 0x200 117#define BCM2835_ARMICU_SIZE 0x200
118 118
119#define BCM2835_VCHIQ_BASE (BCM2835_ARM_BASE + 0x0800) 119#define BCM2835_VCHIQ_BASE (BCM2835_ARM_BASE + 0x0800)
120#define BCM2835_VCHIQ_SIZE 0x50 120#define BCM2835_VCHIQ_SIZE 0x50
121 121
122#define BCM2835_ARMMBOX_BASE (BCM2835_ARM_BASE + 0x0880) 122#define BCM2835_ARMMBOX_BASE (BCM2835_ARM_BASE + 0x0880)
123#define BCM2835_ARMMBOX_SIZE 0x40 123#define BCM2835_ARMMBOX_SIZE 0x40
124 124
125#define BCM2835_INTC_BASE (0x0) /* Relative to BCM2835_ARMICU_BASE */ 125#define BCM2835_INTC_BASE (0x0) /* Relative to BCM2835_ARMICU_BASE */
126 126
127/* Interrupt controller */ 127/* Interrupt controller */
128#define BCM2835_INTC_IRQBPENDING (BCM2835_INTC_BASE + 0x00) /* IRQ Basic pending */ 128#define BCM2835_INTC_IRQBPENDING (BCM2835_INTC_BASE + 0x00) /* IRQ Basic pending */
129#define BCM2835_INTC_IRQ1PENDING (BCM2835_INTC_BASE + 0x04) /* IRQ pending 1 */ 129#define BCM2835_INTC_IRQ1PENDING (BCM2835_INTC_BASE + 0x04) /* IRQ pending 1 */
130#define BCM2835_INTC_IRQ2PENDING (BCM2835_INTC_BASE + 0x08) /* IRQ pending 2 */ 130#define BCM2835_INTC_IRQ2PENDING (BCM2835_INTC_BASE + 0x08) /* IRQ pending 2 */
131#define BCM2835_INTC_FIQCTL (BCM2835_INTC_BASE + 0x0c) /* FIQ control */ 131#define BCM2835_INTC_FIQCTL (BCM2835_INTC_BASE + 0x0c) /* FIQ control */
132#define BCM2835_INTC_IRQ1ENABLE (BCM2835_INTC_BASE + 0x10) /* Enable IRQs 1 */ 132#define BCM2835_INTC_IRQ1ENABLE (BCM2835_INTC_BASE + 0x10) /* Enable IRQs 1 */
133#define BCM2835_INTC_IRQ2ENABLE (BCM2835_INTC_BASE + 0x14) /* Enable IRQs 2 */ 133#define BCM2835_INTC_IRQ2ENABLE (BCM2835_INTC_BASE + 0x14) /* Enable IRQs 2 */
134#define BCM2835_INTC_IRQBENABLE (BCM2835_INTC_BASE + 0x18) /* Enable Basic IRQs */ 134#define BCM2835_INTC_IRQBENABLE (BCM2835_INTC_BASE + 0x18) /* Enable Basic IRQs */
135#define BCM2835_INTC_IRQ1DISABLE (BCM2835_INTC_BASE + 0x1c) /* Disable IRQ 1 */ 135#define BCM2835_INTC_IRQ1DISABLE (BCM2835_INTC_BASE + 0x1c) /* Disable IRQ 1 */
136#define BCM2835_INTC_IRQ2DISABLE (BCM2835_INTC_BASE + 0x20) /* Disable IRQ 2 */ 136#define BCM2835_INTC_IRQ2DISABLE (BCM2835_INTC_BASE + 0x20) /* Disable IRQ 2 */
137#define BCM2835_INTC_IRQBDISABLE (BCM2835_INTC_BASE + 0x24) /* Disable Basic IRQs */ 137#define BCM2835_INTC_IRQBDISABLE (BCM2835_INTC_BASE + 0x24) /* Disable Basic IRQs */
138 138
139#define BCM2835_INTC_ENABLEBASE (BCM2835_INTC_BASE + 0x10) 139#define BCM2835_INTC_ENABLEBASE (BCM2835_INTC_BASE + 0x10)
140#define BCM2835_INTC_DISABLEBASE (BCM2835_INTC_BASE + 0x1c) 140#define BCM2835_INTC_DISABLEBASE (BCM2835_INTC_BASE + 0x1c)
141 141
142#define BCM2836_NCPUS 4 142#define BCM2836_NCPUS 4
143#define BCM2836_NIRQPERCPU 32 143#define BCM2836_NIRQPERCPU 32
144 144
145#define BCM2836_INT_CNTPSIRQ 0 145#define BCM2836_INT_CNTPSIRQ 0
146#define BCM2836_INT_CNTPNSIRQ 1 146#define BCM2836_INT_CNTPNSIRQ 1
147#define BCM2836_INT_CNTHPIRQ 2 147#define BCM2836_INT_CNTHPIRQ 2
148#define BCM2836_INT_CNTVIRQ 3 148#define BCM2836_INT_CNTVIRQ 3
149#define BCM2836_INT_MAILBOX0 4 149#define BCM2836_INT_MAILBOX0 4
150#define BCM2836_INT_MAILBOX1 5 150#define BCM2836_INT_MAILBOX1 5
151#define BCM2836_INT_MAILBOX2 6 151#define BCM2836_INT_MAILBOX2 6
152#define BCM2836_INT_MAILBOX3 7 152#define BCM2836_INT_MAILBOX3 7
153#define BCM2836_INT_GPU_FAST 8 153#define BCM2836_INT_GPU_FAST 8
154#define BCM2836_INT_PMU_FAST 9 154#define BCM2836_INT_PMU_FAST 9
155#define BCM2836_INT_ZERO 10 155#define BCM2836_INT_ZERO 10
156#define BCM2836_INT_TIMER 11 156#define BCM2836_INT_TIMER 11
157#define BCM2836_INT_NLOCAL 12 157#define BCM2836_INT_NLOCAL 12
158 158
159#define BCM2836_INT_CNTPSIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTPSIRQ) 159#define BCM2836_INT_CNTPSIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTPSIRQ)
160#define BCM2836_INT_CNTPNSIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTPNSIRQ) 160#define BCM2836_INT_CNTPNSIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTPNSIRQ)
161#define BCM2836_INT_CNTVIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTVIRQ) 161#define BCM2836_INT_CNTVIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTVIRQ)
162#define BCM2836_INT_CNTHPIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTHPIRQ) 162#define BCM2836_INT_CNTHPIRQ_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_CNTHPIRQ)
163#define BCM2836_INT_MAILBOX0_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_MAILBOX0) 163#define BCM2836_INT_MAILBOX0_CPUN(n) (BCM2836_INT_BASECPUN(n) + BCM2836_INT_MAILBOX0)
164 164
165/* Periperal Interrupt sources */ 165/* Periperal Interrupt sources */
166#define BCM2835_NIRQ 96 166#define BCM2835_NIRQ 96
167 167
168#define BCM2835_INT_GPU0BASE (BCM2835_INT_BASE + 0) 168#define BCM2835_INT_GPU0BASE (BCM2835_INT_BASE + 0)
169#define BCM2835_INT_TIMER0 (BCM2835_INT_GPU0BASE + 0) 169#define BCM2835_INT_TIMER0 (BCM2835_INT_GPU0BASE + 0)
170#define BCM2835_INT_TIMER1 (BCM2835_INT_GPU0BASE + 1) 170#define BCM2835_INT_TIMER1 (BCM2835_INT_GPU0BASE + 1)
171#define BCM2835_INT_TIMER2 (BCM2835_INT_GPU0BASE + 2) 171#define BCM2835_INT_TIMER2 (BCM2835_INT_GPU0BASE + 2)
172#define BCM2835_INT_TIMER3 (BCM2835_INT_GPU0BASE + 3) 172#define BCM2835_INT_TIMER3 (BCM2835_INT_GPU0BASE + 3)
173#define BCM2835_INT_USB (BCM2835_INT_GPU0BASE + 9) 173#define BCM2835_INT_USB (BCM2835_INT_GPU0BASE + 9)
174#define BCM2835_INT_DMA0 (BCM2835_INT_GPU0BASE + 16) 174#define BCM2835_INT_DMA0 (BCM2835_INT_GPU0BASE + 16)
175#define BCM2835_INT_DMA2 (BCM2835_INT_GPU0BASE + 18) 175#define BCM2835_INT_DMA2 (BCM2835_INT_GPU0BASE + 18)
176#define BCM2835_INT_DMA3 (BCM2835_INT_GPU0BASE + 19) 176#define BCM2835_INT_DMA3 (BCM2835_INT_GPU0BASE + 19)
177#define BCM2835_INT_AUX (BCM2835_INT_GPU0BASE + 29) 177#define BCM2835_INT_AUX (BCM2835_INT_GPU0BASE + 29)
178#define BCM2835_INT_ARM (BCM2835_INT_GPU0BASE + 30) 178#define BCM2835_INT_ARM (BCM2835_INT_GPU0BASE + 30)
179 179
180#define BCM2835_INT_GPU1BASE (BCM2835_INT_BASE + 32) 180#define BCM2835_INT_GPU1BASE (BCM2835_INT_BASE + 32)
181#define BCM2835_INT_GPIO0 (BCM2835_INT_GPU1BASE + 17) 181#define BCM2835_INT_GPIO0 (BCM2835_INT_GPU1BASE + 17)
182#define BCM2835_INT_GPIO1 (BCM2835_INT_GPU1BASE + 18) 182#define BCM2835_INT_GPIO1 (BCM2835_INT_GPU1BASE + 18)
183#define BCM2835_INT_GPIO2 (BCM2835_INT_GPU1BASE + 19) 183#define BCM2835_INT_GPIO2 (BCM2835_INT_GPU1BASE + 19)
184#define BCM2835_INT_GPIO3 (BCM2835_INT_GPU1BASE + 20) 184#define BCM2835_INT_GPIO3 (BCM2835_INT_GPU1BASE + 20)
185#define BCM2835_INT_BSC (BCM2835_INT_GPU1BASE + 21) 185#define BCM2835_INT_BSC (BCM2835_INT_GPU1BASE + 21)
186#define BCM2835_INT_SPI0 (BCM2835_INT_GPU1BASE + 22) 186#define BCM2835_INT_SPI0 (BCM2835_INT_GPU1BASE + 22)
187#define BCM2835_INT_PCM (BCM2835_INT_GPU1BASE + 23) 187#define BCM2835_INT_PCM (BCM2835_INT_GPU1BASE + 23)
188#define BCM2835_INT_SDHOST (BCM2835_INT_GPU1BASE + 24) 188#define BCM2835_INT_SDHOST (BCM2835_INT_GPU1BASE + 24)
189#define BCM2835_INT_UART0 (BCM2835_INT_GPU1BASE + 25) 189#define BCM2835_INT_UART0 (BCM2835_INT_GPU1BASE + 25)
190#define BCM2835_INT_EMMC (BCM2835_INT_GPU1BASE + 30) 190#define BCM2835_INT_EMMC (BCM2835_INT_GPU1BASE + 30)
191 191
192#define BCM2835_INT_BASICBASE (BCM2835_INT_BASE + 64) 192#define BCM2835_INT_BASICBASE (BCM2835_INT_BASE + 64)
193#define BCM2835_INT_ARMTIMER (BCM2835_INT_BASICBASE + 0) 193#define BCM2835_INT_ARMTIMER (BCM2835_INT_BASICBASE + 0)
194#define BCM2835_INT_ARMMAILBOX (BCM2835_INT_BASICBASE + 1) 194#define BCM2835_INT_ARMMAILBOX (BCM2835_INT_BASICBASE + 1)
195#define BCM2835_INT_ARMDOORBELL0 (BCM2835_INT_BASICBASE + 2) 195#define BCM2835_INT_ARMDOORBELL0 (BCM2835_INT_BASICBASE + 2)
196#define BCM2835_INT_ARMDOORBELL1 (BCM2835_INT_BASICBASE + 3) 196#define BCM2835_INT_ARMDOORBELL1 (BCM2835_INT_BASICBASE + 3)
197#define BCM2835_INT_GPU0HALTED (BCM2835_INT_BASICBASE + 4) 197#define BCM2835_INT_GPU0HALTED (BCM2835_INT_BASICBASE + 4)
198#define BCM2835_INT_GPU1HALTED (BCM2835_INT_BASICBASE + 5) 198#define BCM2835_INT_GPU1HALTED (BCM2835_INT_BASICBASE + 5)
199#define BCM2835_INT_ILLEGALTYPE0 (BCM2835_INT_BASICBASE + 6) 199#define BCM2835_INT_ILLEGALTYPE0 (BCM2835_INT_BASICBASE + 6)
200#define BCM2835_INT_ILLEGALTYPE1 (BCM2835_INT_BASICBASE + 7) 200#define BCM2835_INT_ILLEGALTYPE1 (BCM2835_INT_BASICBASE + 7)
201 201
202 202
203#define BCM2835_UART0_CLK 3000000 203#define BCM2835_UART0_CLK 3000000
204 204
 205#define BCM2711_ARM_LOCAL_BASE_BUS 0x40000000
205#define BCM2711_ARM_LOCAL_BASE 0xff800000 206#define BCM2711_ARM_LOCAL_BASE 0xff800000
206#define BCM2711_ARM_LOCAL_SIZE 0x00100000 /* 1MByte */ 207#define BCM2711_ARM_LOCAL_SIZE 0x00100000 /* 1MBytes */
 208
 209#define BCM2711_ARM_LOCAL_PHYS_TO_BUS(a) \
 210 ((a) - BCM2711_ARM_LOCAL_BASE + BCM2711_ARM_LOCAL_BASE_BUS)
 211#define BCM2711_ARM_LOCAL_BUS_TO_PHYS(a) \
 212 ((a) - BCM2711_ARM_LOCAL_BASE_BUS + BCM2711_ARM_LOCAL_BASE)
207 213
208#define BCM2836_ARM_LOCAL_BASE 0x40000000 214#define BCM2836_ARM_LOCAL_BASE 0x40000000
209#define BCM2836_ARM_LOCAL_SIZE 0x00001000 /* 4KBytes */ 215#define BCM2836_ARM_LOCAL_SIZE 0x00001000 /* 4KBytes */
210 216
211#define BCM2836_LOCAL_CONTROL 0x000 217#define BCM2836_LOCAL_CONTROL 0x000
212#define BCM2836_LOCAL_PRESCALER 0x008 218#define BCM2836_LOCAL_PRESCALER 0x008
213#define BCM2836_LOCAL_GPU_INT_ROUTING 0x00c 219#define BCM2836_LOCAL_GPU_INT_ROUTING 0x00c
214#define BCM2836_LOCAL_PM_ROUTING_SET 0x010 220#define BCM2836_LOCAL_PM_ROUTING_SET 0x010
215#define BCM2836_LOCAL_PM_ROUTING_CLR 0x014 221#define BCM2836_LOCAL_PM_ROUTING_CLR 0x014
216#define BCM2836_LOCAL_TIMER_LS 0x01c 222#define BCM2836_LOCAL_TIMER_LS 0x01c
217#define BCM2836_LOCAL_TIMER_MS 0x020 223#define BCM2836_LOCAL_TIMER_MS 0x020
218#define BCM2836_LOCAL_INT_ROUTING 0x024 224#define BCM2836_LOCAL_INT_ROUTING 0x024
219#define BCM2836_LOCAL_AXI_COUNT 0x02c 225#define BCM2836_LOCAL_AXI_COUNT 0x02c
220#define BCM2836_LOCAL_AXI_IRQ 0x030 226#define BCM2836_LOCAL_AXI_IRQ 0x030
221#define BCM2836_LOCAL_TIMER_CONTROL 0x034 227#define BCM2836_LOCAL_TIMER_CONTROL 0x034
222#define BCM2836_LOCAL_TIMER_WRITE 0x038 228#define BCM2836_LOCAL_TIMER_WRITE 0x038
223 229
224 230
225#define BCM2836_LOCAL_TIMER_IRQ_CONTROL_BASE 0x40 231#define BCM2836_LOCAL_TIMER_IRQ_CONTROL_BASE 0x40
226#define BCM2836_LOCAL_MAILBOX_IRQ_CONTROL_BASE 0x50 232#define BCM2836_LOCAL_MAILBOX_IRQ_CONTROL_BASE 0x50
227#define BCM2836_LOCAL_INTC_IRQPENDING_BASE 0x60 233#define BCM2836_LOCAL_INTC_IRQPENDING_BASE 0x60
228#define BCM2836_LOCAL_INTC_FIQPENDING_BASE 0x70 234#define BCM2836_LOCAL_INTC_FIQPENDING_BASE 0x70
229 235
230#define BCM2836_LOCAL_TIMER_IRQ_CONTROL_SIZE 0x10 236#define BCM2836_LOCAL_TIMER_IRQ_CONTROL_SIZE 0x10
231#define BCM2836_LOCAL_MAILBOX_IRQ_CONTROL_SIZE 0x10 237#define BCM2836_LOCAL_MAILBOX_IRQ_CONTROL_SIZE 0x10
232 238
233#define BCM2836_LOCAL_TIMER_IRQ_CONTROLN(n) (BCM2836_LOCAL_TIMER_IRQ_CONTROL_BASE + 4*(n)) 239#define BCM2836_LOCAL_TIMER_IRQ_CONTROLN(n) (BCM2836_LOCAL_TIMER_IRQ_CONTROL_BASE + 4*(n))
234#define BCM2836_LOCAL_MAILBOX_IRQ_CONTROLN(n) (BCM2836_LOCAL_MAILBOX_IRQ_CONTROL_BASE + 4*(n)) 240#define BCM2836_LOCAL_MAILBOX_IRQ_CONTROLN(n) (BCM2836_LOCAL_MAILBOX_IRQ_CONTROL_BASE + 4*(n))
235#define BCM2836_LOCAL_INTC_IRQPENDINGN(n) (BCM2836_LOCAL_INTC_IRQPENDING_BASE + 4*(n)) 241#define BCM2836_LOCAL_INTC_IRQPENDINGN(n) (BCM2836_LOCAL_INTC_IRQPENDING_BASE + 4*(n))
236#define BCM2836_LOCAL_INTC_FIQPENDINGN(n) (BCM2836_LOCAL_INTC_FIQPENDING_BASE + 4*(n)) 242#define BCM2836_LOCAL_INTC_FIQPENDINGN(n) (BCM2836_LOCAL_INTC_FIQPENDING_BASE + 4*(n))
237 243
238#define BCM2836_LOCAL_MAILBOX0_SETN(n) (0x80 + 0x10 * (n)) 244#define BCM2836_LOCAL_MAILBOX0_SETN(n) (0x80 + 0x10 * (n))
239#define BCM2836_LOCAL_MAILBOX1_SETN(n) (0x84 + 0x10 * (n)) 245#define BCM2836_LOCAL_MAILBOX1_SETN(n) (0x84 + 0x10 * (n))
240#define BCM2836_LOCAL_MAILBOX2_SETN(n) (0x88 + 0x10 * (n)) 246#define BCM2836_LOCAL_MAILBOX2_SETN(n) (0x88 + 0x10 * (n))
241#define BCM2836_LOCAL_MAILBOX3_SETN(n) (0x8c + 0x10 * (n)) 247#define BCM2836_LOCAL_MAILBOX3_SETN(n) (0x8c + 0x10 * (n))
242#define BCM2836_LOCAL_MAILBOX0_CLRN(n) (0xc0 + 0x10 * (n)) 248#define BCM2836_LOCAL_MAILBOX0_CLRN(n) (0xc0 + 0x10 * (n))
243#define BCM2836_LOCAL_MAILBOX1_CLRN(n) (0xc4 + 0x10 * (n)) 249#define BCM2836_LOCAL_MAILBOX1_CLRN(n) (0xc4 + 0x10 * (n))
244#define BCM2836_LOCAL_MAILBOX2_CLRN(n) (0xc8 + 0x10 * (n)) 250#define BCM2836_LOCAL_MAILBOX2_CLRN(n) (0xc8 + 0x10 * (n))
245#define BCM2836_LOCAL_MAILBOX3_CLRN(n) (0xcc + 0x10 * (n)) 251#define BCM2836_LOCAL_MAILBOX3_CLRN(n) (0xcc + 0x10 * (n))
246 252
247#define BCM2836_ARM_SMP_BASE 0x00000000 253#define BCM2836_ARM_SMP_BASE 0x00000000
248#define BCM2836_ARM_SMP_SIZE 0x00001000 /* 4KBytes */ 254#define BCM2836_ARM_SMP_SIZE 0x00001000 /* 4KBytes */
249 255
250#endif /* _BCM2835REG_H_ */ 256#endif /* _BCM2835REG_H_ */

cvs diff -r1.30 -r1.31 src/sys/arch/arm/broadcom/bcm283x_platform.c (switch to unified diff)

--- src/sys/arch/arm/broadcom/bcm283x_platform.c 2019/12/30 16:06:29 1.30
+++ src/sys/arch/arm/broadcom/bcm283x_platform.c 2019/12/30 16:19:27 1.31
@@ -1,1335 +1,1335 @@ @@ -1,1335 +1,1335 @@
1/* $NetBSD: bcm283x_platform.c,v 1.30 2019/12/30 16:06:29 skrll Exp $ */ 1/* $NetBSD: bcm283x_platform.c,v 1.31 2019/12/30 16:19:27 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2017 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2017 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.30 2019/12/30 16:06:29 skrll Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.31 2019/12/30 16:19:27 skrll Exp $");
31 31
32#include "opt_arm_debug.h" 32#include "opt_arm_debug.h"
33#include "opt_bcm283x.h" 33#include "opt_bcm283x.h"
34#include "opt_cpuoptions.h" 34#include "opt_cpuoptions.h"
35#include "opt_ddb.h" 35#include "opt_ddb.h"
36#include "opt_evbarm_boardtype.h" 36#include "opt_evbarm_boardtype.h"
37#include "opt_kgdb.h" 37#include "opt_kgdb.h"
38#include "opt_fdt.h" 38#include "opt_fdt.h"
39#include "opt_rpi.h" 39#include "opt_rpi.h"
40#include "opt_vcprop.h" 40#include "opt_vcprop.h"
41 41
42#include "sdhc.h" 42#include "sdhc.h"
43#include "bcmsdhost.h" 43#include "bcmsdhost.h"
44#include "bcmdwctwo.h" 44#include "bcmdwctwo.h"
45#include "bcmspi.h" 45#include "bcmspi.h"
46#include "bsciic.h" 46#include "bsciic.h"
47#include "plcom.h" 47#include "plcom.h"
48#include "com.h" 48#include "com.h"
49#include "genfb.h" 49#include "genfb.h"
50#include "ukbd.h" 50#include "ukbd.h"
51 51
52#include <sys/param.h> 52#include <sys/param.h>
53#include <sys/bus.h> 53#include <sys/bus.h>
54#include <sys/cpu.h> 54#include <sys/cpu.h>
55#include <sys/device.h> 55#include <sys/device.h>
56#include <sys/termios.h> 56#include <sys/termios.h>
57 57
58#include <net/if_ether.h> 58#include <net/if_ether.h>
59 59
60#include <prop/proplib.h> 60#include <prop/proplib.h>
61 61
62#include <dev/fdt/fdtvar.h> 62#include <dev/fdt/fdtvar.h>
63 63
64#include <uvm/uvm_extern.h> 64#include <uvm/uvm_extern.h>
65 65
66#include <machine/bootconfig.h> 66#include <machine/bootconfig.h>
67 67
68#include <arm/armreg.h> 68#include <arm/armreg.h>
69#include <arm/cpufunc.h> 69#include <arm/cpufunc.h>
70 70
71#include <libfdt.h> 71#include <libfdt.h>
72 72
73#include <arm/broadcom/bcm2835reg.h> 73#include <arm/broadcom/bcm2835reg.h>
74#include <arm/broadcom/bcm2835var.h> 74#include <arm/broadcom/bcm2835var.h>
75#include <arm/broadcom/bcm283x_platform.h> 75#include <arm/broadcom/bcm283x_platform.h>
76#include <arm/broadcom/bcm2835_intr.h> 76#include <arm/broadcom/bcm2835_intr.h>
77#include <arm/broadcom/bcm2835_mbox.h> 77#include <arm/broadcom/bcm2835_mbox.h>
78#include <arm/broadcom/bcm2835_pmwdogvar.h> 78#include <arm/broadcom/bcm2835_pmwdogvar.h>
79 79
80#include <evbarm/dev/plcomreg.h> 80#include <evbarm/dev/plcomreg.h>
81#include <evbarm/dev/plcomvar.h> 81#include <evbarm/dev/plcomvar.h>
82#include <evbarm/fdt/machdep.h> 82#include <evbarm/fdt/machdep.h>
83 83
84#include <dev/ic/ns16550reg.h> 84#include <dev/ic/ns16550reg.h>
85#include <dev/ic/comreg.h> 85#include <dev/ic/comreg.h>
86 86
87#include <evbarm/rpi/vcio.h> 87#include <evbarm/rpi/vcio.h>
88#include <evbarm/rpi/vcpm.h> 88#include <evbarm/rpi/vcpm.h>
89#include <evbarm/rpi/vcprop.h> 89#include <evbarm/rpi/vcprop.h>
90 90
91#include <arm/fdt/arm_fdtvar.h> 91#include <arm/fdt/arm_fdtvar.h>
92 92
93#include <arm/cortex/gtmr_var.h> 93#include <arm/cortex/gtmr_var.h>
94 94
95#if NGENFB > 0 95#if NGENFB > 0
96#include <dev/videomode/videomode.h> 96#include <dev/videomode/videomode.h>
97#include <dev/videomode/edidvar.h> 97#include <dev/videomode/edidvar.h>
98#include <dev/wscons/wsconsio.h> 98#include <dev/wscons/wsconsio.h>
99#endif 99#endif
100 100
101#if NUKBD > 0 101#if NUKBD > 0
102#include <dev/usb/ukbdvar.h> 102#include <dev/usb/ukbdvar.h>
103#endif 103#endif
104 104
105#ifdef DDB 105#ifdef DDB
106#include <machine/db_machdep.h> 106#include <machine/db_machdep.h>
107#include <ddb/db_sym.h> 107#include <ddb/db_sym.h>
108#include <ddb/db_extern.h> 108#include <ddb/db_extern.h>
109#endif 109#endif
110 110
111#define RPI_CPU_MAX 4 111#define RPI_CPU_MAX 4
112 112
113void bcm2835_platform_early_putchar(char c); 113void bcm2835_platform_early_putchar(char c);
114void bcm2836_platform_early_putchar(char c); 114void bcm2836_platform_early_putchar(char c);
115void bcm2837_platform_early_putchar(char c); 115void bcm2837_platform_early_putchar(char c);
116void bcm2711_platform_early_putchar(char c); 116void bcm2711_platform_early_putchar(char c);
117 117
118extern void bcmgenfb_set_console_dev(device_t dev); 118extern void bcmgenfb_set_console_dev(device_t dev);
119void bcmgenfb_set_ioctl(int(*)(void *, void *, u_long, void *, int, struct lwp *)); 119void bcmgenfb_set_ioctl(int(*)(void *, void *, u_long, void *, int, struct lwp *));
120extern void bcmgenfb_ddb_trap_callback(int where); 120extern void bcmgenfb_ddb_trap_callback(int where);
121static int rpi_ioctl(void *, void *, u_long, void *, int, lwp_t *); 121static int rpi_ioctl(void *, void *, u_long, void *, int, lwp_t *);
122 122
123extern struct bus_space arm_generic_bs_tag; 123extern struct bus_space arm_generic_bs_tag;
124extern struct bus_space arm_generic_a4x_bs_tag; 124extern struct bus_space arm_generic_a4x_bs_tag;
125 125
126/* Prototypes for all the bus_space structure functions */ 126/* Prototypes for all the bus_space structure functions */
127bs_protos(arm_generic); 127bs_protos(arm_generic);
128bs_protos(arm_generic_a4x); 128bs_protos(arm_generic_a4x);
129bs_protos(bcm2835); 129bs_protos(bcm2835);
130bs_protos(bcm2835_a4x); 130bs_protos(bcm2835_a4x);
131bs_protos(bcm2836); 131bs_protos(bcm2836);
132bs_protos(bcm2836_a4x); 132bs_protos(bcm2836_a4x);
133bs_protos(bcm2711); 133bs_protos(bcm2711);
134bs_protos(bcm2711_a4x); 134bs_protos(bcm2711_a4x);
135 135
136struct bus_space bcm2835_bs_tag; 136struct bus_space bcm2835_bs_tag;
137struct bus_space bcm2835_a4x_bs_tag; 137struct bus_space bcm2835_a4x_bs_tag;
138struct bus_space bcm2836_bs_tag; 138struct bus_space bcm2836_bs_tag;
139struct bus_space bcm2836_a4x_bs_tag; 139struct bus_space bcm2836_a4x_bs_tag;
140struct bus_space bcm2711_bs_tag; 140struct bus_space bcm2711_bs_tag;
141struct bus_space bcm2711_a4x_bs_tag; 141struct bus_space bcm2711_a4x_bs_tag;
142 142
143static paddr_t bcm2835_bus_to_phys(bus_addr_t); 143static paddr_t bcm2835_bus_to_phys(bus_addr_t);
144static paddr_t bcm2836_bus_to_phys(bus_addr_t); 144static paddr_t bcm2836_bus_to_phys(bus_addr_t);
145static paddr_t bcm2711_bus_to_phys(bus_addr_t); 145static paddr_t bcm2711_bus_to_phys(bus_addr_t);
146 146
147#ifdef VERBOSE_INIT_ARM 147#ifdef VERBOSE_INIT_ARM
148#define VPRINTF(...) printf(__VA_ARGS__) 148#define VPRINTF(...) printf(__VA_ARGS__)
149#else 149#else
150#define VPRINTF(...) __nothing 150#define VPRINTF(...) __nothing
151#endif 151#endif
152 152
153static paddr_t 153static paddr_t
154bcm2835_bus_to_phys(bus_addr_t ba) 154bcm2835_bus_to_phys(bus_addr_t ba)
155{ 155{
156 156
157 /* Attempt to find the PA device mapping */ 157 /* Attempt to find the PA device mapping */
158 if (ba >= BCM283X_PERIPHERALS_BASE_BUS && 158 if (ba >= BCM283X_PERIPHERALS_BASE_BUS &&
159 ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) 159 ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE)
160 return BCM2835_PERIPHERALS_BUS_TO_PHYS(ba); 160 return BCM2835_PERIPHERALS_BUS_TO_PHYS(ba);
161 161
162 return ba & ~BCM2835_BUSADDR_CACHE_MASK; 162 return ba & ~BCM2835_BUSADDR_CACHE_MASK;
163} 163}
164 164
165static paddr_t 165static paddr_t
166bcm2836_bus_to_phys(bus_addr_t ba) 166bcm2836_bus_to_phys(bus_addr_t ba)
167{ 167{
168 168
169 /* Attempt to find the PA device mapping */ 169 /* Attempt to find the PA device mapping */
170 if (ba >= BCM283X_PERIPHERALS_BASE_BUS && 170 if (ba >= BCM283X_PERIPHERALS_BASE_BUS &&
171 ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) 171 ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE)
172 return BCM2836_PERIPHERALS_BUS_TO_PHYS(ba); 172 return BCM2836_PERIPHERALS_BUS_TO_PHYS(ba);
173 173
174 if (ba >= BCM2836_ARM_LOCAL_BASE && 174 if (ba >= BCM2836_ARM_LOCAL_BASE &&
175 ba < BCM2836_ARM_LOCAL_BASE + BCM2836_ARM_LOCAL_SIZE) 175 ba < BCM2836_ARM_LOCAL_BASE + BCM2836_ARM_LOCAL_SIZE)
176 return ba; 176 return ba;
177 177
178 return ba & ~BCM2835_BUSADDR_CACHE_MASK; 178 return ba & ~BCM2835_BUSADDR_CACHE_MASK;
179} 179}
180 180
181static paddr_t 181static paddr_t
182bcm2711_bus_to_phys(bus_addr_t ba) 182bcm2711_bus_to_phys(bus_addr_t ba)
183{ 183{
184 184
185 /* Attempt to find the PA device mapping */ 185 /* Attempt to find the PA device mapping */
186 if (ba >= BCM283X_PERIPHERALS_BASE_BUS && 186 if (ba >= BCM283X_PERIPHERALS_BASE_BUS &&
187 ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) 187 ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE)
188 return BCM2711_PERIPHERALS_BUS_TO_PHYS(ba); 188 return BCM2711_PERIPHERALS_BUS_TO_PHYS(ba);
189 189
190 if (ba >= BCM2711_ARM_LOCAL_BASE && 190 if (ba >= BCM2711_ARM_LOCAL_BASE_BUS &&
191 ba < BCM2711_ARM_LOCAL_BASE + BCM2711_ARM_LOCAL_SIZE) 191 ba < BCM2711_ARM_LOCAL_BASE_BUS + BCM2711_ARM_LOCAL_SIZE)
192 return ba; 192 return BCM2711_ARM_LOCAL_BUS_TO_PHYS(ba);
193 193
194 return ba & ~BCM2835_BUSADDR_CACHE_MASK; 194 return ba & ~BCM2835_BUSADDR_CACHE_MASK;
195} 195}
196 196
197int 197int
198bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, 198bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
199 bus_space_handle_t *bshp) 199 bus_space_handle_t *bshp)
200{ 200{
201 const paddr_t pa = bcm2835_bus_to_phys(ba); 201 const paddr_t pa = bcm2835_bus_to_phys(ba);
202 202
203 return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); 203 return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp);
204} 204}
205 205
206paddr_t 206paddr_t
207bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 207bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
208{ 208{
209 const paddr_t pa = bcm2835_bus_to_phys(ba); 209 const paddr_t pa = bcm2835_bus_to_phys(ba);
210 210
211 return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); 211 return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags);
212} 212}
213 213
214paddr_t 214paddr_t
215bcm2835_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 215bcm2835_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
216{ 216{
217 217
218 return bcm2835_bs_mmap(t, ba, 4 * offset, prot, flags); 218 return bcm2835_bs_mmap(t, ba, 4 * offset, prot, flags);
219} 219}
220 220
221int 221int
222bcm2836_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, 222bcm2836_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
223 bus_space_handle_t *bshp) 223 bus_space_handle_t *bshp)
224{ 224{
225 const paddr_t pa = bcm2836_bus_to_phys(ba); 225 const paddr_t pa = bcm2836_bus_to_phys(ba);
226 226
227 return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); 227 return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp);
228} 228}
229 229
230paddr_t 230paddr_t
231bcm2836_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 231bcm2836_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
232{ 232{
233 const paddr_t pa = bcm2836_bus_to_phys(ba); 233 const paddr_t pa = bcm2836_bus_to_phys(ba);
234 234
235 return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); 235 return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags);
236} 236}
237 237
238paddr_t 238paddr_t
239bcm2836_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 239bcm2836_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
240{ 240{
241 241
242 return bcm2836_bs_mmap(t, ba, 4 * offset, prot, flags); 242 return bcm2836_bs_mmap(t, ba, 4 * offset, prot, flags);
243} 243}
244 244
245int 245int
246bcm2711_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, 246bcm2711_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
247 bus_space_handle_t *bshp) 247 bus_space_handle_t *bshp)
248{ 248{
249 const paddr_t pa = bcm2711_bus_to_phys(ba); 249 const paddr_t pa = bcm2711_bus_to_phys(ba);
250 250
251 return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); 251 return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp);
252} 252}
253 253
254paddr_t 254paddr_t
255bcm2711_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 255bcm2711_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
256{ 256{
257 const paddr_t pa = bcm2711_bus_to_phys(ba); 257 const paddr_t pa = bcm2711_bus_to_phys(ba);
258 258
259 return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); 259 return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags);
260} 260}
261 261
262paddr_t 262paddr_t
263bcm2711_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 263bcm2711_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
264{ 264{
265 265
266 return bcm2711_bs_mmap(t, ba, 4 * offset, prot, flags); 266 return bcm2711_bs_mmap(t, ba, 4 * offset, prot, flags);
267} 267}
268 268
269struct arm32_dma_range bcm2835_dma_ranges[] = { 269struct arm32_dma_range bcm2835_dma_ranges[] = {
270 [0] = { 270 [0] = {
271 .dr_sysbase = 0, 271 .dr_sysbase = 0,
272 .dr_busbase = BCM2835_BUSADDR_CACHE_COHERENT, 272 .dr_busbase = BCM2835_BUSADDR_CACHE_COHERENT,
273 } 273 }
274}; 274};
275 275
276struct arm32_dma_range bcm2836_dma_ranges[] = { 276struct arm32_dma_range bcm2836_dma_ranges[] = {
277 [0] = { 277 [0] = {
278 .dr_sysbase = 0, 278 .dr_sysbase = 0,
279 .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT, 279 .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT,
280 } 280 }
281}; 281};
282 282
283struct arm32_dma_range bcm2711_dma_ranges[] = { 283struct arm32_dma_range bcm2711_dma_ranges[] = {
284 [0] = { 284 [0] = {
285 .dr_sysbase = 0, 285 .dr_sysbase = 0,
286 .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT, 286 .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT,
287 } 287 }
288}; 288};
289 289
290 290
291#if defined(SOC_BCM2835) 291#if defined(SOC_BCM2835)
292static const struct pmap_devmap * 292static const struct pmap_devmap *
293bcm2835_platform_devmap(void) 293bcm2835_platform_devmap(void)
294{ 294{
295 static const struct pmap_devmap devmap[] = { 295 static const struct pmap_devmap devmap[] = {
296 DEVMAP_ENTRY(BCM2835_PERIPHERALS_VBASE, BCM2835_PERIPHERALS_BASE, 296 DEVMAP_ENTRY(BCM2835_PERIPHERALS_VBASE, BCM2835_PERIPHERALS_BASE,
297 BCM283X_PERIPHERALS_SIZE), /* 16Mb */ 297 BCM283X_PERIPHERALS_SIZE), /* 16Mb */
298 298
299 DEVMAP_ENTRY_END 299 DEVMAP_ENTRY_END
300 }; 300 };
301 301
302 return devmap; 302 return devmap;
303} 303}
304#endif 304#endif
305 305
306#if defined(SOC_BCM2836) 306#if defined(SOC_BCM2836)
307static const struct pmap_devmap * 307static const struct pmap_devmap *
308bcm2836_platform_devmap(void) 308bcm2836_platform_devmap(void)
309{ 309{
310 static const struct pmap_devmap devmap[] = { 310 static const struct pmap_devmap devmap[] = {
311 DEVMAP_ENTRY(BCM2836_PERIPHERALS_VBASE, BCM2836_PERIPHERALS_BASE, 311 DEVMAP_ENTRY(BCM2836_PERIPHERALS_VBASE, BCM2836_PERIPHERALS_BASE,
312 BCM283X_PERIPHERALS_SIZE), /* 16Mb */ 312 BCM283X_PERIPHERALS_SIZE), /* 16Mb */
313 DEVMAP_ENTRY(BCM2836_ARM_LOCAL_VBASE, BCM2836_ARM_LOCAL_BASE, 313 DEVMAP_ENTRY(BCM2836_ARM_LOCAL_VBASE, BCM2836_ARM_LOCAL_BASE,
314 BCM2836_ARM_LOCAL_SIZE), 314 BCM2836_ARM_LOCAL_SIZE),
315#if defined(MULTIPROCESSOR) && defined(__aarch64__) 315#if defined(MULTIPROCESSOR) && defined(__aarch64__)
316 /* for fdt cpu spin-table */ 316 /* for fdt cpu spin-table */
317 DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE, 317 DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE,
318 BCM2836_ARM_SMP_SIZE), 318 BCM2836_ARM_SMP_SIZE),
319#endif 319#endif
320 DEVMAP_ENTRY_END 320 DEVMAP_ENTRY_END
321 }; 321 };
322 322
323 return devmap; 323 return devmap;
324} 324}
325 325
326static const struct pmap_devmap * 326static const struct pmap_devmap *
327bcm2711_platform_devmap(void) 327bcm2711_platform_devmap(void)
328{ 328{
329 static const struct pmap_devmap devmap[] = { 329 static const struct pmap_devmap devmap[] = {
330 DEVMAP_ENTRY(BCM2711_PERIPHERALS_VBASE, BCM2711_PERIPHERALS_BASE, 330 DEVMAP_ENTRY(BCM2711_PERIPHERALS_VBASE, BCM2711_PERIPHERALS_BASE,
331 BCM283X_PERIPHERALS_SIZE), /* 16Mb */ 331 BCM283X_PERIPHERALS_SIZE), /* 16Mb */
332 DEVMAP_ENTRY(BCM2711_ARM_LOCAL_VBASE, BCM2711_ARM_LOCAL_BASE, 332 DEVMAP_ENTRY(BCM2711_ARM_LOCAL_VBASE, BCM2711_ARM_LOCAL_BASE,
333 BCM2711_ARM_LOCAL_SIZE), 333 BCM2711_ARM_LOCAL_SIZE),
334#if defined(MULTIPROCESSOR) && defined(__aarch64__) 334#if defined(MULTIPROCESSOR) && defined(__aarch64__)
335 /* for fdt cpu spin-table */ 335 /* for fdt cpu spin-table */
336 DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE, 336 DEVMAP_ENTRY(BCM2711_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE,
337 BCM2836_ARM_SMP_SIZE), 337 BCM2836_ARM_SMP_SIZE),
338#endif 338#endif
339 DEVMAP_ENTRY_END 339 DEVMAP_ENTRY_END
340 }; 340 };
341 341
342 return devmap; 342 return devmap;
343} 343}
344#endif 344#endif
345 345
346/* 346/*
347 * Macros to translate between physical and virtual for a subset of the 347 * Macros to translate between physical and virtual for a subset of the
348 * kernel address space. *Not* for general use. 348 * kernel address space. *Not* for general use.
349 */ 349 */
350 350
351#ifndef RPI_FB_WIDTH 351#ifndef RPI_FB_WIDTH
352#define RPI_FB_WIDTH 1280 352#define RPI_FB_WIDTH 1280
353#endif 353#endif
354#ifndef RPI_FB_HEIGHT 354#ifndef RPI_FB_HEIGHT
355#define RPI_FB_HEIGHT 720 355#define RPI_FB_HEIGHT 720
356#endif 356#endif
357 357
358int uart_clk = BCM2835_UART0_CLK; 358int uart_clk = BCM2835_UART0_CLK;
359int core_clk; 359int core_clk;
360 360
361static struct { 361static struct {
362 struct vcprop_buffer_hdr vb_hdr; 362 struct vcprop_buffer_hdr vb_hdr;
363 struct vcprop_tag_clockrate vbt_uartclockrate; 363 struct vcprop_tag_clockrate vbt_uartclockrate;
364 struct vcprop_tag_clockrate vbt_vpuclockrate; 364 struct vcprop_tag_clockrate vbt_vpuclockrate;
365 struct vcprop_tag end; 365 struct vcprop_tag end;
366} vb_uart __cacheline_aligned = { 366} vb_uart __cacheline_aligned = {
367 .vb_hdr = { 367 .vb_hdr = {
368 .vpb_len = sizeof(vb_uart), 368 .vpb_len = sizeof(vb_uart),
369 .vpb_rcode = VCPROP_PROCESS_REQUEST, 369 .vpb_rcode = VCPROP_PROCESS_REQUEST,
370 }, 370 },
371 .vbt_uartclockrate = { 371 .vbt_uartclockrate = {
372 .tag = { 372 .tag = {
373 .vpt_tag = VCPROPTAG_GET_CLOCKRATE, 373 .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
374 .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_uartclockrate), 374 .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_uartclockrate),
375 .vpt_rcode = VCPROPTAG_REQUEST 375 .vpt_rcode = VCPROPTAG_REQUEST
376 }, 376 },
377 .id = VCPROP_CLK_UART 377 .id = VCPROP_CLK_UART
378 }, 378 },
379 .vbt_vpuclockrate = { 379 .vbt_vpuclockrate = {
380 .tag = { 380 .tag = {
381 .vpt_tag = VCPROPTAG_GET_CLOCKRATE, 381 .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
382 .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_vpuclockrate), 382 .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_vpuclockrate),
383 .vpt_rcode = VCPROPTAG_REQUEST 383 .vpt_rcode = VCPROPTAG_REQUEST
384 }, 384 },
385 .id = VCPROP_CLK_CORE 385 .id = VCPROP_CLK_CORE
386 }, 386 },
387 .end = { 387 .end = {
388 .vpt_tag = VCPROPTAG_NULL 388 .vpt_tag = VCPROPTAG_NULL
389 } 389 }
390}; 390};
391 391
392static struct { 392static struct {
393 struct vcprop_buffer_hdr vb_hdr; 393 struct vcprop_buffer_hdr vb_hdr;
394 struct vcprop_tag_fwrev vbt_fwrev; 394 struct vcprop_tag_fwrev vbt_fwrev;
395 struct vcprop_tag_boardmodel vbt_boardmodel; 395 struct vcprop_tag_boardmodel vbt_boardmodel;
396 struct vcprop_tag_boardrev vbt_boardrev; 396 struct vcprop_tag_boardrev vbt_boardrev;
397 struct vcprop_tag_macaddr vbt_macaddr; 397 struct vcprop_tag_macaddr vbt_macaddr;
398 struct vcprop_tag_memory vbt_memory; 398 struct vcprop_tag_memory vbt_memory;
399 struct vcprop_tag_boardserial vbt_serial; 399 struct vcprop_tag_boardserial vbt_serial;
400 struct vcprop_tag_dmachan vbt_dmachan; 400 struct vcprop_tag_dmachan vbt_dmachan;
401 struct vcprop_tag_cmdline vbt_cmdline; 401 struct vcprop_tag_cmdline vbt_cmdline;
402 struct vcprop_tag_clockrate vbt_emmcclockrate; 402 struct vcprop_tag_clockrate vbt_emmcclockrate;
403 struct vcprop_tag_clockrate vbt_armclockrate; 403 struct vcprop_tag_clockrate vbt_armclockrate;
404 struct vcprop_tag_clockrate vbt_vpuclockrate; 404 struct vcprop_tag_clockrate vbt_vpuclockrate;
405 struct vcprop_tag_clockrate vbt_emmc2clockrate; 405 struct vcprop_tag_clockrate vbt_emmc2clockrate;
406 struct vcprop_tag end; 406 struct vcprop_tag end;
407} vb __cacheline_aligned = { 407} vb __cacheline_aligned = {
408 .vb_hdr = { 408 .vb_hdr = {
409 .vpb_len = sizeof(vb), 409 .vpb_len = sizeof(vb),
410 .vpb_rcode = VCPROP_PROCESS_REQUEST, 410 .vpb_rcode = VCPROP_PROCESS_REQUEST,
411 }, 411 },
412 .vbt_fwrev = { 412 .vbt_fwrev = {
413 .tag = { 413 .tag = {
414 .vpt_tag = VCPROPTAG_GET_FIRMWAREREV, 414 .vpt_tag = VCPROPTAG_GET_FIRMWAREREV,
415 .vpt_len = VCPROPTAG_LEN(vb.vbt_fwrev), 415 .vpt_len = VCPROPTAG_LEN(vb.vbt_fwrev),
416 .vpt_rcode = VCPROPTAG_REQUEST 416 .vpt_rcode = VCPROPTAG_REQUEST
417 }, 417 },
418 }, 418 },
419 .vbt_boardmodel = { 419 .vbt_boardmodel = {
420 .tag = { 420 .tag = {
421 .vpt_tag = VCPROPTAG_GET_BOARDMODEL, 421 .vpt_tag = VCPROPTAG_GET_BOARDMODEL,
422 .vpt_len = VCPROPTAG_LEN(vb.vbt_boardmodel), 422 .vpt_len = VCPROPTAG_LEN(vb.vbt_boardmodel),
423 .vpt_rcode = VCPROPTAG_REQUEST 423 .vpt_rcode = VCPROPTAG_REQUEST
424 }, 424 },
425 }, 425 },
426 .vbt_boardrev = { 426 .vbt_boardrev = {
427 .tag = { 427 .tag = {
428 .vpt_tag = VCPROPTAG_GET_BOARDREVISION, 428 .vpt_tag = VCPROPTAG_GET_BOARDREVISION,
429 .vpt_len = VCPROPTAG_LEN(vb.vbt_boardrev), 429 .vpt_len = VCPROPTAG_LEN(vb.vbt_boardrev),
430 .vpt_rcode = VCPROPTAG_REQUEST 430 .vpt_rcode = VCPROPTAG_REQUEST
431 }, 431 },
432 }, 432 },
433 .vbt_macaddr = { 433 .vbt_macaddr = {
434 .tag = { 434 .tag = {
435 .vpt_tag = VCPROPTAG_GET_MACADDRESS, 435 .vpt_tag = VCPROPTAG_GET_MACADDRESS,
436 .vpt_len = VCPROPTAG_LEN(vb.vbt_macaddr), 436 .vpt_len = VCPROPTAG_LEN(vb.vbt_macaddr),
437 .vpt_rcode = VCPROPTAG_REQUEST 437 .vpt_rcode = VCPROPTAG_REQUEST
438 }, 438 },
439 }, 439 },
440 .vbt_memory = { 440 .vbt_memory = {
441 .tag = { 441 .tag = {
442 .vpt_tag = VCPROPTAG_GET_ARMMEMORY, 442 .vpt_tag = VCPROPTAG_GET_ARMMEMORY,
443 .vpt_len = VCPROPTAG_LEN(vb.vbt_memory), 443 .vpt_len = VCPROPTAG_LEN(vb.vbt_memory),
444 .vpt_rcode = VCPROPTAG_REQUEST 444 .vpt_rcode = VCPROPTAG_REQUEST
445 }, 445 },
446 }, 446 },
447 .vbt_serial = { 447 .vbt_serial = {
448 .tag = { 448 .tag = {
449 .vpt_tag = VCPROPTAG_GET_BOARDSERIAL, 449 .vpt_tag = VCPROPTAG_GET_BOARDSERIAL,
450 .vpt_len = VCPROPTAG_LEN(vb.vbt_serial), 450 .vpt_len = VCPROPTAG_LEN(vb.vbt_serial),
451 .vpt_rcode = VCPROPTAG_REQUEST 451 .vpt_rcode = VCPROPTAG_REQUEST
452 }, 452 },
453 }, 453 },
454 .vbt_dmachan = { 454 .vbt_dmachan = {
455 .tag = { 455 .tag = {
456 .vpt_tag = VCPROPTAG_GET_DMACHAN, 456 .vpt_tag = VCPROPTAG_GET_DMACHAN,
457 .vpt_len = VCPROPTAG_LEN(vb.vbt_dmachan), 457 .vpt_len = VCPROPTAG_LEN(vb.vbt_dmachan),
458 .vpt_rcode = VCPROPTAG_REQUEST 458 .vpt_rcode = VCPROPTAG_REQUEST
459 }, 459 },
460 }, 460 },
461 .vbt_cmdline = { 461 .vbt_cmdline = {
462 .tag = { 462 .tag = {
463 .vpt_tag = VCPROPTAG_GET_CMDLINE, 463 .vpt_tag = VCPROPTAG_GET_CMDLINE,
464 .vpt_len = VCPROPTAG_LEN(vb.vbt_cmdline), 464 .vpt_len = VCPROPTAG_LEN(vb.vbt_cmdline),
465 .vpt_rcode = VCPROPTAG_REQUEST 465 .vpt_rcode = VCPROPTAG_REQUEST
466 }, 466 },
467 }, 467 },
468 .vbt_emmcclockrate = { 468 .vbt_emmcclockrate = {
469 .tag = { 469 .tag = {
470 .vpt_tag = VCPROPTAG_GET_CLOCKRATE, 470 .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
471 .vpt_len = VCPROPTAG_LEN(vb.vbt_emmcclockrate), 471 .vpt_len = VCPROPTAG_LEN(vb.vbt_emmcclockrate),
472 .vpt_rcode = VCPROPTAG_REQUEST 472 .vpt_rcode = VCPROPTAG_REQUEST
473 }, 473 },
474 .id = VCPROP_CLK_EMMC 474 .id = VCPROP_CLK_EMMC
475 }, 475 },
476 .vbt_armclockrate = { 476 .vbt_armclockrate = {
477 .tag = { 477 .tag = {
478 .vpt_tag = VCPROPTAG_GET_CLOCKRATE, 478 .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
479 .vpt_len = VCPROPTAG_LEN(vb.vbt_armclockrate), 479 .vpt_len = VCPROPTAG_LEN(vb.vbt_armclockrate),
480 .vpt_rcode = VCPROPTAG_REQUEST 480 .vpt_rcode = VCPROPTAG_REQUEST
481 }, 481 },
482 .id = VCPROP_CLK_ARM 482 .id = VCPROP_CLK_ARM
483 }, 483 },
484 .vbt_vpuclockrate = { 484 .vbt_vpuclockrate = {
485 .tag = { 485 .tag = {
486 .vpt_tag = VCPROPTAG_GET_CLOCKRATE, 486 .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
487 .vpt_len = VCPROPTAG_LEN(vb.vbt_vpuclockrate), 487 .vpt_len = VCPROPTAG_LEN(vb.vbt_vpuclockrate),
488 .vpt_rcode = VCPROPTAG_REQUEST 488 .vpt_rcode = VCPROPTAG_REQUEST
489 }, 489 },
490 .id = VCPROP_CLK_CORE 490 .id = VCPROP_CLK_CORE
491 }, 491 },
492 .vbt_emmc2clockrate = { 492 .vbt_emmc2clockrate = {
493 .tag = { 493 .tag = {
494 .vpt_tag = VCPROPTAG_GET_CLOCKRATE, 494 .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
495 .vpt_len = VCPROPTAG_LEN(vb.vbt_emmc2clockrate), 495 .vpt_len = VCPROPTAG_LEN(vb.vbt_emmc2clockrate),
496 .vpt_rcode = VCPROPTAG_REQUEST 496 .vpt_rcode = VCPROPTAG_REQUEST
497 }, 497 },
498 .id = VCPROP_CLK_EMMC2 498 .id = VCPROP_CLK_EMMC2
499 }, 499 },
500 .end = { 500 .end = {
501 .vpt_tag = VCPROPTAG_NULL 501 .vpt_tag = VCPROPTAG_NULL
502 } 502 }
503}; 503};
504 504
505#if NGENFB > 0 505#if NGENFB > 0
506static struct { 506static struct {
507 struct vcprop_buffer_hdr vb_hdr; 507 struct vcprop_buffer_hdr vb_hdr;
508 struct vcprop_tag_edidblock vbt_edid; 508 struct vcprop_tag_edidblock vbt_edid;
509 struct vcprop_tag end; 509 struct vcprop_tag end;
510} vb_edid __cacheline_aligned = { 510} vb_edid __cacheline_aligned = {
511 .vb_hdr = { 511 .vb_hdr = {
512 .vpb_len = sizeof(vb_edid), 512 .vpb_len = sizeof(vb_edid),
513 .vpb_rcode = VCPROP_PROCESS_REQUEST, 513 .vpb_rcode = VCPROP_PROCESS_REQUEST,
514 }, 514 },
515 .vbt_edid = { 515 .vbt_edid = {
516 .tag = { 516 .tag = {
517 .vpt_tag = VCPROPTAG_GET_EDID_BLOCK, 517 .vpt_tag = VCPROPTAG_GET_EDID_BLOCK,
518 .vpt_len = VCPROPTAG_LEN(vb_edid.vbt_edid), 518 .vpt_len = VCPROPTAG_LEN(vb_edid.vbt_edid),
519 .vpt_rcode = VCPROPTAG_REQUEST, 519 .vpt_rcode = VCPROPTAG_REQUEST,
520 }, 520 },
521 .blockno = 0, 521 .blockno = 0,
522 }, 522 },
523 .end = { 523 .end = {
524 .vpt_tag = VCPROPTAG_NULL 524 .vpt_tag = VCPROPTAG_NULL
525 } 525 }
526}; 526};
527 527
528static struct { 528static struct {
529 struct vcprop_buffer_hdr vb_hdr; 529 struct vcprop_buffer_hdr vb_hdr;
530 struct vcprop_tag_fbres vbt_res; 530 struct vcprop_tag_fbres vbt_res;
531 struct vcprop_tag_fbres vbt_vres; 531 struct vcprop_tag_fbres vbt_vres;
532 struct vcprop_tag_fbdepth vbt_depth; 532 struct vcprop_tag_fbdepth vbt_depth;
533 struct vcprop_tag_fbalpha vbt_alpha; 533 struct vcprop_tag_fbalpha vbt_alpha;
534 struct vcprop_tag_allocbuf vbt_allocbuf; 534 struct vcprop_tag_allocbuf vbt_allocbuf;
535 struct vcprop_tag_blankscreen vbt_blank; 535 struct vcprop_tag_blankscreen vbt_blank;
536 struct vcprop_tag_fbpitch vbt_pitch; 536 struct vcprop_tag_fbpitch vbt_pitch;
537 struct vcprop_tag end; 537 struct vcprop_tag end;
538} vb_setfb __cacheline_aligned = { 538} vb_setfb __cacheline_aligned = {
539 .vb_hdr = { 539 .vb_hdr = {
540 .vpb_len = sizeof(vb_setfb), 540 .vpb_len = sizeof(vb_setfb),
541 .vpb_rcode = VCPROP_PROCESS_REQUEST, 541 .vpb_rcode = VCPROP_PROCESS_REQUEST,
542 }, 542 },
543 .vbt_res = { 543 .vbt_res = {
544 .tag = { 544 .tag = {
545 .vpt_tag = VCPROPTAG_SET_FB_RES, 545 .vpt_tag = VCPROPTAG_SET_FB_RES,
546 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_res), 546 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_res),
547 .vpt_rcode = VCPROPTAG_REQUEST, 547 .vpt_rcode = VCPROPTAG_REQUEST,
548 }, 548 },
549 .width = 0, 549 .width = 0,
550 .height = 0, 550 .height = 0,
551 }, 551 },
552 .vbt_vres = { 552 .vbt_vres = {
553 .tag = { 553 .tag = {
554 .vpt_tag = VCPROPTAG_SET_FB_VRES, 554 .vpt_tag = VCPROPTAG_SET_FB_VRES,
555 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_vres), 555 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_vres),
556 .vpt_rcode = VCPROPTAG_REQUEST, 556 .vpt_rcode = VCPROPTAG_REQUEST,
557 }, 557 },
558 .width = 0, 558 .width = 0,
559 .height = 0, 559 .height = 0,
560 }, 560 },
561 .vbt_depth = { 561 .vbt_depth = {
562 .tag = { 562 .tag = {
563 .vpt_tag = VCPROPTAG_SET_FB_DEPTH, 563 .vpt_tag = VCPROPTAG_SET_FB_DEPTH,
564 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_depth), 564 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_depth),
565 .vpt_rcode = VCPROPTAG_REQUEST, 565 .vpt_rcode = VCPROPTAG_REQUEST,
566 }, 566 },
567 .bpp = 32, 567 .bpp = 32,
568 }, 568 },
569 .vbt_alpha = { 569 .vbt_alpha = {
570 .tag = { 570 .tag = {
571 .vpt_tag = VCPROPTAG_SET_FB_ALPHA_MODE, 571 .vpt_tag = VCPROPTAG_SET_FB_ALPHA_MODE,
572 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_alpha), 572 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_alpha),
573 .vpt_rcode = VCPROPTAG_REQUEST, 573 .vpt_rcode = VCPROPTAG_REQUEST,
574 }, 574 },
575 .state = VCPROP_ALPHA_IGNORED, 575 .state = VCPROP_ALPHA_IGNORED,
576 }, 576 },
577 .vbt_allocbuf = { 577 .vbt_allocbuf = {
578 .tag = { 578 .tag = {
579 .vpt_tag = VCPROPTAG_ALLOCATE_BUFFER, 579 .vpt_tag = VCPROPTAG_ALLOCATE_BUFFER,
580 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_allocbuf), 580 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_allocbuf),
581 .vpt_rcode = VCPROPTAG_REQUEST, 581 .vpt_rcode = VCPROPTAG_REQUEST,
582 }, 582 },
583 .address = PAGE_SIZE, /* alignment */ 583 .address = PAGE_SIZE, /* alignment */
584 }, 584 },
585 .vbt_blank = { 585 .vbt_blank = {
586 .tag = { 586 .tag = {
587 .vpt_tag = VCPROPTAG_BLANK_SCREEN, 587 .vpt_tag = VCPROPTAG_BLANK_SCREEN,
588 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_blank), 588 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_blank),
589 .vpt_rcode = VCPROPTAG_REQUEST, 589 .vpt_rcode = VCPROPTAG_REQUEST,
590 }, 590 },
591 .state = VCPROP_BLANK_OFF, 591 .state = VCPROP_BLANK_OFF,
592 }, 592 },
593 .vbt_pitch = { 593 .vbt_pitch = {
594 .tag = { 594 .tag = {
595 .vpt_tag = VCPROPTAG_GET_FB_PITCH, 595 .vpt_tag = VCPROPTAG_GET_FB_PITCH,
596 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_pitch), 596 .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_pitch),
597 .vpt_rcode = VCPROPTAG_REQUEST, 597 .vpt_rcode = VCPROPTAG_REQUEST,
598 }, 598 },
599 }, 599 },
600 .end = { 600 .end = {
601 .vpt_tag = VCPROPTAG_NULL, 601 .vpt_tag = VCPROPTAG_NULL,
602 }, 602 },
603}; 603};
604 604
605#endif 605#endif
606 606
607static int rpi_video_on = WSDISPLAYIO_VIDEO_ON; 607static int rpi_video_on = WSDISPLAYIO_VIDEO_ON;
608 608
609#if defined(RPI_HWCURSOR) 609#if defined(RPI_HWCURSOR)
610#define CURSOR_BITMAP_SIZE (64 * 8) 610#define CURSOR_BITMAP_SIZE (64 * 8)
611#define CURSOR_ARGB_SIZE (64 * 64 * 4) 611#define CURSOR_ARGB_SIZE (64 * 64 * 4)
612static uint32_t hcursor = 0; 612static uint32_t hcursor = 0;
613static bus_addr_t pcursor = 0; 613static bus_addr_t pcursor = 0;
614static uint32_t *cmem = NULL; 614static uint32_t *cmem = NULL;
615static int cursor_x = 0, cursor_y = 0, hot_x = 0, hot_y = 0, cursor_on = 0; 615static int cursor_x = 0, cursor_y = 0, hot_x = 0, hot_y = 0, cursor_on = 0;
616static uint32_t cursor_cmap[4]; 616static uint32_t cursor_cmap[4];
617static uint8_t cursor_mask[8 * 64], cursor_bitmap[8 * 64]; 617static uint8_t cursor_mask[8 * 64], cursor_bitmap[8 * 64];
618#endif 618#endif
619 619
620u_int 620u_int
621bcm283x_clk_get_rate_uart(void) 621bcm283x_clk_get_rate_uart(void)
622{ 622{
623 623
624 if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) 624 if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag))
625 return vb_uart.vbt_uartclockrate.rate; 625 return vb_uart.vbt_uartclockrate.rate;
626 return 0; 626 return 0;
627} 627}
628 628
629u_int 629u_int
630bcm283x_clk_get_rate_vpu(void) 630bcm283x_clk_get_rate_vpu(void)
631{ 631{
632 632
633 if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag) && 633 if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag) &&
634 vb.vbt_vpuclockrate.rate > 0) { 634 vb.vbt_vpuclockrate.rate > 0) {
635 return vb.vbt_vpuclockrate.rate; 635 return vb.vbt_vpuclockrate.rate;
636 } 636 }
637 return 0; 637 return 0;
638} 638}
639 639
640u_int 640u_int
641bcm283x_clk_get_rate_emmc(void) 641bcm283x_clk_get_rate_emmc(void)
642{ 642{
643 643
644 if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag) && 644 if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag) &&
645 vb.vbt_emmcclockrate.rate > 0) { 645 vb.vbt_emmcclockrate.rate > 0) {
646 return vb.vbt_emmcclockrate.rate; 646 return vb.vbt_emmcclockrate.rate;
647 } 647 }
648 return 0; 648 return 0;
649} 649}
650 650
651u_int 651u_int
652bcm283x_clk_get_rate_emmc2(void) 652bcm283x_clk_get_rate_emmc2(void)
653{ 653{
654 654
655 if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag) && 655 if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag) &&
656 vb.vbt_emmc2clockrate.rate > 0) { 656 vb.vbt_emmc2clockrate.rate > 0) {
657 return vb.vbt_emmc2clockrate.rate; 657 return vb.vbt_emmc2clockrate.rate;
658 } 658 }
659 return 0; 659 return 0;
660} 660}
661 661
662 662
663 663
664static void 664static void
665bcm283x_uartinit(bus_space_tag_t iot, bus_space_handle_t ioh) 665bcm283x_uartinit(bus_space_tag_t iot, bus_space_handle_t ioh)
666{ 666{
667 uint32_t res; 667 uint32_t res;
668 668
669 bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, 669 bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC,
670 KERN_VTOPHYS((vaddr_t)&vb_uart)); 670 KERN_VTOPHYS((vaddr_t)&vb_uart));
671 671
672 bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); 672 bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res);
673 673
674 if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) 674 if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag))
675 uart_clk = vb_uart.vbt_uartclockrate.rate; 675 uart_clk = vb_uart.vbt_uartclockrate.rate;
676 if (vcprop_tag_success_p(&vb_uart.vbt_vpuclockrate.tag)) 676 if (vcprop_tag_success_p(&vb_uart.vbt_vpuclockrate.tag))
677 core_clk = vb_uart.vbt_vpuclockrate.rate; 677 core_clk = vb_uart.vbt_vpuclockrate.rate;
678} 678}
679 679
680#if defined(SOC_BCM2835) 680#if defined(SOC_BCM2835)
681static void 681static void
682bcm2835_uartinit(void) 682bcm2835_uartinit(void)
683{ 683{
684 const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); 684 const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
685 const bus_space_tag_t iot = &bcm2835_bs_tag; 685 const bus_space_tag_t iot = &bcm2835_bs_tag;
686 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); 686 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa);
687 687
688 bcm283x_uartinit(iot, ioh); 688 bcm283x_uartinit(iot, ioh);
689} 689}
690#endif 690#endif
691 691
692#if defined(SOC_BCM2836) 692#if defined(SOC_BCM2836)
693static void 693static void
694bcm2836_uartinit(void) 694bcm2836_uartinit(void)
695{ 695{
696 const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); 696 const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
697 const bus_space_tag_t iot = &bcm2836_bs_tag; 697 const bus_space_tag_t iot = &bcm2836_bs_tag;
698 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); 698 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa);
699 699
700 bcm283x_uartinit(iot, ioh); 700 bcm283x_uartinit(iot, ioh);
701} 701}
702 702
703static void 703static void
704bcm2711_uartinit(void) 704bcm2711_uartinit(void)
705{ 705{
706 const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); 706 const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
707 const bus_space_tag_t iot = &bcm2711_bs_tag; 707 const bus_space_tag_t iot = &bcm2711_bs_tag;
708 const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa); 708 const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa);
709 709
710 bcm283x_uartinit(iot, ioh); 710 bcm283x_uartinit(iot, ioh);
711} 711}
712#endif 712#endif
713 713
714#define BCM283x_MINIMUM_SPLIT (128U * 1024 * 1024) 714#define BCM283x_MINIMUM_SPLIT (128U * 1024 * 1024)
715 715
716static size_t bcm283x_memorysize; 716static size_t bcm283x_memorysize;
717 717
718static void 718static void
719bcm283x_bootparams(bus_space_tag_t iot, bus_space_handle_t ioh) 719bcm283x_bootparams(bus_space_tag_t iot, bus_space_handle_t ioh)
720{ 720{
721 uint32_t res; 721 uint32_t res;
722 722
723 bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANPM, ( 723 bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANPM, (
724#if (NSDHC > 0) 724#if (NSDHC > 0)
725 (1 << VCPM_POWER_SDCARD) | 725 (1 << VCPM_POWER_SDCARD) |
726#endif 726#endif
727#if (NPLCOM > 0) 727#if (NPLCOM > 0)
728 (1 << VCPM_POWER_UART0) | 728 (1 << VCPM_POWER_UART0) |
729#endif 729#endif
730#if (NBCMDWCTWO > 0) 730#if (NBCMDWCTWO > 0)
731 (1 << VCPM_POWER_USB) | 731 (1 << VCPM_POWER_USB) |
732#endif 732#endif
733#if (NBSCIIC > 0) 733#if (NBSCIIC > 0)
734 (1 << VCPM_POWER_I2C0) | (1 << VCPM_POWER_I2C1) | 734 (1 << VCPM_POWER_I2C0) | (1 << VCPM_POWER_I2C1) |
735 /* (1 << VCPM_POWER_I2C2) | */ 735 /* (1 << VCPM_POWER_I2C2) | */
736#endif 736#endif
737#if (NBCMSPI > 0) 737#if (NBCMSPI > 0)
738 (1 << VCPM_POWER_SPI) | 738 (1 << VCPM_POWER_SPI) |
739#endif 739#endif
740 0) << 4); 740 0) << 4);
741 741
742 bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, 742 bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC,
743 KERN_VTOPHYS((vaddr_t)&vb)); 743 KERN_VTOPHYS((vaddr_t)&vb));
744 744
745 bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); 745 bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res);
746 746
747 /* 747 /*
748 * RPI4 has Cortex A72 processors which do speculation, so 748 * RPI4 has Cortex A72 processors which do speculation, so
749 * we need to invalidate the cache for an updates done by 749 * we need to invalidate the cache for an updates done by
750 * the firmware 750 * the firmware
751 */ 751 */
752 cpu_dcache_inv_range((vaddr_t)&vb, sizeof(vb)); 752 cpu_dcache_inv_range((vaddr_t)&vb, sizeof(vb));
753 753
754 if (!vcprop_buffer_success_p(&vb.vb_hdr)) { 754 if (!vcprop_buffer_success_p(&vb.vb_hdr)) {
755 bootconfig.dramblocks = 1; 755 bootconfig.dramblocks = 1;
756 bootconfig.dram[0].address = 0x0; 756 bootconfig.dram[0].address = 0x0;
757 bootconfig.dram[0].pages = atop(BCM283x_MINIMUM_SPLIT); 757 bootconfig.dram[0].pages = atop(BCM283x_MINIMUM_SPLIT);
758 return; 758 return;
759 } 759 }
760 760
761 struct vcprop_tag_memory *vptp_mem = &vb.vbt_memory; 761 struct vcprop_tag_memory *vptp_mem = &vb.vbt_memory;
762 if (vcprop_tag_success_p(&vptp_mem->tag)) { 762 if (vcprop_tag_success_p(&vptp_mem->tag)) {
763 size_t n = vcprop_tag_resplen(&vptp_mem->tag) / 763 size_t n = vcprop_tag_resplen(&vptp_mem->tag) /
764 sizeof(struct vcprop_memory); 764 sizeof(struct vcprop_memory);
765 765
766 bcm283x_memorysize = 0; 766 bcm283x_memorysize = 0;
767 bootconfig.dramblocks = 0; 767 bootconfig.dramblocks = 0;
768 768
769 for (int i = 0; i < n && i < DRAM_BLOCKS; i++) { 769 for (int i = 0; i < n && i < DRAM_BLOCKS; i++) {
770 bootconfig.dram[i].address = vptp_mem->mem[i].base; 770 bootconfig.dram[i].address = vptp_mem->mem[i].base;
771 bootconfig.dram[i].pages = atop(vptp_mem->mem[i].size); 771 bootconfig.dram[i].pages = atop(vptp_mem->mem[i].size);
772 bootconfig.dramblocks++; 772 bootconfig.dramblocks++;
773 773
774 bcm283x_memorysize += vptp_mem->mem[i].size; 774 bcm283x_memorysize += vptp_mem->mem[i].size;
775 } 775 }
776 } 776 }
777 777
778 if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) 778 if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag))
779 curcpu()->ci_data.cpu_cc_freq = vb.vbt_armclockrate.rate; 779 curcpu()->ci_data.cpu_cc_freq = vb.vbt_armclockrate.rate;
780 780
781#ifdef VERBOSE_INIT_ARM 781#ifdef VERBOSE_INIT_ARM
782 if (vcprop_tag_success_p(&vb.vbt_memory.tag)) 782 if (vcprop_tag_success_p(&vb.vbt_memory.tag))
783 printf("%s: memory size %zu\n", __func__, 783 printf("%s: memory size %zu\n", __func__,
784 bcm283x_memorysize); 784 bcm283x_memorysize);
785 if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) 785 if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag))
786 printf("%s: arm clock %d\n", __func__, 786 printf("%s: arm clock %d\n", __func__,
787 vb.vbt_armclockrate.rate); 787 vb.vbt_armclockrate.rate);
788 if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag)) 788 if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag))
789 printf("%s: vpu clock %d\n", __func__, 789 printf("%s: vpu clock %d\n", __func__,
790 vb.vbt_vpuclockrate.rate); 790 vb.vbt_vpuclockrate.rate);
791 if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag)) 791 if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag))
792 printf("%s: emmc clock %d\n", __func__, 792 printf("%s: emmc clock %d\n", __func__,
793 vb.vbt_emmcclockrate.rate); 793 vb.vbt_emmcclockrate.rate);
794 if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag)) 794 if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag))
795 printf("%s: emmc2 clock %d\n", __func__, 795 printf("%s: emmc2 clock %d\n", __func__,
796 vb.vbt_emmcclockrate.rate); 796 vb.vbt_emmcclockrate.rate);
797 if (vcprop_tag_success_p(&vb.vbt_fwrev.tag)) 797 if (vcprop_tag_success_p(&vb.vbt_fwrev.tag))
798 printf("%s: firmware rev %x\n", __func__, 798 printf("%s: firmware rev %x\n", __func__,
799 vb.vbt_fwrev.rev); 799 vb.vbt_fwrev.rev);
800 if (vcprop_tag_success_p(&vb.vbt_boardmodel.tag)) 800 if (vcprop_tag_success_p(&vb.vbt_boardmodel.tag))
801 printf("%s: board model %x\n", __func__, 801 printf("%s: board model %x\n", __func__,
802 vb.vbt_boardmodel.model); 802 vb.vbt_boardmodel.model);
803 if (vcprop_tag_success_p(&vb.vbt_macaddr.tag)) 803 if (vcprop_tag_success_p(&vb.vbt_macaddr.tag))
804 printf("%s: mac-address %" PRIx64 "\n", __func__, 804 printf("%s: mac-address %" PRIx64 "\n", __func__,
805 vb.vbt_macaddr.addr); 805 vb.vbt_macaddr.addr);
806 if (vcprop_tag_success_p(&vb.vbt_boardrev.tag)) 806 if (vcprop_tag_success_p(&vb.vbt_boardrev.tag))
807 printf("%s: board rev %x\n", __func__, 807 printf("%s: board rev %x\n", __func__,
808 vb.vbt_boardrev.rev); 808 vb.vbt_boardrev.rev);
809 if (vcprop_tag_success_p(&vb.vbt_serial.tag)) 809 if (vcprop_tag_success_p(&vb.vbt_serial.tag))
810 printf("%s: board serial %" PRIx64 "\n", __func__, 810 printf("%s: board serial %" PRIx64 "\n", __func__,
811 vb.vbt_serial.sn); 811 vb.vbt_serial.sn);
812 if (vcprop_tag_success_p(&vb.vbt_dmachan.tag)) 812 if (vcprop_tag_success_p(&vb.vbt_dmachan.tag))
813 printf("%s: DMA channel mask 0x%08x\n", __func__, 813 printf("%s: DMA channel mask 0x%08x\n", __func__,
814 vb.vbt_dmachan.mask); 814 vb.vbt_dmachan.mask);
815 815
816 if (vcprop_tag_success_p(&vb.vbt_cmdline.tag)) 816 if (vcprop_tag_success_p(&vb.vbt_cmdline.tag))
817 printf("%s: cmdline %s\n", __func__, 817 printf("%s: cmdline %s\n", __func__,
818 vb.vbt_cmdline.cmdline); 818 vb.vbt_cmdline.cmdline);
819#endif 819#endif
820} 820}
821 821
822#if defined(SOC_BCM2835) 822#if defined(SOC_BCM2835)
823static void 823static void
824bcm2835_bootparams(void) 824bcm2835_bootparams(void)
825{ 825{
826 const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); 826 const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
827 const bus_space_tag_t iot = &bcm2835_bs_tag; 827 const bus_space_tag_t iot = &bcm2835_bs_tag;
828 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); 828 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa);
829 829
830 bcm283x_bootparams(iot, ioh); 830 bcm283x_bootparams(iot, ioh);
831} 831}
832#endif 832#endif
833 833
834#if defined(SOC_BCM2836) 834#if defined(SOC_BCM2836)
835static void 835static void
836bcm2836_bootparams(void) 836bcm2836_bootparams(void)
837{ 837{
838 const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); 838 const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
839 const bus_space_tag_t iot = &bcm2836_bs_tag; 839 const bus_space_tag_t iot = &bcm2836_bs_tag;
840 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); 840 const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa);
841 841
842 bcm283x_bootparams(iot, ioh); 842 bcm283x_bootparams(iot, ioh);
843} 843}
844 844
845static void 845static void
846bcm2711_bootparams(void) 846bcm2711_bootparams(void)
847{ 847{
848 const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); 848 const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
849 const bus_space_tag_t iot = &bcm2711_bs_tag; 849 const bus_space_tag_t iot = &bcm2711_bs_tag;
850 const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa); 850 const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa);
851 851
852 bcm283x_bootparams(iot, ioh); 852 bcm283x_bootparams(iot, ioh);
853} 853}
854 854
855#if defined(MULTIPROCESSOR) 855#if defined(MULTIPROCESSOR)
856static int 856static int
857cpu_enable_bcm2836(int phandle) 857cpu_enable_bcm2836(int phandle)
858{ 858{
859 bus_space_tag_t iot = &bcm2836_bs_tag; 859 bus_space_tag_t iot = &bcm2836_bs_tag;
860 bus_space_handle_t ioh = BCM2836_ARM_LOCAL_VBASE; 860 bus_space_handle_t ioh = BCM2836_ARM_LOCAL_VBASE;
861 uint64_t mpidr; 861 uint64_t mpidr;
862 862
863 fdtbus_get_reg64(phandle, 0, &mpidr, NULL); 863 fdtbus_get_reg64(phandle, 0, &mpidr, NULL);
864 864
865 const u_int cpuno = __SHIFTOUT(mpidr, MPIDR_AFF0); 865 const u_int cpuno = __SHIFTOUT(mpidr, MPIDR_AFF0);
866 866
867 bus_space_write_4(iot, ioh, BCM2836_LOCAL_MAILBOX3_SETN(cpuno), 867 bus_space_write_4(iot, ioh, BCM2836_LOCAL_MAILBOX3_SETN(cpuno),
868 KERN_VTOPHYS((vaddr_t)cpu_mpstart)); 868 KERN_VTOPHYS((vaddr_t)cpu_mpstart));
869 869
870 return 0; 870 return 0;
871} 871}
872ARM_CPU_METHOD(bcm2836, "brcm,bcm2836-smp", cpu_enable_bcm2836); 872ARM_CPU_METHOD(bcm2836, "brcm,bcm2836-smp", cpu_enable_bcm2836);
873#endif 873#endif
874 874
875#endif /* SOC_BCM2836 */ 875#endif /* SOC_BCM2836 */
876 876
877#if NGENFB > 0 877#if NGENFB > 0
878static bool 878static bool
879rpi_fb_parse_mode(const char *s, uint32_t *pwidth, uint32_t *pheight) 879rpi_fb_parse_mode(const char *s, uint32_t *pwidth, uint32_t *pheight)
880{ 880{
881 char *x; 881 char *x;
882 882
883 if (strncmp(s, "disable", 7) == 0) 883 if (strncmp(s, "disable", 7) == 0)
884 return false; 884 return false;
885 885
886 x = strchr(s, 'x'); 886 x = strchr(s, 'x');
887 if (x) { 887 if (x) {
888 *pwidth = strtoul(s, NULL, 10); 888 *pwidth = strtoul(s, NULL, 10);
889 *pheight = strtoul(x + 1, NULL, 10); 889 *pheight = strtoul(x + 1, NULL, 10);
890 } 890 }
891 891
892 return true; 892 return true;
893} 893}
894 894
895static bool 895static bool
896rpi_fb_get_edid_mode(uint32_t *pwidth, uint32_t *pheight) 896rpi_fb_get_edid_mode(uint32_t *pwidth, uint32_t *pheight)
897{ 897{
898 struct edid_info ei; 898 struct edid_info ei;
899 uint8_t edid_data[1024]; 899 uint8_t edid_data[1024];
900 uint32_t res; 900 uint32_t res;
901 int error; 901 int error;
902 902
903 error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_edid, 903 error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_edid,
904 sizeof(vb_edid), &res); 904 sizeof(vb_edid), &res);
905 if (error) { 905 if (error) {
906 printf("%s: mbox request failed (%d)\n", __func__, error); 906 printf("%s: mbox request failed (%d)\n", __func__, error);
907 return false; 907 return false;
908 } 908 }
909 909
910 if (!vcprop_buffer_success_p(&vb_edid.vb_hdr) || 910 if (!vcprop_buffer_success_p(&vb_edid.vb_hdr) ||
911 !vcprop_tag_success_p(&vb_edid.vbt_edid.tag) || 911 !vcprop_tag_success_p(&vb_edid.vbt_edid.tag) ||
912 vb_edid.vbt_edid.status != 0) 912 vb_edid.vbt_edid.status != 0)
913 return false; 913 return false;
914 914
915 memset(edid_data, 0, sizeof(edid_data)); 915 memset(edid_data, 0, sizeof(edid_data));
916 memcpy(edid_data, vb_edid.vbt_edid.data, 916 memcpy(edid_data, vb_edid.vbt_edid.data,
917 sizeof(vb_edid.vbt_edid.data)); 917 sizeof(vb_edid.vbt_edid.data));
918 edid_parse(edid_data, &ei); 918 edid_parse(edid_data, &ei);
919#ifdef VERBOSE_INIT_ARM 919#ifdef VERBOSE_INIT_ARM
920 edid_print(&ei); 920 edid_print(&ei);
921#endif 921#endif
922 922
923 if (ei.edid_preferred_mode) { 923 if (ei.edid_preferred_mode) {
924 *pwidth = ei.edid_preferred_mode->hdisplay; 924 *pwidth = ei.edid_preferred_mode->hdisplay;
925 *pheight = ei.edid_preferred_mode->vdisplay; 925 *pheight = ei.edid_preferred_mode->vdisplay;
926 } 926 }
927 927
928 return true; 928 return true;
929} 929}
930 930
931/* 931/*
932 * Initialize framebuffer console. 932 * Initialize framebuffer console.
933 * 933 *
934 * Some notes about boot parameters: 934 * Some notes about boot parameters:
935 * - If "fb=disable" is present, ignore framebuffer completely. 935 * - If "fb=disable" is present, ignore framebuffer completely.
936 * - If "fb=<width>x<height> is present, use the specified mode. 936 * - If "fb=<width>x<height> is present, use the specified mode.
937 * - If "console=fb" is present, attach framebuffer to console. 937 * - If "console=fb" is present, attach framebuffer to console.
938 */ 938 */
939static bool 939static bool
940rpi_fb_init(prop_dictionary_t dict, void *aux) 940rpi_fb_init(prop_dictionary_t dict, void *aux)
941{ 941{
942 uint32_t width = 0, height = 0; 942 uint32_t width = 0, height = 0;
943 uint32_t res; 943 uint32_t res;
944 char *ptr; 944 char *ptr;
945 int integer; 945 int integer;
946 int error; 946 int error;
947 bool is_bgr = true; 947 bool is_bgr = true;
948 948
949 if (get_bootconf_option(boot_args, "fb", 949 if (get_bootconf_option(boot_args, "fb",
950 BOOTOPT_TYPE_STRING, &ptr)) { 950 BOOTOPT_TYPE_STRING, &ptr)) {
951 if (rpi_fb_parse_mode(ptr, &width, &height) == false) 951 if (rpi_fb_parse_mode(ptr, &width, &height) == false)
952 return false; 952 return false;
953 } 953 }
954 if (width == 0 || height == 0) { 954 if (width == 0 || height == 0) {
955 rpi_fb_get_edid_mode(&width, &height); 955 rpi_fb_get_edid_mode(&width, &height);
956 } 956 }
957 if (width == 0 || height == 0) { 957 if (width == 0 || height == 0) {
958 width = RPI_FB_WIDTH; 958 width = RPI_FB_WIDTH;
959 height = RPI_FB_HEIGHT; 959 height = RPI_FB_HEIGHT;
960 } 960 }
961 961
962 vb_setfb.vbt_res.width = width; 962 vb_setfb.vbt_res.width = width;
963 vb_setfb.vbt_res.height = height; 963 vb_setfb.vbt_res.height = height;
964 vb_setfb.vbt_vres.width = width; 964 vb_setfb.vbt_vres.width = width;
965 vb_setfb.vbt_vres.height = height; 965 vb_setfb.vbt_vres.height = height;
966 error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_setfb, 966 error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_setfb,
967 sizeof(vb_setfb), &res); 967 sizeof(vb_setfb), &res);
968 if (error) { 968 if (error) {
969 printf("%s: mbox request failed (%d)\n", __func__, error); 969 printf("%s: mbox request failed (%d)\n", __func__, error);
970 return false; 970 return false;
971 } 971 }
972 972
973 if (!vcprop_buffer_success_p(&vb_setfb.vb_hdr) || 973 if (!vcprop_buffer_success_p(&vb_setfb.vb_hdr) ||
974 !vcprop_tag_success_p(&vb_setfb.vbt_res.tag) || 974 !vcprop_tag_success_p(&vb_setfb.vbt_res.tag) ||
975 !vcprop_tag_success_p(&vb_setfb.vbt_vres.tag) || 975 !vcprop_tag_success_p(&vb_setfb.vbt_vres.tag) ||
976 !vcprop_tag_success_p(&vb_setfb.vbt_depth.tag) || 976 !vcprop_tag_success_p(&vb_setfb.vbt_depth.tag) ||
977 !vcprop_tag_success_p(&vb_setfb.vbt_allocbuf.tag) || 977 !vcprop_tag_success_p(&vb_setfb.vbt_allocbuf.tag) ||
978 !vcprop_tag_success_p(&vb_setfb.vbt_blank.tag) || 978 !vcprop_tag_success_p(&vb_setfb.vbt_blank.tag) ||
979 !vcprop_tag_success_p(&vb_setfb.vbt_pitch.tag)) { 979 !vcprop_tag_success_p(&vb_setfb.vbt_pitch.tag)) {
980 printf("%s: prop tag failed\n", __func__); 980 printf("%s: prop tag failed\n", __func__);
981 return false; 981 return false;
982 } 982 }
983 983
984#ifdef VERBOSE_INIT_ARM 984#ifdef VERBOSE_INIT_ARM
985 printf("%s: addr = 0x%x size = %d\n", __func__, 985 printf("%s: addr = 0x%x size = %d\n", __func__,
986 vb_setfb.vbt_allocbuf.address, 986 vb_setfb.vbt_allocbuf.address,
987 vb_setfb.vbt_allocbuf.size); 987 vb_setfb.vbt_allocbuf.size);
988 printf("%s: depth = %d\n", __func__, vb_setfb.vbt_depth.bpp); 988 printf("%s: depth = %d\n", __func__, vb_setfb.vbt_depth.bpp);
989 printf("%s: pitch = %d\n", __func__, 989 printf("%s: pitch = %d\n", __func__,
990 vb_setfb.vbt_pitch.linebytes); 990 vb_setfb.vbt_pitch.linebytes);
991 printf("%s: width = %d height = %d\n", __func__, 991 printf("%s: width = %d height = %d\n", __func__,
992 vb_setfb.vbt_res.width, vb_setfb.vbt_res.height); 992 vb_setfb.vbt_res.width, vb_setfb.vbt_res.height);
993 printf("%s: vwidth = %d vheight = %d\n", __func__, 993 printf("%s: vwidth = %d vheight = %d\n", __func__,
994 vb_setfb.vbt_vres.width, vb_setfb.vbt_vres.height); 994 vb_setfb.vbt_vres.width, vb_setfb.vbt_vres.height);
995#endif 995#endif
996 996
997 if (vb_setfb.vbt_allocbuf.address == 0 || 997 if (vb_setfb.vbt_allocbuf.address == 0 ||
998 vb_setfb.vbt_allocbuf.size == 0 || 998 vb_setfb.vbt_allocbuf.size == 0 ||
999 vb_setfb.vbt_res.width == 0 || 999 vb_setfb.vbt_res.width == 0 ||
1000 vb_setfb.vbt_res.height == 0 || 1000 vb_setfb.vbt_res.height == 0 ||
1001 vb_setfb.vbt_vres.width == 0 || 1001 vb_setfb.vbt_vres.width == 0 ||
1002 vb_setfb.vbt_vres.height == 0 || 1002 vb_setfb.vbt_vres.height == 0 ||
1003 vb_setfb.vbt_pitch.linebytes == 0) { 1003 vb_setfb.vbt_pitch.linebytes == 0) {
1004 printf("%s: failed to set mode %ux%u\n", __func__, 1004 printf("%s: failed to set mode %ux%u\n", __func__,
1005 width, height); 1005 width, height);
1006 return false; 1006 return false;
1007 } 1007 }
1008 1008
1009 prop_dictionary_set_uint32(dict, "width", vb_setfb.vbt_res.width); 1009 prop_dictionary_set_uint32(dict, "width", vb_setfb.vbt_res.width);
1010 prop_dictionary_set_uint32(dict, "height", vb_setfb.vbt_res.height); 1010 prop_dictionary_set_uint32(dict, "height", vb_setfb.vbt_res.height);
1011 prop_dictionary_set_uint8(dict, "depth", vb_setfb.vbt_depth.bpp); 1011 prop_dictionary_set_uint8(dict, "depth", vb_setfb.vbt_depth.bpp);
1012 prop_dictionary_set_uint16(dict, "linebytes", 1012 prop_dictionary_set_uint16(dict, "linebytes",
1013 vb_setfb.vbt_pitch.linebytes); 1013 vb_setfb.vbt_pitch.linebytes);
1014 prop_dictionary_set_uint32(dict, "address", 1014 prop_dictionary_set_uint32(dict, "address",
1015 vb_setfb.vbt_allocbuf.address); 1015 vb_setfb.vbt_allocbuf.address);
1016 1016
1017 /* 1017 /*
1018 * Old firmware uses BGR. New firmware uses RGB. The get and set 1018 * Old firmware uses BGR. New firmware uses RGB. The get and set
1019 * pixel order mailbox properties don't seem to work. The firmware 1019 * pixel order mailbox properties don't seem to work. The firmware
1020 * adds a kernel cmdline option bcm2708_fb.fbswap=<0|1>, so use it 1020 * adds a kernel cmdline option bcm2708_fb.fbswap=<0|1>, so use it
1021 * to determine pixel order. 0 means BGR, 1 means RGB. 1021 * to determine pixel order. 0 means BGR, 1 means RGB.
1022 * 1022 *
1023 * See https://github.com/raspberrypi/linux/issues/514 1023 * See https://github.com/raspberrypi/linux/issues/514
1024 */ 1024 */
1025 if (get_bootconf_option(boot_args, "bcm2708_fb.fbswap", 1025 if (get_bootconf_option(boot_args, "bcm2708_fb.fbswap",
1026 BOOTOPT_TYPE_INT, &integer)) { 1026 BOOTOPT_TYPE_INT, &integer)) {
1027 is_bgr = integer == 0; 1027 is_bgr = integer == 0;
1028 } 1028 }
1029 prop_dictionary_set_bool(dict, "is_bgr", is_bgr); 1029 prop_dictionary_set_bool(dict, "is_bgr", is_bgr);
1030 1030
1031 /* if "genfb.type=<n>" is passed in cmdline, override wsdisplay type */ 1031 /* if "genfb.type=<n>" is passed in cmdline, override wsdisplay type */
1032 if (get_bootconf_option(boot_args, "genfb.type", 1032 if (get_bootconf_option(boot_args, "genfb.type",
1033 BOOTOPT_TYPE_INT, &integer)) { 1033 BOOTOPT_TYPE_INT, &integer)) {
1034 prop_dictionary_set_uint32(dict, "wsdisplay_type", integer); 1034 prop_dictionary_set_uint32(dict, "wsdisplay_type", integer);
1035 } 1035 }
1036 1036
1037#if defined(RPI_HWCURSOR) 1037#if defined(RPI_HWCURSOR)
1038 struct fdt_attach_args *faa = aux; 1038 struct fdt_attach_args *faa = aux;
1039 bus_space_handle_t hc; 1039 bus_space_handle_t hc;
1040 1040
1041 hcursor = rpi_alloc_mem(CURSOR_ARGB_SIZE, PAGE_SIZE, 1041 hcursor = rpi_alloc_mem(CURSOR_ARGB_SIZE, PAGE_SIZE,
1042 MEM_FLAG_L1_NONALLOCATING | MEM_FLAG_HINT_PERMALOCK); 1042 MEM_FLAG_L1_NONALLOCATING | MEM_FLAG_HINT_PERMALOCK);
1043 pcursor = rpi_lock_mem(hcursor); 1043 pcursor = rpi_lock_mem(hcursor);
1044#ifdef RPI_IOCTL_DEBUG 1044#ifdef RPI_IOCTL_DEBUG
1045 printf("hcursor: %08x\n", hcursor); 1045 printf("hcursor: %08x\n", hcursor);
1046 printf("pcursor: %08x\n", (uint32_t)pcursor); 1046 printf("pcursor: %08x\n", (uint32_t)pcursor);
1047 printf("fb: %08x\n", (uint32_t)vb_setfb.vbt_allocbuf.address); 1047 printf("fb: %08x\n", (uint32_t)vb_setfb.vbt_allocbuf.address);
1048#endif 1048#endif
1049 if (bus_space_map(faa->faa_bst, pcursor, CURSOR_ARGB_SIZE, 1049 if (bus_space_map(faa->faa_bst, pcursor, CURSOR_ARGB_SIZE,
1050 BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &hc) != 0) { 1050 BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &hc) != 0) {
1051 printf("couldn't map cursor memory\n"); 1051 printf("couldn't map cursor memory\n");
1052 } else { 1052 } else {
1053 int i, j, k; 1053 int i, j, k;
1054 1054
1055 cmem = bus_space_vaddr(faa->faa_bst, hc); 1055 cmem = bus_space_vaddr(faa->faa_bst, hc);
1056 k = 0; 1056 k = 0;
1057 for (j = 0; j < 64; j++) { 1057 for (j = 0; j < 64; j++) {
1058 for (i = 0; i < 64; i++) { 1058 for (i = 0; i < 64; i++) {
1059 cmem[i + k] = 1059 cmem[i + k] =
1060 ((i & 8) ^ (j & 8)) ? 0xa0ff0000 : 0xa000ff00; 1060 ((i & 8) ^ (j & 8)) ? 0xa0ff0000 : 0xa000ff00;
1061 } 1061 }
1062 k += 64; 1062 k += 64;
1063 } 1063 }
1064 cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); 1064 cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE);
1065 rpi_fb_initcursor(pcursor, 0, 0); 1065 rpi_fb_initcursor(pcursor, 0, 0);
1066#ifdef RPI_IOCTL_DEBUG 1066#ifdef RPI_IOCTL_DEBUG
1067 rpi_fb_movecursor(600, 400, 1); 1067 rpi_fb_movecursor(600, 400, 1);
1068#else 1068#else
1069 rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); 1069 rpi_fb_movecursor(cursor_x, cursor_y, cursor_on);
1070#endif 1070#endif
1071 } 1071 }
1072#endif 1072#endif
1073 1073
1074 return true; 1074 return true;
1075} 1075}
1076 1076
1077 1077
1078#if defined(RPI_HWCURSOR) 1078#if defined(RPI_HWCURSOR)
1079static int 1079static int
1080rpi_fb_do_cursor(struct wsdisplay_cursor *cur) 1080rpi_fb_do_cursor(struct wsdisplay_cursor *cur)
1081{ 1081{
1082 int pos = 0; 1082 int pos = 0;
1083 int shape = 0; 1083 int shape = 0;
1084 1084
1085 if (cur->which & WSDISPLAY_CURSOR_DOCUR) { 1085 if (cur->which & WSDISPLAY_CURSOR_DOCUR) {
1086 if (cursor_on != cur->enable) { 1086 if (cursor_on != cur->enable) {
1087 cursor_on = cur->enable; 1087 cursor_on = cur->enable;
1088 pos = 1; 1088 pos = 1;
1089 } 1089 }
1090 } 1090 }
1091 if (cur->which & WSDISPLAY_CURSOR_DOHOT) { 1091 if (cur->which & WSDISPLAY_CURSOR_DOHOT) {
1092 1092
1093 hot_x = cur->hot.x; 1093 hot_x = cur->hot.x;
1094 hot_y = cur->hot.y; 1094 hot_y = cur->hot.y;
1095 pos = 1; 1095 pos = 1;
1096 shape = 1; 1096 shape = 1;
1097 } 1097 }
1098 if (cur->which & WSDISPLAY_CURSOR_DOPOS) { 1098 if (cur->which & WSDISPLAY_CURSOR_DOPOS) {
1099 1099
1100 cursor_x = cur->pos.x; 1100 cursor_x = cur->pos.x;
1101 cursor_y = cur->pos.y; 1101 cursor_y = cur->pos.y;
1102 pos = 1; 1102 pos = 1;
1103 } 1103 }
1104 if (cur->which & WSDISPLAY_CURSOR_DOCMAP) { 1104 if (cur->which & WSDISPLAY_CURSOR_DOCMAP) {
1105 int i; 1105 int i;
1106 uint32_t val; 1106 uint32_t val;
1107 1107
1108 for (i = 0; i < uimin(cur->cmap.count, 3); i++) { 1108 for (i = 0; i < uimin(cur->cmap.count, 3); i++) {
1109 val = (cur->cmap.red[i] << 16 ) | 1109 val = (cur->cmap.red[i] << 16 ) |
1110 (cur->cmap.green[i] << 8) | 1110 (cur->cmap.green[i] << 8) |
1111 (cur->cmap.blue[i] ) | 1111 (cur->cmap.blue[i] ) |
1112 0xff000000; 1112 0xff000000;
1113 cursor_cmap[i + cur->cmap.index + 2] = val; 1113 cursor_cmap[i + cur->cmap.index + 2] = val;
1114 } 1114 }
1115 shape = 1; 1115 shape = 1;
1116 } 1116 }
1117 if (cur->which & WSDISPLAY_CURSOR_DOSHAPE) { 1117 if (cur->which & WSDISPLAY_CURSOR_DOSHAPE) {
1118 int err; 1118 int err;
1119 1119
1120 err = copyin(cur->mask, cursor_mask, CURSOR_BITMAP_SIZE); 1120 err = copyin(cur->mask, cursor_mask, CURSOR_BITMAP_SIZE);
1121 err += copyin(cur->image, cursor_bitmap, CURSOR_BITMAP_SIZE); 1121 err += copyin(cur->image, cursor_bitmap, CURSOR_BITMAP_SIZE);
1122 if (err != 0) 1122 if (err != 0)
1123 return EFAULT; 1123 return EFAULT;
1124 shape = 1; 1124 shape = 1;
1125 } 1125 }
1126 if (shape) { 1126 if (shape) {
1127 int i, j, idx; 1127 int i, j, idx;
1128 uint8_t mask; 1128 uint8_t mask;
1129 1129
1130 for (i = 0; i < CURSOR_BITMAP_SIZE; i++) { 1130 for (i = 0; i < CURSOR_BITMAP_SIZE; i++) {
1131 mask = 0x01; 1131 mask = 0x01;
1132 for (j = 0; j < 8; j++) { 1132 for (j = 0; j < 8; j++) {
1133 idx = ((cursor_mask[i] & mask) ? 2 : 0) | 1133 idx = ((cursor_mask[i] & mask) ? 2 : 0) |
1134 ((cursor_bitmap[i] & mask) ? 1 : 0); 1134 ((cursor_bitmap[i] & mask) ? 1 : 0);
1135 cmem[i * 8 + j] = cursor_cmap[idx]; 1135 cmem[i * 8 + j] = cursor_cmap[idx];
1136 mask = mask << 1; 1136 mask = mask << 1;
1137 } 1137 }
1138 } 1138 }
1139 /* just in case */ 1139 /* just in case */
1140 cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); 1140 cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE);
1141 rpi_fb_initcursor(pcursor, hot_x, hot_y); 1141 rpi_fb_initcursor(pcursor, hot_x, hot_y);
1142 } 1142 }
1143 if (pos) { 1143 if (pos) {
1144 rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); 1144 rpi_fb_movecursor(cursor_x, cursor_y, cursor_on);
1145 } 1145 }
1146 return 0; 1146 return 0;
1147} 1147}
1148#endif 1148#endif
1149 1149
1150static int 1150static int
1151rpi_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l) 1151rpi_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l)
1152{ 1152{
1153 1153
1154 switch (cmd) { 1154 switch (cmd) {
1155 case WSDISPLAYIO_SVIDEO: 1155 case WSDISPLAYIO_SVIDEO:
1156 { 1156 {
1157 int d = *(int *)data; 1157 int d = *(int *)data;
1158 if (d == rpi_video_on) 1158 if (d == rpi_video_on)
1159 return 0; 1159 return 0;
1160 rpi_video_on = d; 1160 rpi_video_on = d;
1161 rpi_fb_set_video(d); 1161 rpi_fb_set_video(d);
1162#if defined(RPI_HWCURSOR) 1162#if defined(RPI_HWCURSOR)
1163 rpi_fb_movecursor(cursor_x, cursor_y, 1163 rpi_fb_movecursor(cursor_x, cursor_y,
1164 d ? cursor_on : 0); 1164 d ? cursor_on : 0);
1165#endif 1165#endif
1166 } 1166 }
1167 return 0; 1167 return 0;
1168 case WSDISPLAYIO_GVIDEO: 1168 case WSDISPLAYIO_GVIDEO:
1169 *(int *)data = rpi_video_on; 1169 *(int *)data = rpi_video_on;
1170 return 0; 1170 return 0;
1171#if defined(RPI_HWCURSOR) 1171#if defined(RPI_HWCURSOR)
1172 case WSDISPLAYIO_GCURPOS: 1172 case WSDISPLAYIO_GCURPOS:
1173 { 1173 {
1174 struct wsdisplay_curpos *cp = (void *)data; 1174 struct wsdisplay_curpos *cp = (void *)data;
1175 1175
1176 cp->x = cursor_x; 1176 cp->x = cursor_x;
1177 cp->y = cursor_y; 1177 cp->y = cursor_y;
1178 } 1178 }
1179 return 0; 1179 return 0;
1180 case WSDISPLAYIO_SCURPOS: 1180 case WSDISPLAYIO_SCURPOS:
1181 { 1181 {
1182 struct wsdisplay_curpos *cp = (void *)data; 1182 struct wsdisplay_curpos *cp = (void *)data;
1183 1183
1184 cursor_x = cp->x; 1184 cursor_x = cp->x;
1185 cursor_y = cp->y; 1185 cursor_y = cp->y;
1186 rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); 1186 rpi_fb_movecursor(cursor_x, cursor_y, cursor_on);
1187 } 1187 }
1188 return 0; 1188 return 0;
1189 case WSDISPLAYIO_GCURMAX: 1189 case WSDISPLAYIO_GCURMAX:
1190 { 1190 {
1191 struct wsdisplay_curpos *cp = (void *)data; 1191 struct wsdisplay_curpos *cp = (void *)data;
1192 1192
1193 cp->x = 64; 1193 cp->x = 64;
1194 cp->y = 64; 1194 cp->y = 64;
1195 } 1195 }
1196 return 0; 1196 return 0;
1197 case WSDISPLAYIO_SCURSOR: 1197 case WSDISPLAYIO_SCURSOR:
1198 { 1198 {
1199 struct wsdisplay_cursor *cursor = (void *)data; 1199 struct wsdisplay_cursor *cursor = (void *)data;
1200 1200
1201 return rpi_fb_do_cursor(cursor); 1201 return rpi_fb_do_cursor(cursor);
1202 } 1202 }
1203#endif 1203#endif
1204 default: 1204 default:
1205 return EPASSTHROUGH; 1205 return EPASSTHROUGH;
1206 } 1206 }
1207} 1207}
1208 1208
1209#endif 1209#endif
1210 1210
1211SYSCTL_SETUP(sysctl_machdep_rpi, "sysctl machdep subtree setup (rpi)") 1211SYSCTL_SETUP(sysctl_machdep_rpi, "sysctl machdep subtree setup (rpi)")
1212{ 1212{
1213 sysctl_createv(clog, 0, NULL, NULL, 1213 sysctl_createv(clog, 0, NULL, NULL,
1214 CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, 1214 CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
1215 NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); 1215 NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
1216 1216
1217 sysctl_createv(clog, 0, NULL, NULL, 1217 sysctl_createv(clog, 0, NULL, NULL,
1218 CTLFLAG_PERMANENT|CTLFLAG_READONLY, 1218 CTLFLAG_PERMANENT|CTLFLAG_READONLY,
1219 CTLTYPE_INT, "firmware_revision", NULL, NULL, 0, 1219 CTLTYPE_INT, "firmware_revision", NULL, NULL, 0,
1220 &vb.vbt_fwrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); 1220 &vb.vbt_fwrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
1221 1221
1222 sysctl_createv(clog, 0, NULL, NULL, 1222 sysctl_createv(clog, 0, NULL, NULL,
1223 CTLFLAG_PERMANENT|CTLFLAG_READONLY, 1223 CTLFLAG_PERMANENT|CTLFLAG_READONLY,
1224 CTLTYPE_INT, "board_model", NULL, NULL, 0, 1224 CTLTYPE_INT, "board_model", NULL, NULL, 0,
1225 &vb.vbt_boardmodel.model, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); 1225 &vb.vbt_boardmodel.model, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
1226 1226
1227 sysctl_createv(clog, 0, NULL, NULL, 1227 sysctl_createv(clog, 0, NULL, NULL,
1228 CTLFLAG_PERMANENT|CTLFLAG_READONLY, 1228 CTLFLAG_PERMANENT|CTLFLAG_READONLY,
1229 CTLTYPE_INT, "board_revision", NULL, NULL, 0, 1229 CTLTYPE_INT, "board_revision", NULL, NULL, 0,
1230 &vb.vbt_boardrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); 1230 &vb.vbt_boardrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
1231 1231
1232 sysctl_createv(clog, 0, NULL, NULL, 1232 sysctl_createv(clog, 0, NULL, NULL,
1233 CTLFLAG_PERMANENT|CTLFLAG_READONLY|CTLFLAG_HEX|CTLFLAG_PRIVATE, 1233 CTLFLAG_PERMANENT|CTLFLAG_READONLY|CTLFLAG_HEX|CTLFLAG_PRIVATE,
1234 CTLTYPE_QUAD, "serial", NULL, NULL, 0, 1234 CTLTYPE_QUAD, "serial", NULL, NULL, 0,
1235 &vb.vbt_serial.sn, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); 1235 &vb.vbt_serial.sn, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
1236} 1236}
1237 1237
1238#if defined(SOC_BCM2835) 1238#if defined(SOC_BCM2835)
1239static void 1239static void
1240bcm2835_platform_bootstrap(void) 1240bcm2835_platform_bootstrap(void)
1241{ 1241{
1242 1242
1243 bcm2835_bs_tag = arm_generic_bs_tag; 1243 bcm2835_bs_tag = arm_generic_bs_tag;
1244 bcm2835_a4x_bs_tag = arm_generic_a4x_bs_tag; 1244 bcm2835_a4x_bs_tag = arm_generic_a4x_bs_tag;
1245 1245
1246 bcm2835_bs_tag.bs_map = bcm2835_bs_map; 1246 bcm2835_bs_tag.bs_map = bcm2835_bs_map;
1247 bcm2835_bs_tag.bs_mmap = bcm2835_bs_mmap; 1247 bcm2835_bs_tag.bs_mmap = bcm2835_bs_mmap;
1248 bcm2835_a4x_bs_tag.bs_map = bcm2835_bs_map; 1248 bcm2835_a4x_bs_tag.bs_map = bcm2835_bs_map;
1249 bcm2835_a4x_bs_tag.bs_mmap = bcm2835_a4x_bs_mmap; 1249 bcm2835_a4x_bs_tag.bs_mmap = bcm2835_a4x_bs_mmap;
1250 1250
1251 fdtbus_set_decoderegprop(false); 1251 fdtbus_set_decoderegprop(false);
1252 1252
1253 bcm2835_uartinit(); 1253 bcm2835_uartinit();
1254 1254
1255 bcm2835_bootparams(); 1255 bcm2835_bootparams();
1256} 1256}
1257#endif 1257#endif
1258 1258
1259#if defined(SOC_BCM2836) 1259#if defined(SOC_BCM2836)
1260static void 1260static void
1261bcm2836_platform_bootstrap(void) 1261bcm2836_platform_bootstrap(void)
1262{ 1262{
1263 1263
1264 bcm2836_bs_tag = arm_generic_bs_tag; 1264 bcm2836_bs_tag = arm_generic_bs_tag;
1265 bcm2836_a4x_bs_tag = arm_generic_a4x_bs_tag; 1265 bcm2836_a4x_bs_tag = arm_generic_a4x_bs_tag;
1266 1266
1267 bcm2836_bs_tag.bs_map = bcm2836_bs_map; 1267 bcm2836_bs_tag.bs_map = bcm2836_bs_map;
1268 bcm2836_bs_tag.bs_mmap = bcm2836_bs_mmap; 1268 bcm2836_bs_tag.bs_mmap = bcm2836_bs_mmap;
1269 bcm2836_a4x_bs_tag.bs_map = bcm2836_bs_map; 1269 bcm2836_a4x_bs_tag.bs_map = bcm2836_bs_map;
1270 bcm2836_a4x_bs_tag.bs_mmap = bcm2836_a4x_bs_mmap; 1270 bcm2836_a4x_bs_tag.bs_mmap = bcm2836_a4x_bs_mmap;
1271 1271
1272 fdtbus_set_decoderegprop(false); 1272 fdtbus_set_decoderegprop(false);
1273 1273
1274 bcm2836_uartinit(); 1274 bcm2836_uartinit();
1275 1275
1276 bcm2836_bootparams(); 1276 bcm2836_bootparams();
1277 1277
1278#ifdef MULTIPROCESSOR 1278#ifdef MULTIPROCESSOR
1279 arm_cpu_max = RPI_CPU_MAX; 1279 arm_cpu_max = RPI_CPU_MAX;
1280 arm_fdt_cpu_bootstrap(); 1280 arm_fdt_cpu_bootstrap();
1281#endif 1281#endif
1282} 1282}
1283 1283
1284static void 1284static void
1285bcm2711_platform_bootstrap(void) 1285bcm2711_platform_bootstrap(void)
1286{ 1286{
1287 1287
1288 bcm2711_bs_tag = arm_generic_bs_tag; 1288 bcm2711_bs_tag = arm_generic_bs_tag;
1289 bcm2711_a4x_bs_tag = arm_generic_a4x_bs_tag; 1289 bcm2711_a4x_bs_tag = arm_generic_a4x_bs_tag;
1290 1290
1291 bcm2711_bs_tag.bs_map = bcm2711_bs_map; 1291 bcm2711_bs_tag.bs_map = bcm2711_bs_map;
1292 bcm2711_bs_tag.bs_mmap = bcm2711_bs_mmap; 1292 bcm2711_bs_tag.bs_mmap = bcm2711_bs_mmap;
1293 bcm2711_a4x_bs_tag.bs_map = bcm2711_bs_map; 1293 bcm2711_a4x_bs_tag.bs_map = bcm2711_bs_map;
1294 bcm2711_a4x_bs_tag.bs_mmap = bcm2711_a4x_bs_mmap; 1294 bcm2711_a4x_bs_tag.bs_mmap = bcm2711_a4x_bs_mmap;
1295 1295
1296 fdtbus_set_decoderegprop(false); 1296 fdtbus_set_decoderegprop(false);
1297 1297
1298 bcm2711_uartinit(); 1298 bcm2711_uartinit();
1299 1299
1300 bcm2711_bootparams(); 1300 bcm2711_bootparams();
1301 1301
1302#ifdef MULTIPROCESSOR 1302#ifdef MULTIPROCESSOR
1303 arm_cpu_max = RPI_CPU_MAX; 1303 arm_cpu_max = RPI_CPU_MAX;
1304 arm_fdt_cpu_bootstrap(); 1304 arm_fdt_cpu_bootstrap();
1305#endif 1305#endif
1306} 1306}
1307#endif 1307#endif
1308 1308
1309#if defined(SOC_BCM2835) 1309#if defined(SOC_BCM2835)
1310static void 1310static void
1311bcm2835_platform_init_attach_args(struct fdt_attach_args *faa) 1311bcm2835_platform_init_attach_args(struct fdt_attach_args *faa)
1312{ 1312{
1313 1313
1314 faa->faa_bst = &bcm2835_bs_tag; 1314 faa->faa_bst = &bcm2835_bs_tag;
1315 faa->faa_a4x_bst = &bcm2835_a4x_bs_tag; 1315 faa->faa_a4x_bst = &bcm2835_a4x_bs_tag;
1316 faa->faa_dmat = &bcm2835_bus_dma_tag; 1316 faa->faa_dmat = &bcm2835_bus_dma_tag;
1317 1317
1318 bcm2835_bus_dma_tag._ranges = bcm2835_dma_ranges; 1318 bcm2835_bus_dma_tag._ranges = bcm2835_dma_ranges;
1319 bcm2835_bus_dma_tag._nranges = __arraycount(bcm2835_dma_ranges); 1319 bcm2835_bus_dma_tag._nranges = __arraycount(bcm2835_dma_ranges);
1320 bcm2835_dma_ranges[0].dr_len = bcm283x_memorysize; 1320 bcm2835_dma_ranges[0].dr_len = bcm283x_memorysize;
1321} 1321}
1322#endif 1322#endif
1323 1323
1324#if defined(SOC_BCM2836) 1324#if defined(SOC_BCM2836)
1325static void 1325static void
1326bcm2836_platform_init_attach_args(struct fdt_attach_args *faa) 1326bcm2836_platform_init_attach_args(struct fdt_attach_args *faa)
1327{ 1327{
1328 1328
1329 faa->faa_bst = &bcm2836_bs_tag; 1329 faa->faa_bst = &bcm2836_bs_tag;
1330 faa->faa_a4x_bst = &bcm2836_a4x_bs_tag; 1330 faa->faa_a4x_bst = &bcm2836_a4x_bs_tag;
1331 faa->faa_dmat = &bcm2835_bus_dma_tag; 1331 faa->faa_dmat = &bcm2835_bus_dma_tag;
1332 1332
1333 bcm2835_bus_dma_tag._ranges = bcm2836_dma_ranges; 1333 bcm2835_bus_dma_tag._ranges = bcm2836_dma_ranges;
1334 bcm2835_bus_dma_tag._nranges = __arraycount(bcm2836_dma_ranges); 1334 bcm2835_bus_dma_tag._nranges = __arraycount(bcm2836_dma_ranges);
1335 bcm2836_dma_ranges[0].dr_len = bcm283x_memorysize; 1335 bcm2836_dma_ranges[0].dr_len = bcm283x_memorysize;

cvs diff -r1.4 -r1.5 src/sys/arch/arm/broadcom/bcm283x_platform.h (switch to unified diff)

--- src/sys/arch/arm/broadcom/bcm283x_platform.h 2019/12/24 14:10:51 1.4
+++ src/sys/arch/arm/broadcom/bcm283x_platform.h 2019/12/30 16:19:27 1.5
@@ -1,61 +1,64 @@ @@ -1,61 +1,64 @@
1/* $NetBSD: bcm283x_platform.h,v 1.4 2019/12/24 14:10:51 skrll Exp $ */ 1/* $NetBSD: bcm283x_platform.h,v 1.5 2019/12/30 16:19:27 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nick Hudson 8 * by Nick Hudson
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _ARM_BCM2835REG_PLATFORM_H_ 32#ifndef _ARM_BCM2835REG_PLATFORM_H_
33#define _ARM_BCM2835REG_PLATFORM_H_ 33#define _ARM_BCM2835REG_PLATFORM_H_
34 34
35#include <arch/evbarm/fdt/platform.h> 35#include <arch/evbarm/fdt/platform.h>
36 36
37#define BCM2835_IOPHYSTOVIRT(a) \ 37#define BCM2835_IOPHYSTOVIRT(a) \
38 ((KERNEL_IO_VBASE | (((a) & 0xf0000000) >> 4)) + ((a) & ~0xff000000)) 38 ((KERNEL_IO_VBASE | (((a) & 0xf0000000) >> 4)) + ((a) & ~0xff000000))
39 39
40#define BCM2711_IOPHYSTOVIRT(a) \ 40#define BCM2711_IOPHYSTOVIRT(a) \
41 ((KERNEL_IO_VBASE | (a))) 41 ((KERNEL_IO_VBASE | (a)))
42 42
43#define BCM2835_PERIPHERALS_VBASE \ 43#define BCM2835_PERIPHERALS_VBASE \
44 BCM2835_IOPHYSTOVIRT(BCM2835_PERIPHERALS_BASE) 44 BCM2835_IOPHYSTOVIRT(BCM2835_PERIPHERALS_BASE)
45 45
46#define BCM2836_PERIPHERALS_VBASE \ 46#define BCM2836_PERIPHERALS_VBASE \
47 BCM2835_IOPHYSTOVIRT(BCM2836_PERIPHERALS_BASE) 47 BCM2835_IOPHYSTOVIRT(BCM2836_PERIPHERALS_BASE)
48 48
49#define BCM2711_PERIPHERALS_VBASE \ 49#define BCM2711_PERIPHERALS_VBASE \
50 BCM2711_IOPHYSTOVIRT(BCM2711_PERIPHERALS_BASE) 50 BCM2711_IOPHYSTOVIRT(BCM2711_PERIPHERALS_BASE)
51 51
52#define BCM2836_ARM_LOCAL_VBASE \ 52#define BCM2836_ARM_LOCAL_VBASE \
53 BCM2835_IOPHYSTOVIRT(BCM2836_ARM_LOCAL_BASE) 53 BCM2835_IOPHYSTOVIRT(BCM2836_ARM_LOCAL_BASE)
54 54
55#define BCM2836_ARM_SMP_VBASE \ 55#define BCM2836_ARM_SMP_VBASE \
56 BCM2835_IOPHYSTOVIRT(BCM2836_ARM_SMP_BASE) 56 BCM2835_IOPHYSTOVIRT(BCM2836_ARM_SMP_BASE)
57 57
58#define BCM2711_ARM_LOCAL_VBASE \ 58#define BCM2711_ARM_LOCAL_VBASE \
59 BCM2711_IOPHYSTOVIRT(BCM2711_ARM_LOCAL_BASE) 59 BCM2711_IOPHYSTOVIRT(BCM2711_ARM_LOCAL_BASE)
60 60
 61#define BCM2711_ARM_SMP_VBASE \
 62 BCM2711_IOPHYSTOVIRT(BCM2836_ARM_SMP_BASE)
 63
61#endif /* _ARM_BCM2835REG_PLATFORM_H_ */ 64#endif /* _ARM_BCM2835REG_PLATFORM_H_ */