Sat Mar 26 09:07:31 2016 UTC ()
Restore HOST1X and AHB_A2 to pmap_devmap to give pmap less work to do


(skrll)
diff -r1.20 -r1.21 src/sys/arch/arm/nvidia/tegra_reg.h
diff -r1.8 -r1.9 src/sys/arch/arm/nvidia/tegra_soc.c
diff -r1.37 -r1.38 src/sys/arch/evbarm/tegra/tegra_machdep.c

cvs diff -r1.20 -r1.21 src/sys/arch/arm/nvidia/tegra_reg.h (switch to unified diff)

--- src/sys/arch/arm/nvidia/tegra_reg.h 2015/11/21 22:55:32 1.20
+++ src/sys/arch/arm/nvidia/tegra_reg.h 2016/03/26 09:07:31 1.21
@@ -1,166 +1,168 @@ @@ -1,166 +1,168 @@
1/* $NetBSD: tegra_reg.h,v 1.20 2015/11/21 22:55:32 jmcneill Exp $ */ 1/* $NetBSD: tegra_reg.h,v 1.21 2016/03/26 09:07:31 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 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#ifndef _ARM_TEGRA_REG_H 29#ifndef _ARM_TEGRA_REG_H
30#define _ARM_TEGRA_REG_H 30#define _ARM_TEGRA_REG_H
31 31
32#define CONSADDR_VA (CONSADDR - TEGRA_APB_BASE + TEGRA_APB_VBASE) 32#define CONSADDR_VA (CONSADDR - TEGRA_APB_BASE + TEGRA_APB_VBASE)
33 33
34#define TEGRA_EXTMEM_BASE 0x80000000 34#define TEGRA_EXTMEM_BASE 0x80000000
35 35
36#define TEGRA_PCIE_OFFSET 0x01000000 36#define TEGRA_PCIE_OFFSET 0x01000000
37#define TEGRA_PCIE_SIZE 0x3f000000 37#define TEGRA_PCIE_SIZE 0x3f000000
38#define TEGRA_PCIE_RPCONF_BASE 0x01000000 38#define TEGRA_PCIE_RPCONF_BASE 0x01000000
39#define TEGRA_PCIE_RPCONF_SIZE 0x00002000 39#define TEGRA_PCIE_RPCONF_SIZE 0x00002000
40#define TEGRA_PCIE_PADS_BASE 0x01003000 40#define TEGRA_PCIE_PADS_BASE 0x01003000
41#define TEGRA_PCIE_PADS_SIZE 0x00000800 41#define TEGRA_PCIE_PADS_SIZE 0x00000800
42#define TEGRA_PCIE_AFI_BASE 0x01003800 42#define TEGRA_PCIE_AFI_BASE 0x01003800
43#define TEGRA_PCIE_AFI_SIZE 0x00000800 43#define TEGRA_PCIE_AFI_SIZE 0x00000800
44#define TEGRA_PCIE_A1_BASE 0x01000000 44#define TEGRA_PCIE_A1_BASE 0x01000000
45#define TEGRA_PCIE_A1_SIZE 0x01000000 45#define TEGRA_PCIE_A1_SIZE 0x01000000
46#define TEGRA_PCIE_A2_BASE 0x02000000 46#define TEGRA_PCIE_A2_BASE 0x02000000
47#define TEGRA_PCIE_A2_SIZE 0x0e000000 47#define TEGRA_PCIE_A2_SIZE 0x0e000000
48#define TEGRA_PCIE_A3_BASE 0x10000000 48#define TEGRA_PCIE_A3_BASE 0x10000000
49#define TEGRA_PCIE_A3_SIZE 0x30000000 49#define TEGRA_PCIE_A3_SIZE 0x30000000
50 50
51#define TEGRA_PCIE_CONF_BASE 0x02000000 51#define TEGRA_PCIE_CONF_BASE 0x02000000
52#define TEGRA_PCIE_CONF_SIZE 0x01000000 52#define TEGRA_PCIE_CONF_SIZE 0x01000000
53#define TEGRA_PCIE_IO_BASE 0x01800000 /* comment in tegra_pcie.c */ 53#define TEGRA_PCIE_IO_BASE 0x01800000 /* comment in tegra_pcie.c */
54#define TEGRA_PCIE_IO_SIZE 0x00800000 54#define TEGRA_PCIE_IO_SIZE 0x00800000
55#define TEGRA_PCIE_MEM_BASE 0x03000000 55#define TEGRA_PCIE_MEM_BASE 0x03000000
56#define TEGRA_PCIE_MEM_SIZE 0x0d000000 56#define TEGRA_PCIE_MEM_SIZE 0x0d000000
57#define TEGRA_PCIE_EXTC_BASE 0x10000000 57#define TEGRA_PCIE_EXTC_BASE 0x10000000
58#define TEGRA_PCIE_EXTC_SIZE 0x10000000 58#define TEGRA_PCIE_EXTC_SIZE 0x10000000
59#define TEGRA_PCIE_PMEM_BASE 0x20000000 59#define TEGRA_PCIE_PMEM_BASE 0x20000000
60#define TEGRA_PCIE_PMEM_SIZE 0x20000000 60#define TEGRA_PCIE_PMEM_SIZE 0x20000000
61 61
62#define TEGRA_HOST1X_BASE 0x50000000 62#define TEGRA_HOST1X_BASE 0x50000000
63#define TEGRA_HOST1X_SIZE 0x00034000 63#define TEGRA_HOST1X_SIZE 0x00034000
64#define TEGRA_GHOST_BASE 0x54000000 64#define TEGRA_GHOST_BASE 0x54000000
65#define TEGRA_GHOST_SIZE 0x01000000 65#define TEGRA_GHOST_SIZE 0x01000000
66#define TEGRA_GPU_BASE 0x57000000 66#define TEGRA_GPU_BASE 0x57000000
67#define TEGRA_GPU_SIZE 0x02000000 67#define TEGRA_GPU_SIZE 0x02000000
68#define TEGRA_PPSB_BASE 0x60000000 68#define TEGRA_PPSB_BASE 0x60000000
69#define TEGRA_PPSB_SIZE 0x01000000 69#define TEGRA_PPSB_SIZE 0x01000000
70#define TEGRA_APB_BASE 0x70000000 70#define TEGRA_APB_BASE 0x70000000
71#define TEGRA_APB_SIZE 0x01000000 71#define TEGRA_APB_SIZE 0x01000000
72#define TEGRA_AHB_A2_BASE 0x7c000000 72#define TEGRA_AHB_A2_BASE 0x7c000000
73#define TEGRA_AHB_A2_SIZE 0x02000000 73#define TEGRA_AHB_A2_SIZE 0x02000000
74 74
75#define TEGRA_PPSB_VBASE 0xfd000000 75#define TEGRA_HOST1X_VBASE 0xfaf00000
76#define TEGRA_APB_VBASE 0xfe000000 76#define TEGRA_PPSB_VBASE 0xfb000000
 77#define TEGRA_APB_VBASE 0xfc000000
 78#define TEGRA_AHB_A2_VBASE 0xfd000000
77 79
78#define TEGRA_REF_FREQ 12000000 80#define TEGRA_REF_FREQ 12000000
79 81
80/* APB */ 82/* APB */
81#define TEGRA_MPIO_OFFSET 0x00000000 83#define TEGRA_MPIO_OFFSET 0x00000000
82#define TEGRA_MPIO_SIZE 0x4000 84#define TEGRA_MPIO_SIZE 0x4000
83#define TEGRA_UARTA_OFFSET 0x00006000 85#define TEGRA_UARTA_OFFSET 0x00006000
84#define TEGRA_UARTA_SIZE 0x40 86#define TEGRA_UARTA_SIZE 0x40
85#define TEGRA_UARTB_OFFSET 0x00006040 87#define TEGRA_UARTB_OFFSET 0x00006040
86#define TEGRA_UARTB_SIZE 0x40 88#define TEGRA_UARTB_SIZE 0x40
87#define TEGRA_UARTC_OFFSET 0x00006200 89#define TEGRA_UARTC_OFFSET 0x00006200
88#define TEGRA_UARTC_SIZE 0x100 90#define TEGRA_UARTC_SIZE 0x100
89#define TEGRA_UARTD_OFFSET 0x00006300 91#define TEGRA_UARTD_OFFSET 0x00006300
90#define TEGRA_UARTD_SIZE 0x100 92#define TEGRA_UARTD_SIZE 0x100
91#define TEGRA_I2C1_OFFSET 0x0000c000 93#define TEGRA_I2C1_OFFSET 0x0000c000
92#define TEGRA_I2C1_SIZE 0x100 94#define TEGRA_I2C1_SIZE 0x100
93#define TEGRA_I2C2_OFFSET 0x0000c400 95#define TEGRA_I2C2_OFFSET 0x0000c400
94#define TEGRA_I2C2_SIZE 0x100 96#define TEGRA_I2C2_SIZE 0x100
95#define TEGRA_I2C3_OFFSET 0x0000c500 97#define TEGRA_I2C3_OFFSET 0x0000c500
96#define TEGRA_I2C3_SIZE 0x100 98#define TEGRA_I2C3_SIZE 0x100
97#define TEGRA_I2C4_OFFSET 0x0000c700 99#define TEGRA_I2C4_OFFSET 0x0000c700
98#define TEGRA_I2C4_SIZE 0x100 100#define TEGRA_I2C4_SIZE 0x100
99#define TEGRA_I2C5_OFFSET 0x0000d000 101#define TEGRA_I2C5_OFFSET 0x0000d000
100#define TEGRA_I2C5_SIZE 0x100 102#define TEGRA_I2C5_SIZE 0x100
101#define TEGRA_I2C6_OFFSET 0x0000d100 103#define TEGRA_I2C6_OFFSET 0x0000d100
102#define TEGRA_I2C6_SIZE 0x100 104#define TEGRA_I2C6_SIZE 0x100
103#define TEGRA_RTC_OFFSET 0x0000e000 105#define TEGRA_RTC_OFFSET 0x0000e000
104#define TEGRA_RTC_SIZE 0x100 106#define TEGRA_RTC_SIZE 0x100
105#define TEGRA_KBC_OFFSET 0x0000e200 107#define TEGRA_KBC_OFFSET 0x0000e200
106#define TEGRA_KBC_SIZE 0x100 108#define TEGRA_KBC_SIZE 0x100
107#define TEGRA_PMC_OFFSET 0x0000e400 109#define TEGRA_PMC_OFFSET 0x0000e400
108#define TEGRA_PMC_SIZE 0x800 110#define TEGRA_PMC_SIZE 0x800
109#define TEGRA_FUSE_OFFSET 0x0000f800 111#define TEGRA_FUSE_OFFSET 0x0000f800
110#define TEGRA_FUSE_SIZE 0x00000400 112#define TEGRA_FUSE_SIZE 0x00000400
111#define TEGRA_CEC_OFFSET 0x00015000 113#define TEGRA_CEC_OFFSET 0x00015000
112#define TEGRA_CEC_SIZE 0x1000 114#define TEGRA_CEC_SIZE 0x1000
113#define TEGRA_MC_OFFSET 0x00019000 115#define TEGRA_MC_OFFSET 0x00019000
114#define TEGRA_MC_SIZE 0x1000 116#define TEGRA_MC_SIZE 0x1000
115#define TEGRA_SATA_OFFSET 0x00020000 117#define TEGRA_SATA_OFFSET 0x00020000
116#define TEGRA_SATA_SIZE 0x10000 118#define TEGRA_SATA_SIZE 0x10000
117#define TEGRA_HDA_OFFSET 0x00030000 119#define TEGRA_HDA_OFFSET 0x00030000
118#define TEGRA_HDA_SIZE 0x10000 120#define TEGRA_HDA_SIZE 0x10000
119#define TEGRA_XUSB_PADCTL_OFFSET 0x0009f000 121#define TEGRA_XUSB_PADCTL_OFFSET 0x0009f000
120#define TEGRA_XUSB_PADCTL_SIZE 0x1000 122#define TEGRA_XUSB_PADCTL_SIZE 0x1000
121#define TEGRA_XUSB_HOST_OFFSET 0x00090000 123#define TEGRA_XUSB_HOST_OFFSET 0x00090000
122#define TEGRA_XUSB_HOST_SIZE 0xa000 124#define TEGRA_XUSB_HOST_SIZE 0xa000
123#define TEGRA_SDMMC1_OFFSET 0x000b0000 125#define TEGRA_SDMMC1_OFFSET 0x000b0000
124#define TEGRA_SDMMC1_SIZE 0x200 126#define TEGRA_SDMMC1_SIZE 0x200
125#define TEGRA_SDMMC2_OFFSET 0x000b0200 127#define TEGRA_SDMMC2_OFFSET 0x000b0200
126#define TEGRA_SDMMC2_SIZE 0x200 128#define TEGRA_SDMMC2_SIZE 0x200
127#define TEGRA_SDMMC3_OFFSET 0x000b0400 129#define TEGRA_SDMMC3_OFFSET 0x000b0400
128#define TEGRA_SDMMC3_SIZE 0x200 130#define TEGRA_SDMMC3_SIZE 0x200
129#define TEGRA_SDMMC4_OFFSET 0x000b0600 131#define TEGRA_SDMMC4_OFFSET 0x000b0600
130#define TEGRA_SDMMC4_SIZE 0x200 132#define TEGRA_SDMMC4_SIZE 0x200
131#define TEGRA_XUSB_DEV_OFFSET 0x000d0000 133#define TEGRA_XUSB_DEV_OFFSET 0x000d0000
132#define TEGRA_XUSB_DEV_SIZE 0xa000 134#define TEGRA_XUSB_DEV_SIZE 0xa000
133#define TEGRA_SOC_THERM_OFFSET 0x000e2000 135#define TEGRA_SOC_THERM_OFFSET 0x000e2000
134#define TEGRA_SOC_THERM_SIZE 0x1000 136#define TEGRA_SOC_THERM_SIZE 0x1000
135 137
136/* PPSB */ 138/* PPSB */
137#define TEGRA_TIMER_OFFSET 0x00005000 139#define TEGRA_TIMER_OFFSET 0x00005000
138#define TEGRA_TIMER_SIZE 0x400 140#define TEGRA_TIMER_SIZE 0x400
139#define TEGRA_CAR_OFFSET 0x00006000 141#define TEGRA_CAR_OFFSET 0x00006000
140#define TEGRA_CAR_SIZE 0x1000 142#define TEGRA_CAR_SIZE 0x1000
141#define TEGRA_GPIO_OFFSET 0x0000d000 143#define TEGRA_GPIO_OFFSET 0x0000d000
142#define TEGRA_GPIO_SIZE 0x00000800 144#define TEGRA_GPIO_SIZE 0x00000800
143#define TEGRA_EVP_OFFSET 0x0000f000 145#define TEGRA_EVP_OFFSET 0x0000f000
144#define TEGRA_EVP_SIZE 0x1000 146#define TEGRA_EVP_SIZE 0x1000
145 147
146/* AHB_A2 */ 148/* AHB_A2 */
147#define TEGRA_USB1_OFFSET 0x01000000 149#define TEGRA_USB1_OFFSET 0x01000000
148#define TEGRA_USB1_SIZE 0x1800 150#define TEGRA_USB1_SIZE 0x1800
149#define TEGRA_USB2_OFFSET 0x01004000 151#define TEGRA_USB2_OFFSET 0x01004000
150#define TEGRA_USB2_SIZE 0x1800 152#define TEGRA_USB2_SIZE 0x1800
151#define TEGRA_USB3_OFFSET 0x01008000 153#define TEGRA_USB3_OFFSET 0x01008000
152#define TEGRA_USB3_SIZE 0x1800 154#define TEGRA_USB3_SIZE 0x1800
153 155
154/* Graphics Host (GHOST) */ 156/* Graphics Host (GHOST) */
155#define TEGRA_DISPLAYA_OFFSET 0x00200000 157#define TEGRA_DISPLAYA_OFFSET 0x00200000
156#define TEGRA_DISPLAYA_SIZE 0x00040000 158#define TEGRA_DISPLAYA_SIZE 0x00040000
157#define TEGRA_DISPLAYB_OFFSET 0x00240000 159#define TEGRA_DISPLAYB_OFFSET 0x00240000
158#define TEGRA_DISPLAYB_SIZE 0x00040000 160#define TEGRA_DISPLAYB_SIZE 0x00040000
159#define TEGRA_HDMI_OFFSET 0x00280000 161#define TEGRA_HDMI_OFFSET 0x00280000
160#define TEGRA_HDMI_SIZE 0x00040000 162#define TEGRA_HDMI_SIZE 0x00040000
161#define TEGRA_SOR_OFFSET 0x00540000 163#define TEGRA_SOR_OFFSET 0x00540000
162#define TEGRA_SOR_SIZE 0x00040000 164#define TEGRA_SOR_SIZE 0x00040000
163#define TEGRA_DPAUX_OFFSET 0x005c0000 165#define TEGRA_DPAUX_OFFSET 0x005c0000
164#define TEGRA_DPAUX_SIZE 0x00040000 166#define TEGRA_DPAUX_SIZE 0x00040000
165 167
166#endif /* _ARM_TEGRA_REG_H */ 168#endif /* _ARM_TEGRA_REG_H */

cvs diff -r1.8 -r1.9 src/sys/arch/arm/nvidia/tegra_soc.c (switch to unified diff)

--- src/sys/arch/arm/nvidia/tegra_soc.c 2015/12/22 22:10:36 1.8
+++ src/sys/arch/arm/nvidia/tegra_soc.c 2016/03/26 09:07:31 1.9
@@ -1,136 +1,146 @@ @@ -1,136 +1,146 @@
1/* $NetBSD: tegra_soc.c,v 1.8 2015/12/22 22:10:36 jmcneill Exp $ */ 1/* $NetBSD: tegra_soc.c,v 1.9 2016/03/26 09:07:31 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 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 "opt_tegra.h" 29#include "opt_tegra.h"
30#include "opt_multiprocessor.h" 30#include "opt_multiprocessor.h"
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: tegra_soc.c,v 1.8 2015/12/22 22:10:36 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: tegra_soc.c,v 1.9 2016/03/26 09:07:31 skrll Exp $");
34 34
35#define _ARM32_BUS_DMA_PRIVATE 35#define _ARM32_BUS_DMA_PRIVATE
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/bus.h> 37#include <sys/bus.h>
38#include <sys/cpu.h> 38#include <sys/cpu.h>
39#include <sys/device.h> 39#include <sys/device.h>
40 40
41#include <uvm/uvm_extern.h> 41#include <uvm/uvm_extern.h>
42 42
43#include <arm/bootconfig.h> 43#include <arm/bootconfig.h>
44#include <arm/cpufunc.h> 44#include <arm/cpufunc.h>
45 45
46#include <arm/nvidia/tegra_reg.h> 46#include <arm/nvidia/tegra_reg.h>
47#include <arm/nvidia/tegra_apbreg.h> 47#include <arm/nvidia/tegra_apbreg.h>
48#include <arm/nvidia/tegra_mcreg.h> 48#include <arm/nvidia/tegra_mcreg.h>
49#include <arm/nvidia/tegra_var.h> 49#include <arm/nvidia/tegra_var.h>
50 50
 51bus_space_handle_t tegra_host1x_bsh;
51bus_space_handle_t tegra_ppsb_bsh; 52bus_space_handle_t tegra_ppsb_bsh;
52bus_space_handle_t tegra_apb_bsh; 53bus_space_handle_t tegra_apb_bsh;
 54bus_space_handle_t tegra_ahb_a2_bsh;
53 55
54struct arm32_bus_dma_tag tegra_dma_tag = { 56struct arm32_bus_dma_tag tegra_dma_tag = {
55 _BUS_DMAMAP_FUNCS, 57 _BUS_DMAMAP_FUNCS,
56 _BUS_DMAMEM_FUNCS, 58 _BUS_DMAMEM_FUNCS,
57 _BUS_DMATAG_FUNCS, 59 _BUS_DMATAG_FUNCS,
58}; 60};
59 61
60static void tegra_mpinit(void); 62static void tegra_mpinit(void);
61 63
62void 64void
63tegra_bootstrap(void) 65tegra_bootstrap(void)
64{ 66{
65 if (bus_space_map(&armv7_generic_bs_tag, 67 if (bus_space_map(&armv7_generic_bs_tag,
 68 TEGRA_HOST1X_BASE, TEGRA_HOST1X_SIZE, 0,
 69 &tegra_host1x_bsh) != 0)
 70 panic("couldn't map HOST1X");
 71 if (bus_space_map(&armv7_generic_bs_tag,
66 TEGRA_PPSB_BASE, TEGRA_PPSB_SIZE, 0, 72 TEGRA_PPSB_BASE, TEGRA_PPSB_SIZE, 0,
67 &tegra_ppsb_bsh) != 0) 73 &tegra_ppsb_bsh) != 0)
68 panic("couldn't map PPSB"); 74 panic("couldn't map PPSB");
69 if (bus_space_map(&armv7_generic_bs_tag, 75 if (bus_space_map(&armv7_generic_bs_tag,
70 TEGRA_APB_BASE, TEGRA_APB_SIZE, 0, 76 TEGRA_APB_BASE, TEGRA_APB_SIZE, 0,
71 &tegra_apb_bsh) != 0) 77 &tegra_apb_bsh) != 0)
72 panic("couldn't map APB"); 78 panic("couldn't map APB");
 79 if (bus_space_map(&armv7_generic_bs_tag,
 80 TEGRA_AHB_A2_BASE, TEGRA_AHB_A2_SIZE, 0,
 81 &tegra_ahb_a2_bsh) != 0)
 82 panic("couldn't map AHB A2");
73 83
74 tegra_mpinit(); 84 tegra_mpinit();
75} 85}
76 86
77void 87void
78tegra_dma_bootstrap(psize_t psize) 88tegra_dma_bootstrap(psize_t psize)
79{ 89{
80} 90}
81 91
82void 92void
83tegra_cpuinit(void) 93tegra_cpuinit(void)
84{ 94{
85 switch (tegra_chip_id()) { 95 switch (tegra_chip_id()) {
86#ifdef SOC_TEGRA124 96#ifdef SOC_TEGRA124
87 case CHIP_ID_TEGRA124: 97 case CHIP_ID_TEGRA124:
88 tegra124_cpuinit(); 98 tegra124_cpuinit();
89 break; 99 break;
90#endif 100#endif
91 } 101 }
92 102
93 tegra_cpufreq_init(); 103 tegra_cpufreq_init();
94} 104}
95 105
96static void 106static void
97tegra_mpinit(void) 107tegra_mpinit(void)
98{ 108{
99#if defined(MULTIPROCESSOR) 109#if defined(MULTIPROCESSOR)
100 switch (tegra_chip_id()) { 110 switch (tegra_chip_id()) {
101#ifdef SOC_TEGRA124 111#ifdef SOC_TEGRA124
102 case CHIP_ID_TEGRA124: 112 case CHIP_ID_TEGRA124:
103 tegra124_mpinit(); 113 tegra124_mpinit();
104 break; 114 break;
105#endif 115#endif
106 default: 116 default:
107 panic("Unsupported SOC ID %#x", tegra_chip_id()); 117 panic("Unsupported SOC ID %#x", tegra_chip_id());
108 } 118 }
109#endif 119#endif
110} 120}
111 121
112u_int 122u_int
113tegra_chip_id(void) 123tegra_chip_id(void)
114{ 124{
115 static u_int chip_id = 0; 125 static u_int chip_id = 0;
116 126
117 if (!chip_id) { 127 if (!chip_id) {
118 const bus_space_tag_t bst = &armv7_generic_bs_tag; 128 const bus_space_tag_t bst = &armv7_generic_bs_tag;
119 const bus_space_handle_t bsh = tegra_apb_bsh; 129 const bus_space_handle_t bsh = tegra_apb_bsh;
120 const uint32_t v = bus_space_read_4(bst, bsh, 130 const uint32_t v = bus_space_read_4(bst, bsh,
121 APB_MISC_GP_HIDREV_0_REG); 131 APB_MISC_GP_HIDREV_0_REG);
122 chip_id = __SHIFTOUT(v, APB_MISC_GP_HIDREV_0_CHIPID); 132 chip_id = __SHIFTOUT(v, APB_MISC_GP_HIDREV_0_CHIPID);
123 } 133 }
124 134
125 return chip_id; 135 return chip_id;
126} 136}
127 137
128const char * 138const char *
129tegra_chip_name(void) 139tegra_chip_name(void)
130{ 140{
131 switch (tegra_chip_id()) { 141 switch (tegra_chip_id()) {
132 case CHIP_ID_TEGRA124: return "Tegra K1 (T124)"; 142 case CHIP_ID_TEGRA124: return "Tegra K1 (T124)";
133 case CHIP_ID_TEGRA132: return "Tegra K1 (T132)"; 143 case CHIP_ID_TEGRA132: return "Tegra K1 (T132)";
134 default: return "Unknown Tegra SoC"; 144 default: return "Unknown Tegra SoC";
135 } 145 }
136} 146}

cvs diff -r1.37 -r1.38 src/sys/arch/evbarm/tegra/Attic/tegra_machdep.c (switch to unified diff)

--- src/sys/arch/evbarm/tegra/Attic/tegra_machdep.c 2015/12/22 22:10:36 1.37
+++ src/sys/arch/evbarm/tegra/Attic/tegra_machdep.c 2016/03/26 09:07:31 1.38
@@ -1,523 +1,537 @@ @@ -1,523 +1,537 @@
1/* $NetBSD: tegra_machdep.c,v 1.37 2015/12/22 22:10:36 jmcneill Exp $ */ 1/* $NetBSD: tegra_machdep.c,v 1.38 2016/03/26 09:07:31 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 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: tegra_machdep.c,v 1.37 2015/12/22 22:10:36 jmcneill Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.38 2016/03/26 09:07:31 skrll Exp $");
31 31
32#include "opt_tegra.h" 32#include "opt_tegra.h"
33#include "opt_machdep.h" 33#include "opt_machdep.h"
34#include "opt_ddb.h" 34#include "opt_ddb.h"
35#include "opt_md.h" 35#include "opt_md.h"
36#include "opt_arm_debug.h" 36#include "opt_arm_debug.h"
37#include "opt_multiprocessor.h" 37#include "opt_multiprocessor.h"
38 38
39#include "com.h" 39#include "com.h"
40#include "ukbd.h" 40#include "ukbd.h"
41#include "genfb.h" 41#include "genfb.h"
42#include "ether.h" 42#include "ether.h"
43#include "as3722pmic.h" 43#include "as3722pmic.h"
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/systm.h> 46#include <sys/systm.h>
47#include <sys/bus.h> 47#include <sys/bus.h>
48#include <sys/atomic.h> 48#include <sys/atomic.h>
49#include <sys/cpu.h> 49#include <sys/cpu.h>
50#include <sys/device.h> 50#include <sys/device.h>
51#include <sys/exec.h> 51#include <sys/exec.h>
52#include <sys/kernel.h> 52#include <sys/kernel.h>
53#include <sys/kmem.h> 53#include <sys/kmem.h>
54#include <sys/ksyms.h> 54#include <sys/ksyms.h>
55#include <sys/msgbuf.h> 55#include <sys/msgbuf.h>
56#include <sys/proc.h> 56#include <sys/proc.h>
57#include <sys/reboot.h> 57#include <sys/reboot.h>
58#include <sys/termios.h> 58#include <sys/termios.h>
59#include <sys/gpio.h> 59#include <sys/gpio.h>
60 60
61#include <uvm/uvm_extern.h> 61#include <uvm/uvm_extern.h>
62 62
63#include <sys/conf.h> 63#include <sys/conf.h>
64#include <dev/cons.h> 64#include <dev/cons.h>
65#include <dev/md.h> 65#include <dev/md.h>
66 66
67#include <machine/db_machdep.h> 67#include <machine/db_machdep.h>
68#include <ddb/db_sym.h> 68#include <ddb/db_sym.h>
69#include <ddb/db_extern.h> 69#include <ddb/db_extern.h>
70 70
71#include <machine/bootconfig.h> 71#include <machine/bootconfig.h>
72#include <arm/armreg.h> 72#include <arm/armreg.h>
73#include <arm/undefined.h> 73#include <arm/undefined.h>
74 74
75#include <arm/arm32/machdep.h> 75#include <arm/arm32/machdep.h>
76#include <arm/mainbus/mainbus.h> 76#include <arm/mainbus/mainbus.h>
77 77
78#include <arm/nvidia/tegra_reg.h> 78#include <arm/nvidia/tegra_reg.h>
79#include <arm/nvidia/tegra_var.h> 79#include <arm/nvidia/tegra_var.h>
80 80
81#include <arm/cortex/gtmr_var.h> 81#include <arm/cortex/gtmr_var.h>
82 82
83#include <evbarm/include/autoconf.h> 83#include <evbarm/include/autoconf.h>
84#include <evbarm/tegra/platform.h> 84#include <evbarm/tegra/platform.h>
85 85
86#include <dev/ic/ns16550reg.h> 86#include <dev/ic/ns16550reg.h>
87#include <dev/ic/comreg.h> 87#include <dev/ic/comreg.h>
88#include <dev/ic/comvar.h> 88#include <dev/ic/comvar.h>
89 89
90#include <dev/usb/ukbdvar.h> 90#include <dev/usb/ukbdvar.h>
91#include <net/if_ether.h> 91#include <net/if_ether.h>
92 92
93#if NAS3722PMIC > 0 93#if NAS3722PMIC > 0
94#include <dev/i2c/as3722.h> 94#include <dev/i2c/as3722.h>
95#endif 95#endif
96 96
97#ifndef TEGRA_MAX_BOOT_STRING 97#ifndef TEGRA_MAX_BOOT_STRING
98#define TEGRA_MAX_BOOT_STRING 1024 98#define TEGRA_MAX_BOOT_STRING 1024
99#endif 99#endif
100 100
101BootConfig bootconfig; 101BootConfig bootconfig;
102char bootargs[TEGRA_MAX_BOOT_STRING] = ""; 102char bootargs[TEGRA_MAX_BOOT_STRING] = "";
103char *boot_args = NULL; 103char *boot_args = NULL;
104u_int uboot_args[4] = { 0 }; /* filled in by tegra_start.S (not in bss) */ 104u_int uboot_args[4] = { 0 }; /* filled in by tegra_start.S (not in bss) */
105 105
106#include <libfdt.h> 106#include <libfdt.h>
107#include <dev/fdt/fdtvar.h> 107#include <dev/fdt/fdtvar.h>
108#define FDT_BUF_SIZE (128*1024) 108#define FDT_BUF_SIZE (128*1024)
109static uint8_t fdt_data[FDT_BUF_SIZE]; 109static uint8_t fdt_data[FDT_BUF_SIZE];
110 110
111extern char KERNEL_BASE_phys[]; 111extern char KERNEL_BASE_phys[];
112#define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys) 112#define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
113 113
114static void tegra_device_register(device_t, void *); 114static void tegra_device_register(device_t, void *);
115static void tegra_reset(void); 115static void tegra_reset(void);
116static void tegra_powerdown(void); 116static void tegra_powerdown(void);
117 117
118bs_protos(bs_notimpl); 118bs_protos(bs_notimpl);
119 119
120#define _A(a) ((a) & ~L1_S_OFFSET) 120#define _A(a) ((a) & ~L1_S_OFFSET)
121#define _S(s) (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1)) 121#define _S(s) (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
122 122
123static const struct pmap_devmap devmap[] = { 123static const struct pmap_devmap devmap[] = {
124 { 124 {
 125 .pd_va = _A(TEGRA_HOST1X_VBASE),
 126 .pd_pa = _A(TEGRA_HOST1X_BASE),
 127 .pd_size = _S(TEGRA_HOST1X_SIZE),
 128 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
 129 .pd_cache = PTE_NOCACHE
 130 },
 131 {
125 .pd_va = _A(TEGRA_PPSB_VBASE), 132 .pd_va = _A(TEGRA_PPSB_VBASE),
126 .pd_pa = _A(TEGRA_PPSB_BASE), 133 .pd_pa = _A(TEGRA_PPSB_BASE),
127 .pd_size = _S(TEGRA_PPSB_SIZE), 134 .pd_size = _S(TEGRA_PPSB_SIZE),
128 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 135 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
129 .pd_cache = PTE_NOCACHE 136 .pd_cache = PTE_NOCACHE
130 }, 137 },
131 { 138 {
132 .pd_va = _A(TEGRA_APB_VBASE), 139 .pd_va = _A(TEGRA_APB_VBASE),
133 .pd_pa = _A(TEGRA_APB_BASE), 140 .pd_pa = _A(TEGRA_APB_BASE),
134 .pd_size = _S(TEGRA_APB_SIZE), 141 .pd_size = _S(TEGRA_APB_SIZE),
135 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 142 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
136 .pd_cache = PTE_NOCACHE 143 .pd_cache = PTE_NOCACHE
137 }, 144 },
 145 {
 146 .pd_va = _A(TEGRA_AHB_A2_VBASE),
 147 .pd_pa = _A(TEGRA_AHB_A2_BASE),
 148 .pd_size = _S(TEGRA_AHB_A2_SIZE),
 149 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
 150 .pd_cache = PTE_NOCACHE
 151 },
138 {0} 152 {0}
139}; 153};
140 154
141#undef _A 155#undef _A
142#undef _S 156#undef _S
143 157
144#ifdef PMAP_NEED_ALLOC_POOLPAGE 158#ifdef PMAP_NEED_ALLOC_POOLPAGE
145static struct boot_physmem bp_lowgig = { 159static struct boot_physmem bp_lowgig = {
146 .bp_start = TEGRA_EXTMEM_BASE / NBPG, 160 .bp_start = TEGRA_EXTMEM_BASE / NBPG,
147 .bp_pages = (KERNEL_VM_BASE - KERNEL_BASE) / NBPG, 161 .bp_pages = (KERNEL_VM_BASE - KERNEL_BASE) / NBPG,
148 .bp_freelist = VM_FREELIST_ISADMA, 162 .bp_freelist = VM_FREELIST_ISADMA,
149 .bp_flags = 0 163 .bp_flags = 0
150}; 164};
151#endif 165#endif
152 166
153#ifdef VERBOSE_INIT_ARM 167#ifdef VERBOSE_INIT_ARM
154static void 168static void
155tegra_putchar(char c) 169tegra_putchar(char c)
156{ 170{
157 volatile uint32_t *uartaddr = (volatile uint32_t *)CONSADDR_VA; 171 volatile uint32_t *uartaddr = (volatile uint32_t *)CONSADDR_VA;
158 int timo = 150000; 172 int timo = 150000;
159 173
160 while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) { 174 while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) {
161 if (--timo == 0) 175 if (--timo == 0)
162 break; 176 break;
163 } 177 }
164 178
165 uartaddr[com_data] = c; 179 uartaddr[com_data] = c;
166 180
167 while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) { 181 while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) {
168 if (--timo == 0) 182 if (--timo == 0)
169 break; 183 break;
170 } 184 }
171} 185}
172static void 186static void
173tegra_putstr(const char *s) 187tegra_putstr(const char *s)
174{ 188{
175 for (const char *p = s; *p; p++) { 189 for (const char *p = s; *p; p++) {
176 tegra_putchar(*p); 190 tegra_putchar(*p);
177 } 191 }
178} 192}
179 193
180static void 194static void
181tegra_printn(u_int n, int base) 195tegra_printn(u_int n, int base)
182{ 196{
183 char *p, buf[(sizeof(u_int) * NBBY / 3) + 1 + 2 /* ALT + SIGN */]; 197 char *p, buf[(sizeof(u_int) * NBBY / 3) + 1 + 2 /* ALT + SIGN */];
184 198
185 p = buf; 199 p = buf;
186 do { 200 do {
187 *p++ = hexdigits[n % base]; 201 *p++ = hexdigits[n % base];
188 } while (n /= base); 202 } while (n /= base);
189 203
190 do { 204 do {
191 tegra_putchar(*--p); 205 tegra_putchar(*--p);
192 } while (p > buf); 206 } while (p > buf);
193} 207}
194#define DPRINTF(...) printf(__VA_ARGS__) 208#define DPRINTF(...) printf(__VA_ARGS__)
195#define DPRINT(x) tegra_putstr(x) 209#define DPRINT(x) tegra_putstr(x)
196#define DPRINTN(x,b) tegra_printn((x), (b)) 210#define DPRINTN(x,b) tegra_printn((x), (b))
197#else 211#else
198#define DPRINTF(...) 212#define DPRINTF(...)
199#define DPRINT(x) 213#define DPRINT(x)
200#define DPRINTN(x,b) 214#define DPRINTN(x,b)
201#endif 215#endif
202 216
203extern void cortex_mpstart(void); 217extern void cortex_mpstart(void);
204 218
205/* 219/*
206 * u_int initarm(...) 220 * u_int initarm(...)
207 * 221 *
208 * Initial entry point on startup. This gets called before main() is 222 * Initial entry point on startup. This gets called before main() is
209 * entered. 223 * entered.
210 * It should be responsible for setting up everything that must be 224 * It should be responsible for setting up everything that must be
211 * in place when main is called. 225 * in place when main is called.
212 * This includes 226 * This includes
213 * Taking a copy of the boot configuration structure. 227 * Taking a copy of the boot configuration structure.
214 * Initialising the physical console so characters can be printed. 228 * Initialising the physical console so characters can be printed.
215 * Setting up page tables for the kernel 229 * Setting up page tables for the kernel
216 * Relocating the kernel to the bottom of physical memory 230 * Relocating the kernel to the bottom of physical memory
217 */ 231 */
218u_int 232u_int
219initarm(void *arg) 233initarm(void *arg)
220{ 234{
221 psize_t ram_size = 0; 235 psize_t ram_size = 0;
222 DPRINT("initarm:"); 236 DPRINT("initarm:");
223 237
224 DPRINT(" mpstart<0x"); 238 DPRINT(" mpstart<0x");
225 DPRINTN((uint32_t)cortex_mpstart, 16); 239 DPRINTN((uint32_t)cortex_mpstart, 16);
226 DPRINT(">"); 240 DPRINT(">");
227 241
228 DPRINT(" devmap"); 242 DPRINT(" devmap");
229 pmap_devmap_register(devmap); 243 pmap_devmap_register(devmap);
230 244
231 DPRINT(" bootstrap"); 245 DPRINT(" bootstrap");
232 tegra_bootstrap(); 246 tegra_bootstrap();
233 247
234 /* Heads up ... Setup the CPU / MMU / TLB functions. */ 248 /* Heads up ... Setup the CPU / MMU / TLB functions. */
235 DPRINT(" cpufunc"); 249 DPRINT(" cpufunc");
236 if (set_cpufuncs()) 250 if (set_cpufuncs())
237 panic("cpu not recognized!"); 251 panic("cpu not recognized!");
238 252
239 DPRINT(" consinit"); 253 DPRINT(" consinit");
240 consinit(); 254 consinit();
241 255
242 DPRINTF(" cbar=%#x", armreg_cbar_read()); 256 DPRINTF(" cbar=%#x", armreg_cbar_read());
243 257
244 DPRINTF(" ok\n"); 258 DPRINTF(" ok\n");
245 259
246 DPRINTF("uboot: args %#x, %#x, %#x, %#x\n", 260 DPRINTF("uboot: args %#x, %#x, %#x, %#x\n",
247 uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]); 261 uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]);
248 262
249 cpu_reset_address = tegra_reset; 263 cpu_reset_address = tegra_reset;
250 cpu_powerdown_address = tegra_powerdown; 264 cpu_powerdown_address = tegra_powerdown;
251 265
252 /* Talk to the user */ 266 /* Talk to the user */
253 DPRINTF("\nNetBSD/evbarm (tegra) booting ...\n"); 267 DPRINTF("\nNetBSD/evbarm (tegra) booting ...\n");
254 268
255#ifdef BOOT_ARGS 269#ifdef BOOT_ARGS
256 char mi_bootargs[] = BOOT_ARGS; 270 char mi_bootargs[] = BOOT_ARGS;
257 parse_mi_bootargs(mi_bootargs); 271 parse_mi_bootargs(mi_bootargs);
258#endif 272#endif
259 273
260 const uint8_t *fdt_addr_r = (const uint8_t *)uboot_args[2]; 274 const uint8_t *fdt_addr_r = (const uint8_t *)uboot_args[2];
261 int error = fdt_check_header(fdt_addr_r); 275 int error = fdt_check_header(fdt_addr_r);
262 if (error == 0) { 276 if (error == 0) {
263 error = fdt_move(fdt_addr_r, fdt_data, sizeof(fdt_data)); 277 error = fdt_move(fdt_addr_r, fdt_data, sizeof(fdt_data));
264 if (error != 0) { 278 if (error != 0) {
265 panic("fdt_move failed: %s", fdt_strerror(error)); 279 panic("fdt_move failed: %s", fdt_strerror(error));
266 } 280 }
267 fdtbus_set_data(fdt_data); 281 fdtbus_set_data(fdt_data);
268 } else { 282 } else {
269 panic("fdt_check_header failed: %s", fdt_strerror(error)); 283 panic("fdt_check_header failed: %s", fdt_strerror(error));
270 } 284 }
271 285
272 const u_int chip_id = tegra_chip_id(); 286 const u_int chip_id = tegra_chip_id();
273 switch (chip_id) { 287 switch (chip_id) {
274#ifdef SOC_TEGRA124 288#ifdef SOC_TEGRA124
275 case CHIP_ID_TEGRA124: { 289 case CHIP_ID_TEGRA124: {
276 const char * const tegra124_compatible_strings[] = { 290 const char * const tegra124_compatible_strings[] = {
277 "nvidia,tegra124", 291 "nvidia,tegra124",
278 NULL 292 NULL
279 }; 293 };
280 const int node = OF_peer(0); 294 const int node = OF_peer(0);
281 if (of_compatible(node, tegra124_compatible_strings) < 0) { 295 if (of_compatible(node, tegra124_compatible_strings) < 0) {
282 panic("FDT is not compatible with Tegra124"); 296 panic("FDT is not compatible with Tegra124");
283 } 297 }
284 break; 298 break;
285 } 299 }
286#endif 300#endif
287 default: 301 default:
288 panic("Kernel does not support Tegra SOC ID %#x", chip_id); 302 panic("Kernel does not support Tegra SOC ID %#x", chip_id);
289 } 303 }
290 304
291 DPRINTF("KERNEL_BASE=0x%x, KERNEL_VM_BASE=0x%x, KERNEL_VM_BASE - KERNEL_BASE=0x%x, KERNEL_BASE_VOFFSET=0x%x\n", 305 DPRINTF("KERNEL_BASE=0x%x, KERNEL_VM_BASE=0x%x, KERNEL_VM_BASE - KERNEL_BASE=0x%x, KERNEL_BASE_VOFFSET=0x%x\n",
292 KERNEL_BASE, KERNEL_VM_BASE, KERNEL_VM_BASE - KERNEL_BASE, KERNEL_BASE_VOFFSET); 306 KERNEL_BASE, KERNEL_VM_BASE, KERNEL_VM_BASE - KERNEL_BASE, KERNEL_BASE_VOFFSET);
293 307
294 ram_size = tegra_mc_memsize(); 308 ram_size = tegra_mc_memsize();
295 309
296#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS 310#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
297 const bool mapallmem_p = true; 311 const bool mapallmem_p = true;
298#ifndef PMAP_NEED_ALLOC_POOLPAGE 312#ifndef PMAP_NEED_ALLOC_POOLPAGE
299 if (ram_size > KERNEL_VM_BASE - KERNEL_BASE) { 313 if (ram_size > KERNEL_VM_BASE - KERNEL_BASE) {
300 printf("%s: dropping RAM size from %luMB to %uMB\n", 314 printf("%s: dropping RAM size from %luMB to %uMB\n",
301 __func__, (unsigned long) (ram_size >> 20),  315 __func__, (unsigned long) (ram_size >> 20),
302 (KERNEL_VM_BASE - KERNEL_BASE) >> 20); 316 (KERNEL_VM_BASE - KERNEL_BASE) >> 20);
303 ram_size = KERNEL_VM_BASE - KERNEL_BASE; 317 ram_size = KERNEL_VM_BASE - KERNEL_BASE;
304 } 318 }
305#endif 319#endif
306#else 320#else
307 const bool mapallmem_p = false; 321 const bool mapallmem_p = false;
308#endif 322#endif
309 323
310 /* 324 /*
311 * If MEMSIZE specified less than what we really have, limit ourselves 325 * If MEMSIZE specified less than what we really have, limit ourselves
312 * to that. 326 * to that.
313 */ 327 */
314#ifdef MEMSIZE 328#ifdef MEMSIZE
315 if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024) 329 if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024)
316 ram_size = (unsigned)MEMSIZE * 1024 * 1024; 330 ram_size = (unsigned)MEMSIZE * 1024 * 1024;
317 DPRINTF("ram_size = 0x%x\n", (int)ram_size); 331 DPRINTF("ram_size = 0x%x\n", (int)ram_size);
318#else 332#else
319 KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined"); 333 KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined");
320#endif 334#endif
321 335
322 /* DMA tag setup */ 336 /* DMA tag setup */
323 tegra_dma_bootstrap(ram_size); 337 tegra_dma_bootstrap(ram_size);
324 338
325 /* Fake bootconfig structure for the benefit of pmap.c. */ 339 /* Fake bootconfig structure for the benefit of pmap.c. */
326 bootconfig.dramblocks = 1; 340 bootconfig.dramblocks = 1;
327 bootconfig.dram[0].address = TEGRA_EXTMEM_BASE; /* DDR PHY addr */ 341 bootconfig.dram[0].address = TEGRA_EXTMEM_BASE; /* DDR PHY addr */
328 bootconfig.dram[0].pages = ram_size / PAGE_SIZE; 342 bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
329 343
330 KASSERT((armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0); 344 KASSERT((armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0);
331 345
332 arm32_bootmem_init(bootconfig.dram[0].address, ram_size, 346 arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
333 KERNEL_BASE_PHYS); 347 KERNEL_BASE_PHYS);
334 arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0, devmap, 348 arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0, devmap,
335 mapallmem_p); 349 mapallmem_p);
336 350
337 const int chosen = OF_finddevice("/chosen"); 351 const int chosen = OF_finddevice("/chosen");
338 if (chosen >= 0) { 352 if (chosen >= 0) {
339 OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs)); 353 OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
340 } 354 }
341 355
342 DPRINTF("bootargs: %s\n", bootargs); 356 DPRINTF("bootargs: %s\n", bootargs);
343 357
344 boot_args = bootargs; 358 boot_args = bootargs;
345 parse_mi_bootargs(boot_args); 359 parse_mi_bootargs(boot_args);
346 360
347 evbarm_device_register = tegra_device_register; 361 evbarm_device_register = tegra_device_register;
348 362
349#ifdef PMAP_NEED_ALLOC_POOLPAGE 363#ifdef PMAP_NEED_ALLOC_POOLPAGE
350 if (atop(ram_size) > bp_lowgig.bp_pages) { 364 if (atop(ram_size) > bp_lowgig.bp_pages) {
351 arm_poolpage_vmfreelist = bp_lowgig.bp_freelist; 365 arm_poolpage_vmfreelist = bp_lowgig.bp_freelist;
352 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, 366 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE,
353 &bp_lowgig, 1); 367 &bp_lowgig, 1);
354 } 368 }
355#endif 369#endif
356 370
357 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0); 371 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
358 372
359} 373}
360 374
361#if NCOM > 0 375#if NCOM > 0
362#ifndef CONSADDR 376#ifndef CONSADDR
363#error Specify the address of the console UART with the CONSADDR option. 377#error Specify the address of the console UART with the CONSADDR option.
364#endif 378#endif
365#ifndef CONSPEED 379#ifndef CONSPEED
366#define CONSPEED 115200 380#define CONSPEED 115200
367#endif 381#endif
368#ifndef CONMODE 382#ifndef CONMODE
369#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 383#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
370#endif 384#endif
371#endif 385#endif
372 386
373void 387void
374consinit(void) 388consinit(void)
375{ 389{
376 static bool consinit_called = false; 390 static bool consinit_called = false;
377 391
378 if (consinit_called) 392 if (consinit_called)
379 return; 393 return;
380 consinit_called = true; 394 consinit_called = true;
381 395
382#if NCOM > 0 396#if NCOM > 0
383 const bus_space_tag_t bst = &armv7_generic_a4x_bs_tag; 397 const bus_space_tag_t bst = &armv7_generic_a4x_bs_tag;
384 const u_int freq = 408000000; /* 408MHz PLLP_OUT0 */ 398 const u_int freq = 408000000; /* 408MHz PLLP_OUT0 */
385 if (comcnattach(bst, CONSADDR, CONSPEED, freq, 399 if (comcnattach(bst, CONSADDR, CONSPEED, freq,
386 COM_TYPE_TEGRA, CONMODE)) { 400 COM_TYPE_TEGRA, CONMODE)) {
387 panic("Serial console cannot be initialized."); 401 panic("Serial console cannot be initialized.");
388 } 402 }
389#else 403#else
390#error only COM console is supported 404#error only COM console is supported
391#endif 405#endif
392} 406}
393 407
394static bool 408static bool
395tegra_bootconf_match(const char *key, const char *val) 409tegra_bootconf_match(const char *key, const char *val)
396{ 410{
397 char *s; 411 char *s;
398 412
399 if (!get_bootconf_option(boot_args, key, BOOTOPT_TYPE_STRING, &s)) 413 if (!get_bootconf_option(boot_args, key, BOOTOPT_TYPE_STRING, &s))
400 return false; 414 return false;
401 415
402 return strncmp(s, val, strlen(val)) == 0; 416 return strncmp(s, val, strlen(val)) == 0;
403} 417}
404 418
405static char * 419static char *
406tegra_bootconf_strdup(const char *key) 420tegra_bootconf_strdup(const char *key)
407{ 421{
408 char *s, *ret; 422 char *s, *ret;
409 int i = 0; 423 int i = 0;
410 424
411 if (!get_bootconf_option(boot_args, key, BOOTOPT_TYPE_STRING, &s)) 425 if (!get_bootconf_option(boot_args, key, BOOTOPT_TYPE_STRING, &s))
412 return NULL; 426 return NULL;
413 427
414 for (;;) { 428 for (;;) {
415 if (s[i] == ' ' || s[i] == '\t' || s[i] == '\0') 429 if (s[i] == ' ' || s[i] == '\t' || s[i] == '\0')
416 break; 430 break;
417 ++i; 431 ++i;
418 } 432 }
419 433
420 ret = kmem_alloc(i + 1, KM_SLEEP); 434 ret = kmem_alloc(i + 1, KM_SLEEP);
421 if (ret == NULL) 435 if (ret == NULL)
422 return NULL; 436 return NULL;
423 437
424 strlcpy(ret, s, i + 1); 438 strlcpy(ret, s, i + 1);
425 return ret; 439 return ret;
426} 440}
427 441
428void 442void
429tegra_device_register(device_t self, void *aux) 443tegra_device_register(device_t self, void *aux)
430{ 444{
431 prop_dictionary_t dict = device_properties(self); 445 prop_dictionary_t dict = device_properties(self);
432 446
433 if (device_is_a(self, "armperiph") 447 if (device_is_a(self, "armperiph")
434 && device_is_a(device_parent(self), "mainbus")) { 448 && device_is_a(device_parent(self), "mainbus")) {
435 struct mainbus_attach_args * const mb = aux; 449 struct mainbus_attach_args * const mb = aux;
436 mb->mb_iot = &armv7_generic_bs_tag; 450 mb->mb_iot = &armv7_generic_bs_tag;
437 return; 451 return;
438 } 452 }
439 453
440 if (device_is_a(self, "armgtmr")) { 454 if (device_is_a(self, "armgtmr")) {
441 prop_dictionary_set_uint32(dict, "frequency", TEGRA_REF_FREQ); 455 prop_dictionary_set_uint32(dict, "frequency", TEGRA_REF_FREQ);
442 return; 456 return;
443 } 457 }
444 458
445 if (device_is_a(self, "tegrafb") 459 if (device_is_a(self, "tegrafb")
446 && tegra_bootconf_match("console", "fb")) { 460 && tegra_bootconf_match("console", "fb")) {
447 prop_dictionary_set_bool(dict, "is_console", true); 461 prop_dictionary_set_bool(dict, "is_console", true);
448#if NUKBD > 0 462#if NUKBD > 0
449 ukbd_cnattach(); 463 ukbd_cnattach();
450#endif 464#endif
451 } 465 }
452 466
453 if (device_is_a(self, "tegradrm")) { 467 if (device_is_a(self, "tegradrm")) {
454 const char *video = tegra_bootconf_strdup("video"); 468 const char *video = tegra_bootconf_strdup("video");
455 469
456 if (tegra_bootconf_match("hdmi.forcemode", "dvi")) { 470 if (tegra_bootconf_match("hdmi.forcemode", "dvi")) {
457 prop_dictionary_set_bool(dict, "force-dvi", true); 471 prop_dictionary_set_bool(dict, "force-dvi", true);
458 } 472 }
459 473
460 if (video) { 474 if (video) {
461 prop_dictionary_set_cstring(dict, "HDMI-A-1", video); 475 prop_dictionary_set_cstring(dict, "HDMI-A-1", video);
462 } 476 }
463 } 477 }
464 478
465 if (device_is_a(self, "tegracec")) { 479 if (device_is_a(self, "tegracec")) {
466 prop_dictionary_set_cstring(dict, "hdmi-device", "tegradrm0"); 480 prop_dictionary_set_cstring(dict, "hdmi-device", "tegradrm0");
467 } 481 }
468 482
469 if (device_is_a(self, "nouveau")) { 483 if (device_is_a(self, "nouveau")) {
470 const char *config = tegra_bootconf_strdup("nouveau.config"); 484 const char *config = tegra_bootconf_strdup("nouveau.config");
471 const char *debug = tegra_bootconf_strdup("nouveau.debug"); 485 const char *debug = tegra_bootconf_strdup("nouveau.debug");
472 if (config) 486 if (config)
473 prop_dictionary_set_cstring(dict, "config", config); 487 prop_dictionary_set_cstring(dict, "config", config);
474 if (debug) 488 if (debug)
475 prop_dictionary_set_cstring(dict, "debug", debug); 489 prop_dictionary_set_cstring(dict, "debug", debug);
476 } 490 }
477 491
478 if (device_is_a(self, "tegrapcie")) { 492 if (device_is_a(self, "tegrapcie")) {
479 const char * const jetsontk1_compat[] = { 493 const char * const jetsontk1_compat[] = {
480 "nvidia,jetson-tk1", NULL 494 "nvidia,jetson-tk1", NULL
481 }; 495 };
482 int phandle = OF_peer(0); 496 int phandle = OF_peer(0);
483 if (of_match_compatible(phandle, jetsontk1_compat)) { 497 if (of_match_compatible(phandle, jetsontk1_compat)) {
484 /* rfkill GPIO at GPIO X7 */ 498 /* rfkill GPIO at GPIO X7 */
485 struct tegra_gpio_pin *pin; 499 struct tegra_gpio_pin *pin;
486 pin = tegra_gpio_acquire("X7", GPIO_PIN_OUTPUT); 500 pin = tegra_gpio_acquire("X7", GPIO_PIN_OUTPUT);
487 if (pin) { 501 if (pin) {
488 tegra_gpio_write(pin, 1); 502 tegra_gpio_write(pin, 1);
489 } 503 }
490 } 504 }
491 } 505 }
492} 506}
493 507
494static void 508static void
495tegra_reset(void) 509tegra_reset(void)
496{ 510{
497#if NAS3722PMIC > 0 511#if NAS3722PMIC > 0
498 device_t pmic = device_find_by_driver_unit("as3722pmic", 0); 512 device_t pmic = device_find_by_driver_unit("as3722pmic", 0);
499 if (pmic != NULL) { 513 if (pmic != NULL) {
500 delay(1000000); 514 delay(1000000);
501 if (as3722_reboot(pmic) != 0) { 515 if (as3722_reboot(pmic) != 0) {
502 printf("WARNING: AS3722 reset failed\n"); 516 printf("WARNING: AS3722 reset failed\n");
503 return; 517 return;
504 } 518 }
505 } 519 }
506#endif 520#endif
507 tegra_pmc_reset(); 521 tegra_pmc_reset();
508} 522}
509 523
510static void 524static void
511tegra_powerdown(void) 525tegra_powerdown(void)
512{ 526{
513#if NAS3722PMIC > 0 527#if NAS3722PMIC > 0
514 device_t pmic = device_find_by_driver_unit("as3722pmic", 0); 528 device_t pmic = device_find_by_driver_unit("as3722pmic", 0);
515 if (pmic != NULL) { 529 if (pmic != NULL) {
516 delay(1000000); 530 delay(1000000);
517 if (as3722_poweroff(pmic) != 0) { 531 if (as3722_poweroff(pmic) != 0) {
518 printf("WARNING: AS3722 poweroff failed\n"); 532 printf("WARNING: AS3722 poweroff failed\n");
519 return; 533 return;
520 } 534 }
521 } 535 }
522#endif 536#endif
523} 537}