Thu May 27 22:11:31 2021 UTC ()
The Tsunami / Typhoon chipsets have a static "monster window" for DMA
that allows for up to 32GB of RAM to be direct-mapped if the PCI device
can issue a 64-bit address (the monster window lives at 0x10000000000).
Enable this window and provide this to the PCI bus as a "dmat64".


(thorpej)
diff -r1.21 -r1.22 src/sys/arch/alpha/include/pci_machdep.h
diff -r1.25 -r1.26 src/sys/arch/alpha/pci/tsc.c
diff -r1.16 -r1.17 src/sys/arch/alpha/pci/tsp_dma.c
diff -r1.8 -r1.9 src/sys/arch/alpha/pci/tsreg.h
diff -r1.14 -r1.15 src/sys/arch/alpha/pci/tsvar.h

cvs diff -r1.21 -r1.22 src/sys/arch/alpha/include/pci_machdep.h (switch to unified diff)

--- src/sys/arch/alpha/include/pci_machdep.h 2020/09/26 21:07:48 1.21
+++ src/sys/arch/alpha/include/pci_machdep.h 2021/05/27 22:11:31 1.22
@@ -1,143 +1,144 @@ @@ -1,143 +1,144 @@
1/* $NetBSD: pci_machdep.h,v 1.21 2020/09/26 21:07:48 thorpej Exp $ */ 1/* $NetBSD: pci_machdep.h,v 1.22 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Carnegie-Mellon University. 4 * Copyright (c) 1996 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 * 18 *
19 * Carnegie Mellon requests users of this software to return to 19 * Carnegie Mellon requests users of this software to return to
20 * 20 *
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science 22 * School of Computer Science
23 * Carnegie Mellon University 23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890 24 * Pittsburgh PA 15213-3890
25 * 25 *
26 * any improvements or extensions that they make and grant Carnegie the 26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes. 27 * rights to redistribute these changes.
28 */ 28 */
29 29
30#ifndef _ALPHA_PCI_MACHDEP_H_ 30#ifndef _ALPHA_PCI_MACHDEP_H_
31#define _ALPHA_PCI_MACHDEP_H_ 31#define _ALPHA_PCI_MACHDEP_H_
32 32
33#include <sys/errno.h> 33#include <sys/errno.h>
34 34
35/* 35/*
36 * Machine-specific definitions for PCI autoconfiguration. 36 * Machine-specific definitions for PCI autoconfiguration.
37 */ 37 */
38#define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH 38#define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
 39#define _PCI_HAVE_DMA64
39 40
40/* 41/*
41 * Types provided to machine-independent PCI code 42 * Types provided to machine-independent PCI code
42 */ 43 */
43typedef struct alpha_pci_chipset *pci_chipset_tag_t; 44typedef struct alpha_pci_chipset *pci_chipset_tag_t;
44typedef u_long pcitag_t; 45typedef u_long pcitag_t;
45typedef struct { 46typedef struct {
46 u_long value; 47 u_long value;
47} pci_intr_handle_t; 48} pci_intr_handle_t;
48 49
49/* 50/*
50 * Forward declarations. 51 * Forward declarations.
51 */ 52 */
52struct pci_attach_args; 53struct pci_attach_args;
53struct alpha_shared_intr; 54struct alpha_shared_intr;
54 55
55/* 56/*
56 * alpha-specific PCI structure and type definitions. 57 * alpha-specific PCI structure and type definitions.
57 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE. 58 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
58 */ 59 */
59struct alpha_pci_chipset { 60struct alpha_pci_chipset {
60 void *pc_conf_v; 61 void *pc_conf_v;
61 void (*pc_attach_hook)(device_t, device_t, 62 void (*pc_attach_hook)(device_t, device_t,
62 struct pcibus_attach_args *); 63 struct pcibus_attach_args *);
63 int (*pc_bus_maxdevs)(void *, int); 64 int (*pc_bus_maxdevs)(void *, int);
64 pcitag_t (*pc_make_tag)(void *, int, int, int); 65 pcitag_t (*pc_make_tag)(void *, int, int, int);
65 void (*pc_decompose_tag)(void *, pcitag_t, int *, 66 void (*pc_decompose_tag)(void *, pcitag_t, int *,
66 int *, int *); 67 int *, int *);
67 pcireg_t (*pc_conf_read)(void *, pcitag_t, int); 68 pcireg_t (*pc_conf_read)(void *, pcitag_t, int);
68 void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t); 69 void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
69 70
70 void *pc_intr_v; 71 void *pc_intr_v;
71 int (*pc_intr_map)(const struct pci_attach_args *, 72 int (*pc_intr_map)(const struct pci_attach_args *,
72 pci_intr_handle_t *); 73 pci_intr_handle_t *);
73 const char *(*pc_intr_string)(pci_chipset_tag_t, 74 const char *(*pc_intr_string)(pci_chipset_tag_t,
74 pci_intr_handle_t, char *, size_t); 75 pci_intr_handle_t, char *, size_t);
75 const struct evcnt *(*pc_intr_evcnt)(pci_chipset_tag_t, 76 const struct evcnt *(*pc_intr_evcnt)(pci_chipset_tag_t,
76 pci_intr_handle_t); 77 pci_intr_handle_t);
77 void *(*pc_intr_establish)(pci_chipset_tag_t, 78 void *(*pc_intr_establish)(pci_chipset_tag_t,
78 pci_intr_handle_t, int, int (*)(void *), void *); 79 pci_intr_handle_t, int, int (*)(void *), void *);
79 void (*pc_intr_disestablish)(pci_chipset_tag_t, void *); 80 void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
80 81
81 void *(*pc_pciide_compat_intr_establish)(device_t, 82 void *(*pc_pciide_compat_intr_establish)(device_t,
82 const struct pci_attach_args *, int, 83 const struct pci_attach_args *, int,
83 int (*)(void *), void *); 84 int (*)(void *), void *);
84 85
85 struct alpha_shared_intr *pc_shared_intrs; 86 struct alpha_shared_intr *pc_shared_intrs;
86 const char *pc_intr_desc; 87 const char *pc_intr_desc;
87 u_long pc_vecbase; 88 u_long pc_vecbase;
88 u_int pc_nirq; 89 u_int pc_nirq;
89 90
90 u_long pc_eligible_cpus; 91 u_long pc_eligible_cpus;
91 92
92 void (*pc_intr_enable)(pci_chipset_tag_t, int); 93 void (*pc_intr_enable)(pci_chipset_tag_t, int);
93 void (*pc_intr_disable)(pci_chipset_tag_t, int); 94 void (*pc_intr_disable)(pci_chipset_tag_t, int);
94 void (*pc_intr_set_affinity)(pci_chipset_tag_t, int, 95 void (*pc_intr_set_affinity)(pci_chipset_tag_t, int,
95 struct cpu_info *); 96 struct cpu_info *);
96}; 97};
97 98
98/* 99/*
99 * Functions provided to machine-independent PCI code. 100 * Functions provided to machine-independent PCI code.
100 */ 101 */
101void pci_attach_hook(device_t, device_t, struct pcibus_attach_args *); 102void pci_attach_hook(device_t, device_t, struct pcibus_attach_args *);
102int pci_bus_maxdevs(pci_chipset_tag_t, int); 103int pci_bus_maxdevs(pci_chipset_tag_t, int);
103pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int); 104pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int);
104void pci_decompose_tag(pci_chipset_tag_t, pcitag_t, int *, int *, int *); 105void pci_decompose_tag(pci_chipset_tag_t, pcitag_t, int *, int *, int *);
105pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int); 106pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
106void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); 107void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
107 108
108int pci_intr_map(const struct pci_attach_args *, pci_intr_handle_t *); 109int pci_intr_map(const struct pci_attach_args *, pci_intr_handle_t *);
109const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t, 110const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t,
110 char *, size_t); 111 char *, size_t);
111const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t); 112const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
112void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, int, 113void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, int,
113 int (*)(void *), void *); 114 int (*)(void *), void *);
114void pci_intr_disestablish(pci_chipset_tag_t, void *); 115void pci_intr_disestablish(pci_chipset_tag_t, void *);
115 116
116/* 117/*
117 * alpha-specific PCI functions. 118 * alpha-specific PCI functions.
118 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE. 119 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
119 */ 120 */
120void pci_display_console(bus_space_tag_t, bus_space_tag_t, 121void pci_display_console(bus_space_tag_t, bus_space_tag_t,
121 pci_chipset_tag_t, int, int, int); 122 pci_chipset_tag_t, int, int, int);
122void device_pci_register(device_t, void *); 123void device_pci_register(device_t, void *);
123 124
124int alpha_pci_generic_intr_map(const struct pci_attach_args *, 125int alpha_pci_generic_intr_map(const struct pci_attach_args *,
125 pci_intr_handle_t *); 126 pci_intr_handle_t *);
126const char *alpha_pci_generic_intr_string(pci_chipset_tag_t, 127const char *alpha_pci_generic_intr_string(pci_chipset_tag_t,
127 pci_intr_handle_t, char *, size_t); 128 pci_intr_handle_t, char *, size_t);
128const struct evcnt *alpha_pci_generic_intr_evcnt(pci_chipset_tag_t, 129const struct evcnt *alpha_pci_generic_intr_evcnt(pci_chipset_tag_t,
129 pci_intr_handle_t); 130 pci_intr_handle_t);
130void *alpha_pci_generic_intr_establish(pci_chipset_tag_t, 131void *alpha_pci_generic_intr_establish(pci_chipset_tag_t,
131 pci_intr_handle_t, int, int (*)(void *), void *); 132 pci_intr_handle_t, int, int (*)(void *), void *);
132void alpha_pci_generic_intr_disestablish(pci_chipset_tag_t, void *); 133void alpha_pci_generic_intr_disestablish(pci_chipset_tag_t, void *);
133void alpha_pci_generic_iointr(void *, unsigned long); 134void alpha_pci_generic_iointr(void *, unsigned long);
134 135
135void alpha_pci_generic_intr_redistribute(pci_chipset_tag_t); 136void alpha_pci_generic_intr_redistribute(pci_chipset_tag_t);
136 137
137void alpha_pci_intr_handle_init(pci_intr_handle_t *, u_int, u_int); 138void alpha_pci_intr_handle_init(pci_intr_handle_t *, u_int, u_int);
138void alpha_pci_intr_handle_set_irq(pci_intr_handle_t *, u_int); 139void alpha_pci_intr_handle_set_irq(pci_intr_handle_t *, u_int);
139u_int alpha_pci_intr_handle_get_irq(const pci_intr_handle_t *); 140u_int alpha_pci_intr_handle_get_irq(const pci_intr_handle_t *);
140void alpha_pci_intr_handle_set_flags(pci_intr_handle_t *, u_int); 141void alpha_pci_intr_handle_set_flags(pci_intr_handle_t *, u_int);
141u_int alpha_pci_intr_handle_get_flags(const pci_intr_handle_t *); 142u_int alpha_pci_intr_handle_get_flags(const pci_intr_handle_t *);
142 143
143#endif /* _ALPHA_PCI_MACHDEP_H_ */ 144#endif /* _ALPHA_PCI_MACHDEP_H_ */

cvs diff -r1.25 -r1.26 src/sys/arch/alpha/pci/tsc.c (switch to unified diff)

--- src/sys/arch/alpha/pci/tsc.c 2021/04/24 23:36:23 1.25
+++ src/sys/arch/alpha/pci/tsc.c 2021/05/27 22:11:31 1.26
@@ -1,367 +1,367 @@ @@ -1,367 +1,367 @@
1/* $NetBSD: tsc.c,v 1.25 2021/04/24 23:36:23 thorpej Exp $ */ 1/* $NetBSD: tsc.c,v 1.26 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 4 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement: 15 * must display the following acknowledgement:
16 * This product includes software developed by Ross Harvey. 16 * This product includes software developed by Ross Harvey.
17 * 4. The name of Ross Harvey may not be used to endorse or promote products 17 * 4. The name of Ross Harvey may not be used to endorse or promote products
18 * derived from this software without specific prior written permission. 18 * derived from this software without specific prior written permission.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS 20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY 23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 */ 32 */
33 33
34#include "opt_dec_6600.h" 34#include "opt_dec_6600.h"
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37 37
38__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.25 2021/04/24 23:36:23 thorpej Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.26 2021/05/27 22:11:31 thorpej Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/device.h> 42#include <sys/device.h>
43#include <sys/malloc.h> 43#include <sys/malloc.h>
44 44
45#include <machine/autoconf.h> 45#include <machine/autoconf.h>
46#include <machine/rpb.h> 46#include <machine/rpb.h>
47#include <machine/sysarch.h> 47#include <machine/sysarch.h>
48 48
49#include <dev/isa/isareg.h> 49#include <dev/isa/isareg.h>
50#include <dev/isa/isavar.h> 50#include <dev/isa/isavar.h>
51#include <dev/pci/pcireg.h> 51#include <dev/pci/pcireg.h>
52#include <dev/pci/pcivar.h> 52#include <dev/pci/pcivar.h>
53#include <alpha/pci/tsreg.h> 53#include <alpha/pci/tsreg.h>
54#include <alpha/pci/tsvar.h> 54#include <alpha/pci/tsvar.h>
55 55
56#include "tsciic.h" 56#include "tsciic.h"
57 57
58#ifdef DEC_6600 58#ifdef DEC_6600
59#include <alpha/pci/pci_6600.h> 59#include <alpha/pci/pci_6600.h>
60#endif 60#endif
61 61
62#define tsc() { Generate ctags(1) key. } 62#define tsc() { Generate ctags(1) key. }
63 63
64static int tscmatch(device_t, cfdata_t, void *); 64static int tscmatch(device_t, cfdata_t, void *);
65static void tscattach(device_t, device_t, void *); 65static void tscattach(device_t, device_t, void *);
66 66
67CFATTACH_DECL_NEW(tsc, 0, tscmatch, tscattach, NULL, NULL); 67CFATTACH_DECL_NEW(tsc, 0, tscmatch, tscattach, NULL, NULL);
68 68
69extern struct cfdriver tsc_cd; 69extern struct cfdriver tsc_cd;
70 70
71struct tsp_config tsp_configuration[4]; 71struct tsp_config tsp_configuration[4];
72 72
73static int tscprint(void *, const char *pnp); 73static int tscprint(void *, const char *pnp);
74 74
75static int tspmatch(device_t, cfdata_t, void *); 75static int tspmatch(device_t, cfdata_t, void *);
76static void tspattach(device_t, device_t, void *); 76static void tspattach(device_t, device_t, void *);
77 77
78CFATTACH_DECL_NEW(tsp, 0, tspmatch, tspattach, NULL, NULL); 78CFATTACH_DECL_NEW(tsp, 0, tspmatch, tspattach, NULL, NULL);
79 79
80extern struct cfdriver tsp_cd; 80extern struct cfdriver tsp_cd;
81 81
82static int tsp_bus_get_window(int, int, 82static int tsp_bus_get_window(int, int,
83 struct alpha_bus_space_translation *); 83 struct alpha_bus_space_translation *);
84 84
85static int tsciicprint(void *, const char *pnp); 85static int tsciicprint(void *, const char *pnp);
86 86
87static int tsciicmatch(device_t, cfdata_t, void *); 87static int tsciicmatch(device_t, cfdata_t, void *);
88static void tsciicattach(device_t, device_t, void *); 88static void tsciicattach(device_t, device_t, void *);
89 89
90CFATTACH_DECL_NEW(tsciic, sizeof(struct tsciic_softc), tsciicmatch, 90CFATTACH_DECL_NEW(tsciic, sizeof(struct tsciic_softc), tsciicmatch,
91 tsciicattach, NULL, NULL); 91 tsciicattach, NULL, NULL);
92 92
93#if NTSCIIC 93#if NTSCIIC
94extern struct cfdriver tsciic_cd; 94extern struct cfdriver tsciic_cd;
95#endif 95#endif
96 96
97/* There can be only one */ 97/* There can be only one */
98static int tscfound; 98static int tscfound;
99 99
100/* Which hose is the display console connected to? */ 100/* Which hose is the display console connected to? */
101int tsp_console_hose; 101int tsp_console_hose;
102 102
103static int 103static int
104tscmatch(device_t parent, cfdata_t match, void *aux) 104tscmatch(device_t parent, cfdata_t match, void *aux)
105{ 105{
106 struct mainbus_attach_args *ma = aux; 106 struct mainbus_attach_args *ma = aux;
107 107
108 switch (cputype) { 108 switch (cputype) {
109 case ST_DEC_6600: 109 case ST_DEC_6600:
110 case ST_DEC_TITAN: 110 case ST_DEC_TITAN:
111 return strcmp(ma->ma_name, tsc_cd.cd_name) == 0 && !tscfound; 111 return strcmp(ma->ma_name, tsc_cd.cd_name) == 0 && !tscfound;
112 default: 112 default:
113 return 0; 113 return 0;
114 } 114 }
115} 115}
116 116
117static void 117static void
118tscattach(device_t parent, device_t self, void * aux) 118tscattach(device_t parent, device_t self, void * aux)
119{ 119{
120 int i; 120 int i;
121 int nbus; 121 int nbus;
122 uint64_t csc, aar; 122 uint64_t csc, aar;
123 struct tsp_attach_args tsp; 123 struct tsp_attach_args tsp;
124 struct tsciic_attach_args tsciic; 124 struct tsciic_attach_args tsciic;
125 struct mainbus_attach_args *ma = aux; 125 struct mainbus_attach_args *ma = aux;
126 int titan = cputype == ST_DEC_TITAN; 126 int titan = cputype == ST_DEC_TITAN;
127 127
128 tscfound = 1; 128 tscfound = 1;
129 129
130 csc = LDQP(TS_C_CSC); 130 csc = LDQP(TS_C_CSC);
131 131
132 nbus = 1 + (CSC_BC(csc) >= 2); 132 nbus = 1 + (CSC_BC(csc) >= 2);
133 printf(": 2127%c Core Logic Chipset, Cchip rev %d\n" 133 printf(": 2127%c Core Logic Chipset, Cchip rev %d\n"
134 "%s%d: %c Dchips, %d memory bus%s of %d bytes\n", 134 "%s%d: %c Dchips, %d memory bus%s of %d bytes\n",
135 titan ? '4' : '2', (int)MISC_REV(LDQP(TS_C_MISC)), 135 titan ? '4' : '2', (int)MISC_REV(LDQP(TS_C_MISC)),
136 ma->ma_name, ma->ma_slot, "2448"[CSC_BC(csc)], 136 ma->ma_name, ma->ma_slot, "2448"[CSC_BC(csc)],
137 nbus, nbus > 1 ? "es" : "", 16 + 16 * ((csc & CSC_AW) != 0)); 137 nbus, nbus > 1 ? "es" : "", 16 + 16 * ((csc & CSC_AW) != 0));
138 printf("%s%d: arrays present: ", ma->ma_name, ma->ma_slot); 138 printf("%s%d: arrays present: ", ma->ma_name, ma->ma_slot);
139 for (i = 0; i < 4; ++i) { 139 for (i = 0; i < 4; ++i) {
140 aar = LDQP(TS_C_AAR0 + i * TS_STEP); 140 aar = LDQP(TS_C_AAR0 + i * TS_STEP);
141 printf("%s%dMB%s", i ? ", " : "", (8 << AAR_ASIZ(aar)) & ~0xf, 141 printf("%s%dMB%s", i ? ", " : "", (8 << AAR_ASIZ(aar)) & ~0xf,
142 aar & AAR_SPLIT ? " (split)" : ""); 142 aar & AAR_SPLIT ? " (split)" : "");
143 } 143 }
144 printf(", Dchip 0 rev %d\n", (int)LDQP(TS_D_DREV) & 0xf); 144 printf(", Dchip 0 rev %d\n", (int)LDQP(TS_D_DREV) & 0xf);
145 145
146 memset(&tsp, 0, sizeof tsp); 146 memset(&tsp, 0, sizeof tsp);
147 tsp.tsp_name = "tsp"; 147 tsp.tsp_name = "tsp";
148 tsp.tsp_slot = 0; 148 tsp.tsp_slot = 0;
149 149
150 config_found(self, &tsp, tscprint, CFARG_EOL); 150 config_found(self, &tsp, tscprint, CFARG_EOL);
151 if (titan) { 151 if (titan) {
152 tsp.tsp_slot += 2; 152 tsp.tsp_slot += 2;
153 config_found(self, &tsp, tscprint, CFARG_EOL); 153 config_found(self, &tsp, tscprint, CFARG_EOL);
154 } 154 }
155 155
156 if (csc & CSC_P1P) { 156 if (csc & CSC_P1P) {
157 tsp.tsp_slot = 1; 157 tsp.tsp_slot = 1;
158 config_found(self, &tsp, tscprint, CFARG_EOL); 158 config_found(self, &tsp, tscprint, CFARG_EOL);
159 if (titan) { 159 if (titan) {
160 tsp.tsp_slot += 2; 160 tsp.tsp_slot += 2;
161 config_found(self, &tsp, tscprint, CFARG_EOL); 161 config_found(self, &tsp, tscprint, CFARG_EOL);
162 } 162 }
163 } 163 }
164 164
165 memset(&tsciic, 0, sizeof tsciic); 165 memset(&tsciic, 0, sizeof tsciic);
166 tsciic.tsciic_name = "tsciic"; 166 tsciic.tsciic_name = "tsciic";
167 167
168 config_found(self, &tsciic, tsciicprint, CFARG_EOL); 168 config_found(self, &tsciic, tsciicprint, CFARG_EOL);
169} 169}
170 170
171static int 171static int
172tscprint(void *aux, const char *p) 172tscprint(void *aux, const char *p)
173{ 173{
174 struct tsp_attach_args *tsp = aux; 174 struct tsp_attach_args *tsp = aux;
175 175
176 if (p) 176 if (p)
177 aprint_normal("%s%d at %s", tsp->tsp_name, tsp->tsp_slot, p); 177 aprint_normal("%s%d at %s", tsp->tsp_name, tsp->tsp_slot, p);
178 return UNCONF; 178 return UNCONF;
179} 179}
180 180
181static int 181static int
182tsciicprint(void *aux, const char *p) 182tsciicprint(void *aux, const char *p)
183{ 183{
184 struct tsciic_attach_args *tsciic = aux; 184 struct tsciic_attach_args *tsciic = aux;
185 185
186 if (p) 186 if (p)
187 aprint_normal("%s at %s\n", tsciic->tsciic_name, p); 187 aprint_normal("%s at %s\n", tsciic->tsciic_name, p);
188 else 188 else
189 aprint_normal("\n"); 189 aprint_normal("\n");
190 return UNCONF; 190 return UNCONF;
191} 191}
192 192
193#define tsp() { Generate ctags(1) key. } 193#define tsp() { Generate ctags(1) key. }
194 194
195static int 195static int
196tspmatch(device_t parent, cfdata_t match, void *aux) 196tspmatch(device_t parent, cfdata_t match, void *aux)
197{ 197{
198 struct tsp_attach_args *t = aux; 198 struct tsp_attach_args *t = aux;
199 199
200 switch (cputype) { 200 switch (cputype) {
201 case ST_DEC_6600: 201 case ST_DEC_6600:
202 case ST_DEC_TITAN: 202 case ST_DEC_TITAN:
203 return strcmp(t->tsp_name, tsp_cd.cd_name) == 0; 203 return strcmp(t->tsp_name, tsp_cd.cd_name) == 0;
204 default: 204 default:
205 return 0; 205 return 0;
206 } 206 }
207} 207}
208 208
209static void 209static void
210tspattach(device_t parent, device_t self, void *aux) 210tspattach(device_t parent, device_t self, void *aux)
211{ 211{
212 struct pcibus_attach_args pba; 212 struct pcibus_attach_args pba;
213 struct tsp_attach_args *t = aux; 213 struct tsp_attach_args *t = aux;
214 struct tsp_config *pcp; 214 struct tsp_config *pcp;
215 215
216 printf("\n"); 216 printf("\n");
217 pcp = tsp_init(1, t->tsp_slot); 217 pcp = tsp_init(1, t->tsp_slot);
218 218
219 tsp_dma_init(pcp); 219 tsp_dma_init(pcp);
220 220
221 /* 221 /*
222 * Do PCI memory initialization that needs to be deferred until 222 * Do PCI memory initialization that needs to be deferred until
223 * malloc is safe. On the Tsunami, we need to do this after 223 * malloc is safe. On the Tsunami, we need to do this after
224 * DMA is initialized, as well. 224 * DMA is initialized, as well.
225 */ 225 */
226 tsp_bus_mem_init2(&pcp->pc_memt, pcp); 226 tsp_bus_mem_init2(&pcp->pc_memt, pcp);
227 227
228 pci_6600_pickintr(pcp); 228 pci_6600_pickintr(pcp);
229 229
230 pba.pba_iot = &pcp->pc_iot; 230 pba.pba_iot = &pcp->pc_iot;
231 pba.pba_memt = &pcp->pc_memt; 231 pba.pba_memt = &pcp->pc_memt;
232 pba.pba_dmat = 232 pba.pba_dmat =
233 alphabus_dma_get_tag(&pcp->pc_dmat_direct, ALPHA_BUS_PCI); 233 alphabus_dma_get_tag(&pcp->pc_dmat_direct, ALPHA_BUS_PCI);
234 pba.pba_dmat64 = NULL; 234 pba.pba_dmat64 = &pcp->pc_dmat64_direct;
235 pba.pba_pc = &pcp->pc_pc; 235 pba.pba_pc = &pcp->pc_pc;
236 pba.pba_bus = 0; 236 pba.pba_bus = 0;
237 pba.pba_bridgetag = NULL; 237 pba.pba_bridgetag = NULL;
238 pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY | 238 pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
239 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY; 239 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
240 config_found(self, &pba, pcibusprint, CFARG_EOL); 240 config_found(self, &pba, pcibusprint, CFARG_EOL);
241} 241}
242 242
243struct tsp_config * 243struct tsp_config *
244tsp_init(int mallocsafe, int n) 244tsp_init(int mallocsafe, int n)
245 /* n: Pchip number */ 245 /* n: Pchip number */
246{ 246{
247 struct tsp_config *pcp; 247 struct tsp_config *pcp;
248 int titan = cputype == ST_DEC_TITAN; 248 int titan = cputype == ST_DEC_TITAN;
249 249
250 KASSERT(n >= 0 && n < __arraycount(tsp_configuration)); 250 KASSERT(n >= 0 && n < __arraycount(tsp_configuration));
251 pcp = &tsp_configuration[n]; 251 pcp = &tsp_configuration[n];
252 pcp->pc_pslot = n; 252 pcp->pc_pslot = n;
253 pcp->pc_iobase = TS_Pn(n, 0); 253 pcp->pc_iobase = TS_Pn(n, 0);
254 pcp->pc_csr = S_PAGE(TS_Pn(n & 1, P_CSRBASE)); 254 pcp->pc_csr = S_PAGE(TS_Pn(n & 1, P_CSRBASE));
255 if (n & 2) { 255 if (n & 2) {
256 /* `A' port of PA Chip */ 256 /* `A' port of PA Chip */
257 pcp->pc_csr++; 257 pcp->pc_csr++;
258 } 258 }
259 if (titan) { 259 if (titan) {
260 /* same address on G and A ports */ 260 /* same address on G and A ports */
261 pcp->pc_tlbia = &pcp->pc_csr->port.g.tsp_tlbia.tsg_r; 261 pcp->pc_tlbia = &pcp->pc_csr->port.g.tsp_tlbia.tsg_r;
262 } else { 262 } else {
263 pcp->pc_tlbia = &pcp->pc_csr->port.p.tsp_tlbia.tsg_r; 263 pcp->pc_tlbia = &pcp->pc_csr->port.p.tsp_tlbia.tsg_r;
264 } 264 }
265 265
266 if (!pcp->pc_initted) { 266 if (!pcp->pc_initted) {
267 tsp_bus_io_init(&pcp->pc_iot, pcp); 267 tsp_bus_io_init(&pcp->pc_iot, pcp);
268 tsp_bus_mem_init(&pcp->pc_memt, pcp); 268 tsp_bus_mem_init(&pcp->pc_memt, pcp);
269 269
270 alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1; 270 alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_IO] = 1;
271 alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1; 271 alpha_bus_window_count[ALPHA_BUS_TYPE_PCI_MEM] = 1;
272 272
273 alpha_bus_get_window = tsp_bus_get_window; 273 alpha_bus_get_window = tsp_bus_get_window;
274 } 274 }
275 pcp->pc_mallocsafe = mallocsafe; 275 pcp->pc_mallocsafe = mallocsafe;
276 tsp_pci_init(&pcp->pc_pc, pcp); 276 tsp_pci_init(&pcp->pc_pc, pcp);
277 pcp->pc_initted = 1; 277 pcp->pc_initted = 1;
278 return pcp; 278 return pcp;
279} 279}
280 280
281static int 281static int
282tsp_bus_get_window(int type, int window, 282tsp_bus_get_window(int type, int window,
283 struct alpha_bus_space_translation *abst) 283 struct alpha_bus_space_translation *abst)
284{ 284{
285 struct tsp_config *tsp = &tsp_configuration[tsp_console_hose]; 285 struct tsp_config *tsp = &tsp_configuration[tsp_console_hose];
286 bus_space_tag_t st; 286 bus_space_tag_t st;
287 int error; 287 int error;
288 288
289 switch (type) { 289 switch (type) {
290 case ALPHA_BUS_TYPE_PCI_IO: 290 case ALPHA_BUS_TYPE_PCI_IO:
291 st = &tsp->pc_iot; 291 st = &tsp->pc_iot;
292 break; 292 break;
293 293
294 case ALPHA_BUS_TYPE_PCI_MEM: 294 case ALPHA_BUS_TYPE_PCI_MEM:
295 st = &tsp->pc_memt; 295 st = &tsp->pc_memt;
296 break; 296 break;
297 297
298 default: 298 default:
299 panic("tsp_bus_get_window"); 299 panic("tsp_bus_get_window");
300 } 300 }
301 301
302 error = alpha_bus_space_get_window(st, window, abst); 302 error = alpha_bus_space_get_window(st, window, abst);
303 if (error) 303 if (error)
304 return error; 304 return error;
305 305
306 abst->abst_sys_start = TS_PHYSADDR(abst->abst_sys_start); 306 abst->abst_sys_start = TS_PHYSADDR(abst->abst_sys_start);
307 abst->abst_sys_end = TS_PHYSADDR(abst->abst_sys_end); 307 abst->abst_sys_end = TS_PHYSADDR(abst->abst_sys_end);
308 308
309 return 0; 309 return 0;
310} 310}
311 311
312#define tsciic() { Generate ctags(1) key. } 312#define tsciic() { Generate ctags(1) key. }
313 313
314static int 314static int
315tsciicmatch(device_t parent, cfdata_t match, void *aux) 315tsciicmatch(device_t parent, cfdata_t match, void *aux)
316{ 316{
317#if NTSCIIC 317#if NTSCIIC
318 struct tsciic_attach_args *t = aux; 318 struct tsciic_attach_args *t = aux;
319#endif 319#endif
320 320
321 switch (cputype) { 321 switch (cputype) {
322 case ST_DEC_6600: 322 case ST_DEC_6600:
323 case ST_DEC_TITAN: 323 case ST_DEC_TITAN:
324#if NTSCIIC 324#if NTSCIIC
325 return strcmp(t->tsciic_name, tsciic_cd.cd_name) == 0; 325 return strcmp(t->tsciic_name, tsciic_cd.cd_name) == 0;
326#endif 326#endif
327 default: 327 default:
328 return 0; 328 return 0;
329 } 329 }
330} 330}
331 331
332static void 332static void
333tsciicattach(device_t parent, device_t self, void *aux) 333tsciicattach(device_t parent, device_t self, void *aux)
334{ 334{
335#if NTSCIIC 335#if NTSCIIC
336 tsciic_init(self); 336 tsciic_init(self);
337#endif 337#endif
338} 338}
339 339
340void 340void
341tsc_print_dir(unsigned int indent, unsigned long dir) 341tsc_print_dir(unsigned int indent, unsigned long dir)
342{ 342{
343 char buf[60]; 343 char buf[60];
344 344
345 snprintb(buf, 60, 345 snprintb(buf, 60,
346 "\177\20" 346 "\177\20"
347 "b\77Internal Cchip asynchronous error\0" 347 "b\77Internal Cchip asynchronous error\0"
348 "b\76Pchip 0 error\0" 348 "b\76Pchip 0 error\0"
349 "b\75Pchip 1 error\0" 349 "b\75Pchip 1 error\0"
350 "b\74Pchip 2 error\0" 350 "b\74Pchip 2 error\0"
351 "b\73Pchip 3 error\0", 351 "b\73Pchip 3 error\0",
352 dir); 352 dir);
353 IPRINTF(indent, "DIR = %s\n", buf); 353 IPRINTF(indent, "DIR = %s\n", buf);
354} 354}
355 355
356void 356void
357tsc_print_misc(unsigned int indent, unsigned long misc) 357tsc_print_misc(unsigned int indent, unsigned long misc)
358{ 358{
359 unsigned long tmp = MISC_NXM_SRC(misc); 359 unsigned long tmp = MISC_NXM_SRC(misc);
360 360
361 if (!MISC_NXM(misc)) 361 if (!MISC_NXM(misc))
362 return; 362 return;
363 363
364 IPRINTF(indent, "NXM address detected\n"); 364 IPRINTF(indent, "NXM address detected\n");
365 IPRINTF(indent, "NXM source = %s %lu\n", 365 IPRINTF(indent, "NXM source = %s %lu\n",
366 tmp <= 3 ? "CPU" : "Pchip", tmp <= 3 ? tmp : tmp - 4); 366 tmp <= 3 ? "CPU" : "Pchip", tmp <= 3 ? tmp : tmp - 4);
367} 367}

cvs diff -r1.16 -r1.17 src/sys/arch/alpha/pci/tsp_dma.c (switch to unified diff)

--- src/sys/arch/alpha/pci/tsp_dma.c 2021/05/05 02:15:18 1.16
+++ src/sys/arch/alpha/pci/tsp_dma.c 2021/05/27 22:11:31 1.17
@@ -1,360 +1,413 @@ @@ -1,360 +1,413 @@
1/* $NetBSD: tsp_dma.c,v 1.16 2021/05/05 02:15:18 thorpej Exp $ */ 1/* $NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $ */
 2
 3/*-
 4 * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
 5 * All rights reserved.
 6 *
 7 * This code is derived from software contributed to The NetBSD Foundation
 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
 9 * NASA Ames Research Center.
 10 *
 11 * Redistribution and use in source and binary forms, with or without
 12 * modification, are permitted provided that the following conditions
 13 * are met:
 14 * 1. Redistributions of source code must retain the above copyright
 15 * notice, this list of conditions and the following disclaimer.
 16 * 2. Redistributions in binary form must reproduce the above copyright
 17 * notice, this list of conditions and the following disclaimer in the
 18 * documentation and/or other materials provided with the distribution.
 19 *
 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 30 * POSSIBILITY OF SUCH DAMAGE.
 31 */
2 32
3/*- 33/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 34 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 35 *
6 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 37 * modification, are permitted provided that the following conditions
8 * are met: 38 * are met:
9 * 1. Redistributions of source code must retain the above copyright 39 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 40 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 41 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 42 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 43 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 44 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement: 45 * must display the following acknowledgement:
16 * This product includes software developed by Ross Harvey. 46 * This product includes software developed by Ross Harvey.
17 * 4. The name of Ross Harvey may not be used to endorse or promote products 47 * 4. The name of Ross Harvey may not be used to endorse or promote products
18 * derived from this software without specific prior written permission. 48 * derived from this software without specific prior written permission.
19 * 49 *
20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS 50 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE 52 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY 53 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 60 * SUCH DAMAGE.
31 * 
32 */ 
33 
34/*- 
35 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 
36 * All rights reserved. 
37 * 
38 * This code is derived from software contributed to The NetBSD Foundation 
39 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 
40 * NASA Ames Research Center. 
41 * 
42 * Redistribution and use in source and binary forms, with or without 
43 * modification, are permitted provided that the following conditions 
44 * are met: 
45 * 1. Redistributions of source code must retain the above copyright 
46 * notice, this list of conditions and the following disclaimer. 
47 * 2. Redistributions in binary form must reproduce the above copyright 
48 * notice, this list of conditions and the following disclaimer in the 
49 * documentation and/or other materials provided with the distribution. 
50 * 
51 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 
52 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
53 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
54 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 
55 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
56 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
57 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
58 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
59 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
61 * POSSIBILITY OF SUCH DAMAGE. 
62 */ 61 */
63 62
64#include <sys/cdefs.h> 63#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.16 2021/05/05 02:15:18 thorpej Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $");
66 65
67#include <sys/param.h> 66#include <sys/param.h>
68#include <sys/systm.h> 67#include <sys/systm.h>
69#include <sys/kernel.h> 68#include <sys/kernel.h>
70#include <sys/device.h> 69#include <sys/device.h>
71#include <sys/malloc.h> 70#include <sys/malloc.h>
72 71
73#include <machine/autoconf.h> 72#include <machine/autoconf.h>
74#define _ALPHA_BUS_DMA_PRIVATE 73#define _ALPHA_BUS_DMA_PRIVATE
75#include <sys/bus.h> 74#include <sys/bus.h>
76#include <machine/rpb.h> 75#include <machine/rpb.h>
77 76
78#include <dev/pci/pcireg.h> 77#include <dev/pci/pcireg.h>
79#include <dev/pci/pcivar.h> 78#include <dev/pci/pcivar.h>
80#include <alpha/pci/tsreg.h> 79#include <alpha/pci/tsreg.h>
81#include <alpha/pci/tsvar.h> 80#include <alpha/pci/tsvar.h>
82 81
83#define tsp_dma() { Generate ctags(1) key. } 82#define tsp_dma() { Generate ctags(1) key. }
84 83
85#define EDIFF(a, b) (((a) | WSBA_ENA | WSBA_SG) != ((b) | WSBA_ENA | WSBA_SG)) 84#define EDIFF(a, b) (((a) | WSBA_ENA | WSBA_SG) != ((b) | WSBA_ENA | WSBA_SG))
86 85
87static bus_dma_tag_t tsp_dma_get_tag(bus_dma_tag_t, alpha_bus_t); 86static bus_dma_tag_t tsp_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
88 87
89static int tsp_bus_dmamap_load_sgmap(bus_dma_tag_t, bus_dmamap_t, void *, 88static int tsp_bus_dmamap_load_sgmap(bus_dma_tag_t, bus_dmamap_t, void *,
90 bus_size_t, struct proc *, int); 89 bus_size_t, struct proc *, int);
91 90
92static int tsp_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t, bus_dmamap_t, 91static int tsp_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t, bus_dmamap_t,
93 struct mbuf *, int); 92 struct mbuf *, int);
94 93
95static int tsp_bus_dmamap_load_uio_sgmap(bus_dma_tag_t, bus_dmamap_t, 94static int tsp_bus_dmamap_load_uio_sgmap(bus_dma_tag_t, bus_dmamap_t,
96 struct uio *, int); 95 struct uio *, int);
97 96
98static int tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t, bus_dmamap_t, 97static int tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t, bus_dmamap_t,
99 bus_dma_segment_t *, int, bus_size_t, int); 98 bus_dma_segment_t *, int, bus_size_t, int);
100 99
101static void tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t, bus_dmamap_t); 100static void tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t, bus_dmamap_t);
102 101
103static void tsp_tlb_invalidate(struct tsp_config *); 102static void tsp_tlb_invalidate(struct tsp_config *);
104 103
105/* 104/*
106 * XXX Need to figure out what this is, if any. Initialize it to 105 * XXX Need to figure out what this is, if any. Initialize it to
107 * XXX something that should be safe. 106 * XXX something that should be safe.
108 */ 107 */
109#define TSP_SGMAP_PFTHRESH 256 108#define TSP_SGMAP_PFTHRESH 256
110 109
 110/*
 111 * Quoting the 21272 programmer's reference manual:
 112 *
 113 * <quote>
 114 * 10.1.4.4 Monster Window DMA Address Translation
 115 *
 116 * In case of a PCI dual-address cycle command, the high-order PCI address
 117 * bits <63:40> are compared to the constant value 0x0000_01 (that is, bit
 118 * <40> = 1; all other bits = 0). If these bits match, a monster window hit
 119 * has occurred and the low-order PCI address bits <34:0> are used unchanged
 120 * as the system address bits <34:0>. PCI address bits <39:35> are ignored.
 121 * The high-order 32 PCI address bits are available on b_ad<31:0> in the
 122 * second cycle of a DAC, and also on b_ad<63:32> in the first cycle of a
 123 * DAC if b_req64_l is asserted.
 124 * </quote>
 125 *
 126 * This means that we can address up to 32GB of RAM using a direct-mapped
 127 * 64-bit DMA tag. This leaves us possibly having to fall back on SGMAP
 128 * DMA on a Titan system (those support up to 64GB of RAM), and we may have
 129 * to address that with an additional large SGMAP DAC window at another
 130 * time.
 131 */
 132#define TSP_MONSTER_DMA_WINDOW_BASE 0x100##00000000UL
 133#define TSP_MONSTER_DMA_WINDOW_SIZE 0x008##00000000UL
 134
111void 135void
112tsp_dma_init(struct tsp_config *pcp) 136tsp_dma_init(struct tsp_config *pcp)
113{ 137{
114 int i; 138 int i;
115 bus_dma_tag_t t; 139 bus_dma_tag_t t;
116 struct ts_pchip *pccsr = pcp->pc_csr; 140 struct ts_pchip *pccsr = pcp->pc_csr;
117 bus_addr_t dwbase, dwlen, sgwbase, sgwlen, tbase; 141 bus_addr_t dwbase, dwlen, sgwbase, sgwlen, tbase;
118 static struct map_expected { 142 static struct map_expected {
119 uint32_t base, mask, enables; 143 uint32_t base, mask, enables;
120 } premap[4] = { 144 } premap[4] = {
121 { 0x00800000, 0x00700000, WSBA_ENA | WSBA_SG }, 145 { 0x00800000, 0x00700000, WSBA_ENA | WSBA_SG },
122 { 0x80000000, 0x3ff00000, WSBA_ENA }, 146 { 0x80000000, 0x3ff00000, WSBA_ENA },
123 { 0, 0, 0 }, 147 { 0, 0, 0 },
124 { 0, 0, 0 } 148 { 0, 0, 0 }
125 }; 149 };
126 150
127 alpha_mb(); 151 alpha_mb();
128 for(i = 0; i < 4; ++i) { 152 for(i = 0; i < 4; ++i) {
129 if (EDIFF(pccsr->tsp_wsba[i].tsg_r, premap[i].base) || 153 if (EDIFF(pccsr->tsp_wsba[i].tsg_r, premap[i].base) ||
130 EDIFF(pccsr->tsp_wsm[i].tsg_r, premap[i].mask)) 154 EDIFF(pccsr->tsp_wsm[i].tsg_r, premap[i].mask))
131 printf("tsp%d: window %d: %lx/base %lx/mask %lx" 155 printf("tsp%d: window %d: %lx/base %lx/mask %lx"
132 " reinitialized\n", 156 " reinitialized\n",
133 pcp->pc_pslot, i, 157 pcp->pc_pslot, i,
134 pccsr->tsp_wsba[i].tsg_r, 158 pccsr->tsp_wsba[i].tsg_r,
135 pccsr->tsp_wsm[i].tsg_r, 159 pccsr->tsp_wsm[i].tsg_r,
136 pccsr->tsp_tba[i].tsg_r); 160 pccsr->tsp_tba[i].tsg_r);
137 pccsr->tsp_wsba[i].tsg_r = premap[i].base | premap[i].enables; 161 pccsr->tsp_wsba[i].tsg_r = premap[i].base | premap[i].enables;
138 pccsr->tsp_wsm[i].tsg_r = premap[i].mask; 162 pccsr->tsp_wsm[i].tsg_r = premap[i].mask;
139 } 163 }
 164
 165 /* Ensure the Monster Window is enabled. */
 166 pccsr->tsp_pctl.tsg_r |= PCTL_MWIN;
140 alpha_mb(); 167 alpha_mb();
141 168
142 /* 169 /*
 170 * Initialize the DMA tag used for direct-mapped 64-bit DMA.
 171 */
 172 t = &pcp->pc_dmat64_direct;
 173 t->_cookie = pcp;
 174 t->_wbase = TSP_MONSTER_DMA_WINDOW_BASE;
 175 t->_wsize = TSP_MONSTER_DMA_WINDOW_SIZE;
 176 t->_next_window = &pcp->pc_dmat_sgmap;
 177 t->_boundary = 0;
 178 t->_sgmap = NULL;
 179 t->_get_tag = tsp_dma_get_tag;
 180 t->_dmamap_create = _bus_dmamap_create;
 181 t->_dmamap_destroy = _bus_dmamap_destroy;
 182 t->_dmamap_load = _bus_dmamap_load_direct;
 183 t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
 184 t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
 185 t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
 186 t->_dmamap_unload = _bus_dmamap_unload;
 187 t->_dmamap_sync = _bus_dmamap_sync;
 188
 189 t->_dmamem_alloc = _bus_dmamem_alloc;
 190 t->_dmamem_free = _bus_dmamem_free;
 191 t->_dmamem_map = _bus_dmamem_map;
 192 t->_dmamem_unmap = _bus_dmamem_unmap;
 193 t->_dmamem_mmap = _bus_dmamem_mmap;
 194
 195 /*
143 * Initialize the DMA tag used for direct-mapped DMA. 196 * Initialize the DMA tag used for direct-mapped DMA.
144 */ 197 */
145 t = &pcp->pc_dmat_direct; 198 t = &pcp->pc_dmat_direct;
146 t->_cookie = pcp; 199 t->_cookie = pcp;
147 t->_wbase = dwbase = WSBA_ADDR(pccsr->tsp_wsba[1].tsg_r); 200 t->_wbase = dwbase = WSBA_ADDR(pccsr->tsp_wsba[1].tsg_r);
148 t->_wsize = dwlen = WSM_LEN(pccsr->tsp_wsm[1].tsg_r); 201 t->_wsize = dwlen = WSM_LEN(pccsr->tsp_wsm[1].tsg_r);
149 t->_next_window = &pcp->pc_dmat_sgmap; 202 t->_next_window = &pcp->pc_dmat_sgmap;
150 t->_boundary = 0; 203 t->_boundary = 0;
151 t->_sgmap = NULL; 204 t->_sgmap = NULL;
152 t->_get_tag = tsp_dma_get_tag; 205 t->_get_tag = tsp_dma_get_tag;
153 t->_dmamap_create = _bus_dmamap_create; 206 t->_dmamap_create = _bus_dmamap_create;
154 t->_dmamap_destroy = _bus_dmamap_destroy; 207 t->_dmamap_destroy = _bus_dmamap_destroy;
155 t->_dmamap_load = _bus_dmamap_load_direct; 208 t->_dmamap_load = _bus_dmamap_load_direct;
156 t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct; 209 t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
157 t->_dmamap_load_uio = _bus_dmamap_load_uio_direct; 210 t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
158 t->_dmamap_load_raw = _bus_dmamap_load_raw_direct; 211 t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
159 t->_dmamap_unload = _bus_dmamap_unload; 212 t->_dmamap_unload = _bus_dmamap_unload;
160 t->_dmamap_sync = _bus_dmamap_sync; 213 t->_dmamap_sync = _bus_dmamap_sync;
161 214
162 t->_dmamem_alloc = _bus_dmamem_alloc; 215 t->_dmamem_alloc = _bus_dmamem_alloc;
163 t->_dmamem_free = _bus_dmamem_free; 216 t->_dmamem_free = _bus_dmamem_free;
164 t->_dmamem_map = _bus_dmamem_map; 217 t->_dmamem_map = _bus_dmamem_map;
165 t->_dmamem_unmap = _bus_dmamem_unmap; 218 t->_dmamem_unmap = _bus_dmamem_unmap;
166 t->_dmamem_mmap = _bus_dmamem_mmap; 219 t->_dmamem_mmap = _bus_dmamem_mmap;
167 220
168 /* 221 /*
169 * Initialize the DMA tag used for sgmap-mapped DMA. 222 * Initialize the DMA tag used for sgmap-mapped DMA.
170 */ 223 */
171 t = &pcp->pc_dmat_sgmap; 224 t = &pcp->pc_dmat_sgmap;
172 t->_cookie = pcp; 225 t->_cookie = pcp;
173 t->_wbase = sgwbase = WSBA_ADDR(pccsr->tsp_wsba[0].tsg_r); 226 t->_wbase = sgwbase = WSBA_ADDR(pccsr->tsp_wsba[0].tsg_r);
174 t->_wsize = sgwlen = WSM_LEN(pccsr->tsp_wsm[0].tsg_r); 227 t->_wsize = sgwlen = WSM_LEN(pccsr->tsp_wsm[0].tsg_r);
175 t->_next_window = NULL; 228 t->_next_window = NULL;
176 t->_boundary = 0; 229 t->_boundary = 0;
177 t->_sgmap = &pcp->pc_sgmap; 230 t->_sgmap = &pcp->pc_sgmap;
178 t->_pfthresh = TSP_SGMAP_PFTHRESH; 231 t->_pfthresh = TSP_SGMAP_PFTHRESH;
179 t->_get_tag = tsp_dma_get_tag; 232 t->_get_tag = tsp_dma_get_tag;
180 t->_dmamap_create = alpha_sgmap_dmamap_create; 233 t->_dmamap_create = alpha_sgmap_dmamap_create;
181 t->_dmamap_destroy = alpha_sgmap_dmamap_destroy; 234 t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
182 t->_dmamap_load = tsp_bus_dmamap_load_sgmap; 235 t->_dmamap_load = tsp_bus_dmamap_load_sgmap;
183 t->_dmamap_load_mbuf = tsp_bus_dmamap_load_mbuf_sgmap; 236 t->_dmamap_load_mbuf = tsp_bus_dmamap_load_mbuf_sgmap;
184 t->_dmamap_load_uio = tsp_bus_dmamap_load_uio_sgmap; 237 t->_dmamap_load_uio = tsp_bus_dmamap_load_uio_sgmap;
185 t->_dmamap_load_raw = tsp_bus_dmamap_load_raw_sgmap; 238 t->_dmamap_load_raw = tsp_bus_dmamap_load_raw_sgmap;
186 t->_dmamap_unload = tsp_bus_dmamap_unload_sgmap; 239 t->_dmamap_unload = tsp_bus_dmamap_unload_sgmap;
187 t->_dmamap_sync = _bus_dmamap_sync; 240 t->_dmamap_sync = _bus_dmamap_sync;
188 241
189 t->_dmamem_alloc = _bus_dmamem_alloc; 242 t->_dmamem_alloc = _bus_dmamem_alloc;
190 t->_dmamem_free = _bus_dmamem_free; 243 t->_dmamem_free = _bus_dmamem_free;
191 t->_dmamem_map = _bus_dmamem_map; 244 t->_dmamem_map = _bus_dmamem_map;
192 t->_dmamem_unmap = _bus_dmamem_unmap; 245 t->_dmamem_unmap = _bus_dmamem_unmap;
193 t->_dmamem_mmap = _bus_dmamem_mmap; 246 t->_dmamem_mmap = _bus_dmamem_mmap;
194 247
195 /* 248 /*
196 * Initialize the SGMAP. Align page table to 32k in case 249 * Initialize the SGMAP. Align page table to 32k in case
197 * window is somewhat larger than expected. 250 * window is somewhat larger than expected.
198 */ 251 */
199 alpha_sgmap_init(t, &pcp->pc_sgmap, "tsp_sgmap", 252 alpha_sgmap_init(t, &pcp->pc_sgmap, "tsp_sgmap",
200 sgwbase, 0, sgwlen, sizeof(uint64_t), NULL, (32*1024)); 253 sgwbase, 0, sgwlen, sizeof(uint64_t), NULL, (32*1024));
201 254
202 /* 255 /*
203 * Enable window 0 and enable SG PTE mapping. 256 * Enable window 0 and enable SG PTE mapping.
204 */ 257 */
205 alpha_mb(); 258 alpha_mb();
206 pccsr->tsp_wsba[0].tsg_r |= WSBA_SG | WSBA_ENA; 259 pccsr->tsp_wsba[0].tsg_r |= WSBA_SG | WSBA_ENA;
207 alpha_mb(); 260 alpha_mb();
208 261
209 /* 262 /*
210 * Enable window 1 in direct mode. 263 * Enable window 1 in direct mode.
211 */ 264 */
212 alpha_mb(); 265 alpha_mb();
213 pccsr->tsp_wsba[1].tsg_r = 266 pccsr->tsp_wsba[1].tsg_r =
214 (pccsr->tsp_wsba[1].tsg_r & ~WSBA_SG) | WSBA_ENA; 267 (pccsr->tsp_wsba[1].tsg_r & ~WSBA_SG) | WSBA_ENA;
215 alpha_mb(); 268 alpha_mb();
216 269
217 /* 270 /*
218 * Check windows for sanity, especially if we later decide to 271 * Check windows for sanity, especially if we later decide to
219 * use the firmware's initialization in some cases. 272 * use the firmware's initialization in some cases.
220 */ 273 */
221 if ((sgwbase <= dwbase && dwbase < sgwbase + sgwlen) || 274 if ((sgwbase <= dwbase && dwbase < sgwbase + sgwlen) ||
222 (dwbase <= sgwbase && sgwbase < dwbase + dwlen)) 275 (dwbase <= sgwbase && sgwbase < dwbase + dwlen))
223 panic("tsp_dma_init: overlap"); 276 panic("tsp_dma_init: overlap");
224 277
225 tbase = pcp->pc_sgmap.aps_ptpa; 278 tbase = pcp->pc_sgmap.aps_ptpa;
226 if (tbase & ~0x7fffffc00UL) 279 if (tbase & ~0x7fffffc00UL)
227 panic("tsp_dma_init: bad page table address"); 280 panic("tsp_dma_init: bad page table address");
228 alpha_mb(); 281 alpha_mb();
229 pccsr->tsp_tba[0].tsg_r = tbase; 282 pccsr->tsp_tba[0].tsg_r = tbase;
230 alpha_mb(); 283 alpha_mb();
231 284
232 tsp_tlb_invalidate(pcp); 285 tsp_tlb_invalidate(pcp);
233 alpha_mb(); 286 alpha_mb();
234} 287}
235 288
236/* 289/*
237 * Return the bus dma tag to be used for the specified bus type. 290 * Return the bus dma tag to be used for the specified bus type.
238 * INTERNAL USE ONLY! 291 * INTERNAL USE ONLY!
239 */ 292 */
240static bus_dma_tag_t 293static bus_dma_tag_t
241tsp_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype) 294tsp_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
242{ 295{
243 struct tsp_config *pcp = t->_cookie; 296 struct tsp_config *pcp = t->_cookie;
244 297
245 switch (bustype) { 298 switch (bustype) {
246 case ALPHA_BUS_PCI: 299 case ALPHA_BUS_PCI:
247 case ALPHA_BUS_EISA: 300 case ALPHA_BUS_EISA:
248 /* 301 /*
249 * The direct mapped window will work for most systems, 302 * The direct mapped window will work for most systems,
250 * most of the time. When it doesn't, we chain to the sgmap 303 * most of the time. When it doesn't, we chain to the sgmap
251 * window automatically. 304 * window automatically.
252 */ 305 */
253 return (&pcp->pc_dmat_direct); 306 return (&pcp->pc_dmat_direct);
254 307
255 case ALPHA_BUS_ISA: 308 case ALPHA_BUS_ISA:
256 /* 309 /*
257 * ISA doesn't have enough address bits to use 310 * ISA doesn't have enough address bits to use
258 * the direct-mapped DMA window, so we must use 311 * the direct-mapped DMA window, so we must use
259 * SGMAPs. 312 * SGMAPs.
260 */ 313 */
261 return (&pcp->pc_dmat_sgmap); 314 return (&pcp->pc_dmat_sgmap);
262 315
263 default: 316 default:
264 panic("tsp_dma_get_tag: shouldn't be here, really..."); 317 panic("tsp_dma_get_tag: shouldn't be here, really...");
265 } 318 }
266} 319}
267 320
268/* 321/*
269 * Load a TSP SGMAP-mapped DMA map with a linear buffer. 322 * Load a TSP SGMAP-mapped DMA map with a linear buffer.
270 */ 323 */
271static int 324static int
272tsp_bus_dmamap_load_sgmap(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen, struct proc *p, int flags) 325tsp_bus_dmamap_load_sgmap(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen, struct proc *p, int flags)
273{ 326{
274 int error; 327 int error;
275 328
276 error = pci_sgmap_pte64_load(t, map, buf, buflen, p, flags, 329 error = pci_sgmap_pte64_load(t, map, buf, buflen, p, flags,
277 t->_sgmap); 330 t->_sgmap);
278 if (error == 0) 331 if (error == 0)
279 tsp_tlb_invalidate(t->_cookie); 332 tsp_tlb_invalidate(t->_cookie);
280 333
281 return (error); 334 return (error);
282} 335}
283 336
284/* 337/*
285 * Load a TSP SGMAP-mapped DMA map with an mbuf chain. 338 * Load a TSP SGMAP-mapped DMA map with an mbuf chain.
286 */ 339 */
287static int 340static int
288tsp_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m, int flags) 341tsp_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m, int flags)
289{ 342{
290 int error; 343 int error;
291 344
292 error = pci_sgmap_pte64_load_mbuf(t, map, m, flags, t->_sgmap); 345 error = pci_sgmap_pte64_load_mbuf(t, map, m, flags, t->_sgmap);
293 if (error == 0) 346 if (error == 0)
294 tsp_tlb_invalidate(t->_cookie); 347 tsp_tlb_invalidate(t->_cookie);
295 348
296 return (error); 349 return (error);
297} 350}
298 351
299/* 352/*
300 * Load a TSP SGMAP-mapped DMA map with a uio. 353 * Load a TSP SGMAP-mapped DMA map with a uio.
301 */ 354 */
302static int 355static int
303tsp_bus_dmamap_load_uio_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio, int flags) 356tsp_bus_dmamap_load_uio_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio, int flags)
304{ 357{
305 int error; 358 int error;
306 359
307 error = pci_sgmap_pte64_load_uio(t, map, uio, flags, t->_sgmap); 360 error = pci_sgmap_pte64_load_uio(t, map, uio, flags, t->_sgmap);
308 if (error == 0) 361 if (error == 0)
309 tsp_tlb_invalidate(t->_cookie); 362 tsp_tlb_invalidate(t->_cookie);
310 363
311 return (error); 364 return (error);
312} 365}
313 366
314/* 367/*
315 * Load a TSP SGMAP-mapped DMA map with raw memory. 368 * Load a TSP SGMAP-mapped DMA map with raw memory.
316 */ 369 */
317static int 370static int
318tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags) 371tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
319{ 372{
320 int error; 373 int error;
321 374
322 error = pci_sgmap_pte64_load_raw(t, map, segs, nsegs, size, flags, 375 error = pci_sgmap_pte64_load_raw(t, map, segs, nsegs, size, flags,
323 t->_sgmap); 376 t->_sgmap);
324 if (error == 0) 377 if (error == 0)
325 tsp_tlb_invalidate(t->_cookie); 378 tsp_tlb_invalidate(t->_cookie);
326 379
327 return (error); 380 return (error);
328} 381}
329 382
330/* 383/*
331 * Unload a TSP DMA map. 384 * Unload a TSP DMA map.
332 */ 385 */
333static void 386static void
334tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t t, bus_dmamap_t map) 387tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t t, bus_dmamap_t map)
335{ 388{
336 389
337 /* 390 /*
338 * Invalidate any SGMAP page table entries used by this 391 * Invalidate any SGMAP page table entries used by this
339 * mapping. 392 * mapping.
340 */ 393 */
341 pci_sgmap_pte64_unload(t, map, t->_sgmap); 394 pci_sgmap_pte64_unload(t, map, t->_sgmap);
342 tsp_tlb_invalidate(t->_cookie); 395 tsp_tlb_invalidate(t->_cookie);
343 396
344 /* 397 /*
345 * Do the generic bits of the unload. 398 * Do the generic bits of the unload.
346 */ 399 */
347 _bus_dmamap_unload_common(t, map); 400 _bus_dmamap_unload_common(t, map);
348} 401}
349 402
350/* 403/*
351 * Flush the TSP scatter/gather TLB. 404 * Flush the TSP scatter/gather TLB.
352 */ 405 */
353static void 406static void
354tsp_tlb_invalidate(struct tsp_config *pcp) 407tsp_tlb_invalidate(struct tsp_config *pcp)
355{ 408{
356 409
357 alpha_mb(); 410 alpha_mb();
358 *pcp->pc_tlbia = 0; 411 *pcp->pc_tlbia = 0;
359 alpha_mb(); 412 alpha_mb();
360} 413}

cvs diff -r1.8 -r1.9 src/sys/arch/alpha/pci/tsreg.h (switch to unified diff)

--- src/sys/arch/alpha/pci/tsreg.h 2020/09/23 00:46:17 1.8
+++ src/sys/arch/alpha/pci/tsreg.h 2021/05/27 22:11:31 1.9
@@ -1,290 +1,313 @@ @@ -1,290 +1,313 @@
1/* $NetBSD: tsreg.h,v 1.8 2020/09/23 00:46:17 thorpej Exp $ */ 1/* $NetBSD: tsreg.h,v 1.9 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 4 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement: 15 * must display the following acknowledgement:
16 * This product includes software developed by Ross Harvey. 16 * This product includes software developed by Ross Harvey.
17 * 4. The name of Ross Harvey may not be used to endorse or promote products 17 * 4. The name of Ross Harvey may not be used to endorse or promote products
18 * derived from this software without specific prior written permission. 18 * derived from this software without specific prior written permission.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS 20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY 23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 */ 32 */
33 33
34/* 34/*
35 * 21272 Core Logic registers and constants. 35 * 21272 Core Logic registers and constants.
36 */ 36 */
37 37
38#define tsreg() { Generate ctags(1) key. } 38#define tsreg() { Generate ctags(1) key. }
39 39
40/* 40/*
41 * Superpage pointer from physical address. 41 * Superpage pointer from physical address.
42 */ 42 */
43#define S_PAGE(phys) ((void *)ALPHA_PHYS_TO_K0SEG(phys)) 43#define S_PAGE(phys) ((void *)ALPHA_PHYS_TO_K0SEG(phys))
44 44
45/* 45/*
46 * {LD,ST}QP: LoaD and STore Quad Physical 46 * {LD,ST}QP: LoaD and STore Quad Physical
47 */ 47 */
48#define LDQP(a) (*(volatile long *)ALPHA_PHYS_TO_K0SEG(a)) 48#define LDQP(a) (*(volatile long *)ALPHA_PHYS_TO_K0SEG(a))
49#define STQP(a) LDQP(a) 49#define STQP(a) LDQP(a)
50 50
51/* 51/*
52 * Define extraction functions for bit fields via length and left,right bitno 52 * Define extraction functions for bit fields via length and left,right bitno
53 */ 53 */
54#define TSFIELD(r,offs,len) (((r) >> (offs)) & (~0UL >> (64 - (len)))) 54#define TSFIELD(r,offs,len) (((r) >> (offs)) & (~0UL >> (64 - (len))))
55#define TSFIELDBB(r,lb,rb) TSFIELD((r), (rb), (lb) - (rb) + 1) 55#define TSFIELDBB(r,lb,rb) TSFIELD((r), (rb), (lb) - (rb) + 1)
56 56
57/* 57/*
58 * EV6 has a new superpage which can pass through 44 address bits. (Umm, a 58 * EV6 has a new superpage which can pass through 44 address bits. (Umm, a
59 * superduperpage?) But, the firmware doesn't turn it on, so we use the old 59 * superduperpage?) But, the firmware doesn't turn it on, so we use the old
60 * one and let the HW sign extend va/pa<40> to get us the pa<43> that makes 60 * one and let the HW sign extend va/pa<40> to get us the pa<43> that makes
61 * the needed I/O space access. This is just as well; it means we don't have 61 * the needed I/O space access. This is just as well; it means we don't have
62 * to worry about which GENERIC code might get called on other CPU models. 62 * to worry about which GENERIC code might get called on other CPU models.
63 * 63 *
64 * E.g., we want this: 0x0801##a000##0000 64 * E.g., we want this: 0x0801##a000##0000
65 * We use this: 0x0101##a000##0000 65 * We use this: 0x0101##a000##0000
66 * ...mix in the old SP: 0xffff##fc00##0000##0000 66 * ...mix in the old SP: 0xffff##fc00##0000##0000
67 * ...after PA sign ext: 0xffff##ff00##a000##0000 67 * ...after PA sign ext: 0xffff##ff00##a000##0000
68 * (PA<42:41> ignored) 68 * (PA<42:41> ignored)
69 */ 69 */
70 70
71/* 71/*
72 * This hack allows us to map the I/O address space without using 72 * This hack allows us to map the I/O address space without using
73 * the KSEG sign extension hack. 73 * the KSEG sign extension hack.
74 */ 74 */
75#define TS_PHYSADDR(x) \ 75#define TS_PHYSADDR(x) \
76 (((x) & ~0x0100##0000##0000) | 0x0800##0000##0000) 76 (((x) & ~0x0100##0000##0000) | 0x0800##0000##0000)
77 77
78/* 78/*
79 * Cchip CSR Map 79 * Cchip CSR Map
80 */ 80 */
81 81
82#define TS_C_CSC 0x101##a000##0000UL /* Cchip System Configuration */ 82#define TS_C_CSC 0x101##a000##0000UL /* Cchip System Configuration */
83 83
84# define CSC_P1P (1L << 14) 84# define CSC_P1P (1L << 14)
85# define CSC_BC(r) TSFIELD((r), 0, 2) 85# define CSC_BC(r) TSFIELD((r), 0, 2)
86# define CSC_AW (1L << 8) 86# define CSC_AW (1L << 8)
87 87
88#define TS_C_MTR 0x101##a000##0040UL 88#define TS_C_MTR 0x101##a000##0040UL
89 89
90#define TS_C_MISC 0x101##a000##0080UL /* Miscellaneous Register */ 90#define TS_C_MISC 0x101##a000##0080UL /* Miscellaneous Register */
91 91
92# define MISC_NXM(r) TSFIELD((r), 28, 1) 92# define MISC_NXM(r) TSFIELD((r), 28, 1)
93# define MISC_NXM_SRC(r) TSFIELD((r), 29, 3) 93# define MISC_NXM_SRC(r) TSFIELD((r), 29, 3)
94# define MISC_REV(r) TSFIELD((r), 39, 8) 94# define MISC_REV(r) TSFIELD((r), 39, 8)
95 95
96#define TS_C_MPD 0x101##a000##00c0UL 96#define TS_C_MPD 0x101##a000##00c0UL
97 97
98# define MPD_DR 0x08 /* RO: Data receive */ 98# define MPD_DR 0x08 /* RO: Data receive */
99# define MPD_CKR 0x04 /* RO: Clock receive */ 99# define MPD_CKR 0x04 /* RO: Clock receive */
100# define MPD_DS 0x02 /* WO: Data send - Must be a 1 to receive */ 100# define MPD_DS 0x02 /* WO: Data send - Must be a 1 to receive */
101# define MPD_CKS 0x01 /* WO: Clock send */ 101# define MPD_CKS 0x01 /* WO: Clock send */
102 102
103#define TS_C_AAR0 0x101##a000##0100UL 103#define TS_C_AAR0 0x101##a000##0100UL
104#define TS_C_AAR1 0x101##a000##0140UL 104#define TS_C_AAR1 0x101##a000##0140UL
105#define TS_C_AAR2 0x101##a000##0180UL 105#define TS_C_AAR2 0x101##a000##0180UL
106#define TS_C_AAR3 0x101##a000##01c0UL 106#define TS_C_AAR3 0x101##a000##01c0UL
107 107
108# define AAR_ASIZ(r) TSFIELD((r), 12, 4) 108# define AAR_ASIZ(r) TSFIELD((r), 12, 4)
109# define AAR_SPLIT (1L << 8) 109# define AAR_SPLIT (1L << 8)
110 110
111#define TS_C_DIM0 0x101##a000##0200UL 111#define TS_C_DIM0 0x101##a000##0200UL
112#define TS_C_DIM1 0x101##a000##0240UL 112#define TS_C_DIM1 0x101##a000##0240UL
113#define TS_C_DIR0 0x101##a000##0280UL 113#define TS_C_DIR0 0x101##a000##0280UL
114#define TS_C_DIR1 0x101##a000##02c0UL 114#define TS_C_DIR1 0x101##a000##02c0UL
115#define TS_C_DRIR 0x101##a000##0300UL 115#define TS_C_DRIR 0x101##a000##0300UL
116#define TS_C_PRBEN 0x101##a000##0340UL 116#define TS_C_PRBEN 0x101##a000##0340UL
117#define TS_C_IIC0 0x101##a000##0380UL 117#define TS_C_IIC0 0x101##a000##0380UL
118#define TS_C_IIC1 0x101##a000##03c0UL 118#define TS_C_IIC1 0x101##a000##03c0UL
119#define TS_C_MPR0 0x101##a000##0400UL 119#define TS_C_MPR0 0x101##a000##0400UL
120#define TS_C_MPR1 0x101##a000##0440UL 120#define TS_C_MPR1 0x101##a000##0440UL
121#define TS_C_MPR2 0x101##a000##0480UL 121#define TS_C_MPR2 0x101##a000##0480UL
122#define TS_C_MPR3 0x101##a000##04c0UL 122#define TS_C_MPR3 0x101##a000##04c0UL
123#define TS_C_MCTL 0x101##a000##0500UL 123#define TS_C_MCTL 0x101##a000##0500UL
124 124
125#define TS_C_TTR 0x101##a000##0580UL 125#define TS_C_TTR 0x101##a000##0580UL
126#define TS_C_TDR 0x101##a000##05c0UL 126#define TS_C_TDR 0x101##a000##05c0UL
127#define TS_C_DIM2 0x101##a000##0600UL 127#define TS_C_DIM2 0x101##a000##0600UL
128#define TS_C_DIM3 0x101##a000##0640UL 128#define TS_C_DIM3 0x101##a000##0640UL
129#define TS_C_DIR2 0x101##a000##0680UL 129#define TS_C_DIR2 0x101##a000##0680UL
130#define TS_C_DIR3 0x101##a000##06c0UL 130#define TS_C_DIR3 0x101##a000##06c0UL
131#define TS_C_IIC2 0x101##a000##0700UL 131#define TS_C_IIC2 0x101##a000##0700UL
132#define TS_C_IIC3 0x101##a000##0740UL 132#define TS_C_IIC3 0x101##a000##0740UL
133 133
134/* 134/*
135 * Dchip CSR Map 135 * Dchip CSR Map
136 */ 136 */
137 137
138#define TS_D_DSC 0x101##b000##0800UL 138#define TS_D_DSC 0x101##b000##0800UL
139#define TS_D_STR 0x101##b000##0840UL 139#define TS_D_STR 0x101##b000##0840UL
140#define TS_D_DREV 0x101##b000##0880UL 140#define TS_D_DREV 0x101##b000##0880UL
141#define TS_D_DSC2 0x101##b000##08c0UL 141#define TS_D_DSC2 0x101##b000##08c0UL
142 142
143/* 143/*
144 * Pchip CSR Offsets 144 * Pchip CSR Offsets
145 */ 145 */
146 146
147#define P_WSBA0 0x0000 147#define P_WSBA0 0x0000
148#define P_WSBA1 0x0040 148#define P_WSBA1 0x0040
149#define P_WSBA2 0x0080 149#define P_WSBA2 0x0080
150#define P_WSBA3 0x00c0 150#define P_WSBA3 0x00c0
151 151
152# define WSBA_ADDR(r) (TSFIELDBB((r), 31, 20) << 20) 152# define WSBA_ADDR(r) (TSFIELDBB((r), 31, 20) << 20)
153# define WSBA_SG 2 153# define WSBA_SG 2
154# define WSBA_ENA 1 154# define WSBA_ENA 1
155 155
156#define P_WSM0 0x0100 156#define P_WSM0 0x0100
157#define P_WSM1 0x0140 157#define P_WSM1 0x0140
158#define P_WSM2 0x0180 158#define P_WSM2 0x0180
159#define P_WSM3 0x01c0 159#define P_WSM3 0x01c0
160 160
161# define WSM_AM(r) TSFIELDBB((r), 31, 20) 161# define WSM_AM(r) TSFIELDBB((r), 31, 20)
162# define WSM_LEN(r) ((WSM_AM(r) + 1) << 20) 162# define WSM_LEN(r) ((WSM_AM(r) + 1) << 20)
163 163
164#define P_TBA0 0x0200 164#define P_TBA0 0x0200
165#define P_TBA1 0x0240 165#define P_TBA1 0x0240
166#define P_TBA2 0x0280 166#define P_TBA2 0x0280
167#define P_TBA3 0x02c0 167#define P_TBA3 0x02c0
168 168
169#define P_PCTL 0x0300 169#define P_PCTL 0x0300
 170
 171#define PCTL_FDSC __BIT(0) /* fast discard enable */
 172#define PCTL_FBTB __BIT(1) /* fast back-to-back enable */
 173#define PCTL_THDIS __BIT(2) /* disable TLB anti-thrash (debug) */
 174#define PCTL_CHAINDIS __BIT(3) /* disable chaining */
 175#define PCTL_TGTLAT __BIT(4) /* target latency timers enable */
 176#define PCTL_HOLE __BIT(5) /* 512KB->1M hole enable */
 177#define PCTL_MWIN __BIT(6) /* monster window enable */
 178#define PCTL_PRIGRP __BITS(8,14) /* arbiter priority group */
 179#define PCTL_PPRI __BIT(15) /* arbiter priority group for Pchip */
 180#define PCTL_ECCEN __BIT(18) /* ECC enable for DMA and SGTE */
 181#define PCTL_PADM __BIT(19) /* PADbus mode */
 182#define PCTL_CDQMAX __BITS(20,23) /* see manual */
 183#define PCTL_REV __BITS(24,31) /* Pchip revision */
 184#define PCTL_CRQMAX __BITS(32,35) /* see manual */
 185#define PCTL_PTPMAX __BITS(36,39) /* see manual */
 186#define PCTL_PCLKX __BITS(40,41) /* PCI clock freq multipler */
 187#define PCTL_FDSDIS __BIT(42) /* fast DMA start and SGTE disable */
 188#define PCTL_FDWDIS __BIT(43) /* fast DMA read cache block disable */
 189#define PCTL_PTEVRFY __BIT(44) /* PTE verify for DMA read */
 190#define PCTL_RPP __BIT(45) /* remote Pchip present */
 191#define PCTL_PID __BITS(46,47) /* Pchip ID */
 192
170#define P_PLAT 0x0340 193#define P_PLAT 0x0340
171 /* reserved 0x0380 */ 194 /* reserved 0x0380 */
172#define P_PERROR 0x03c0 195#define P_PERROR 0x03c0
173 196
174# define PER_ERR(r) TSFIELD((r), 0, 12) 197# define PER_ERR(r) TSFIELD((r), 0, 12)
175# define PER_ECC(r) TSFIELD((r), 10, 2) 198# define PER_ECC(r) TSFIELD((r), 10, 2)
176# define PER_SADR(r) TSFIELD((r), 16, 34) 199# define PER_SADR(r) TSFIELD((r), 16, 34)
177# define PER_PADR(r) (TSFIELD((r), 18, 32) << 2) 200# define PER_PADR(r) (TSFIELD((r), 18, 32) << 2)
178# define PER_TRNS(r) TSFIELD((r), 16, 2) 201# define PER_TRNS(r) TSFIELD((r), 16, 2)
179# define PER_INV(r) TSFIELD((r), 51, 1) 202# define PER_INV(r) TSFIELD((r), 51, 1)
180# define PER_CMD(r) TSFIELD((r), 52, 4) 203# define PER_CMD(r) TSFIELD((r), 52, 4)
181# define PER_SYN(r) TSFIELD((r), 56, 8) 204# define PER_SYN(r) TSFIELD((r), 56, 8)
182 205
183#define P_PERRMASK 0x0400 206#define P_PERRMASK 0x0400
184#define P_PERRSET 0x0440 207#define P_PERRSET 0x0440
185#define P_TLBIV 0x0480 208#define P_TLBIV 0x0480
186#define P_TLBIA 0x04c0 209#define P_TLBIA 0x04c0
187 210
188#define P_PMONCTL 0x0500 211#define P_PMONCTL 0x0500
189#define P_PMONCNT 0x0540 212#define P_PMONCNT 0x0540
190 213
191#define P_SPRST 0x0800 214#define P_SPRST 0x0800
192 215
193#define TS_STEP 0x40 216#define TS_STEP 0x40
194 217
195/* 218/*
196 * Pchip I/O offsets 219 * Pchip I/O offsets
197 */ 220 */
198 221
199#define P_CSRBASE 0x001##8000##0000UL 222#define P_CSRBASE 0x001##8000##0000UL
200#define P_PCI_MEM 0x800##0000##0000UL 223#define P_PCI_MEM 0x800##0000##0000UL
201#define P_PCI_IO 0x001##fc00##0000UL 224#define P_PCI_IO 0x001##fc00##0000UL
202#define P_PCI_CONFIG 0x001##fe00##0000UL 225#define P_PCI_CONFIG 0x001##fe00##0000UL
203 226
204/* 227/*
205 * Construct EV6 I/O Space Address for Pchip 0 and Pchip 1. 228 * Construct EV6 I/O Space Address for Pchip 0 and Pchip 1.
206 */ 229 */
207 230
208#define TS_P0(offs) (0x100##0000##0000UL + (offs)) 231#define TS_P0(offs) (0x100##0000##0000UL + (offs))
209#define TS_P1(offs) (0x102##0000##0000UL + (offs)) 232#define TS_P1(offs) (0x102##0000##0000UL + (offs))
210#define TS_Pn(n, offs) (0x100##0000##0000UL + 0x2##0000##0000UL * (n) + (offs)) 233#define TS_Pn(n, offs) (0x100##0000##0000UL + 0x2##0000##0000UL * (n) + (offs))
211 234
212/* 235/*
213 * Tsunami Generic Register Type 236 * Tsunami Generic Register Type
214 */ 237 */
215typedef struct _ts_gr { 238typedef struct _ts_gr {
216 volatile uint64_t tsg_r; 239 volatile uint64_t tsg_r;
217 long tsg_deadspace[7]; 240 long tsg_deadspace[7];
218} TS_GR; 241} TS_GR;
219 242
220/* 243/*
221 * Tsunami Pchip 244 * Tsunami Pchip
222 */ 245 */
223struct ts_pport { 246struct ts_pport {
224 TS_GR tsp_resA; 247 TS_GR tsp_resA;
225 TS_GR tsp_error; /* Pchip Error */ 248 TS_GR tsp_error; /* Pchip Error */
226 249
227 TS_GR tsp_perrmask; /* Pchip Error Mask */ 250 TS_GR tsp_perrmask; /* Pchip Error Mask */
228 TS_GR tsp_perrset; /* Pchip Error Set */ 251 TS_GR tsp_perrset; /* Pchip Error Set */
229 TS_GR tsp_tlbiv; /* Translation Buffer Invalidate Virtual */ 252 TS_GR tsp_tlbiv; /* Translation Buffer Invalidate Virtual */
230 TS_GR tsp_tlbia; /* Translation Buffer Invalidate All */ 253 TS_GR tsp_tlbia; /* Translation Buffer Invalidate All */
231 254
232 TS_GR tsp_pmonctl; /* PChip Monitor Control */ 255 TS_GR tsp_pmonctl; /* PChip Monitor Control */
233 TS_GR tsp_pmoncnt; /* PChip Monitor Counters */ 256 TS_GR tsp_pmoncnt; /* PChip Monitor Counters */
234 TS_GR tsp_resB; 257 TS_GR tsp_resB;
235 TS_GR tsp_resC; 258 TS_GR tsp_resC;
236 259
237 TS_GR tsp_resD_K[8]; 260 TS_GR tsp_resD_K[8];
238}; 261};
239 262
240struct ts_gport { 263struct ts_gport {
241 TS_GR tsp_resA[2]; 264 TS_GR tsp_resA[2];
242 TS_GR tsp_serror; 265 TS_GR tsp_serror;
243 TS_GR tsp_serrmask; 266 TS_GR tsp_serrmask;
244 TS_GR tsp_serrset; 267 TS_GR tsp_serrset;
245 TS_GR tsp_resB; 268 TS_GR tsp_resB;
246 TS_GR tsp_gperrmask; 269 TS_GR tsp_gperrmask;
247 TS_GR tsp_gperren; 270 TS_GR tsp_gperren;
248 TS_GR tsp_gperrset; 271 TS_GR tsp_gperrset;
249 TS_GR tsp_resC; 272 TS_GR tsp_resC;
250 TS_GR tsp_tlbiv; 273 TS_GR tsp_tlbiv;
251 TS_GR tsp_tlbia; 274 TS_GR tsp_tlbia;
252 TS_GR tsp_resD[2]; 275 TS_GR tsp_resD[2];
253 TS_GR tsp_sctl; 276 TS_GR tsp_sctl;
254 TS_GR tsp_resE[3]; 277 TS_GR tsp_resE[3];
255}; 278};
256 279
257struct ts_aport { 280struct ts_aport {
258 TS_GR tsp_resA[2]; 281 TS_GR tsp_resA[2];
259 TS_GR tsp_agperror; 282 TS_GR tsp_agperror;
260 TS_GR tsp_agperrmask; 283 TS_GR tsp_agperrmask;
261 TS_GR tsp_agperrset; 284 TS_GR tsp_agperrset;
262 TS_GR tsp_agplastwr; 285 TS_GR tsp_agplastwr;
263 TS_GR tsp_aperror; 286 TS_GR tsp_aperror;
264 TS_GR tsp_aperrmask; 287 TS_GR tsp_aperrmask;
265 TS_GR tsp_aperrset; 288 TS_GR tsp_aperrset;
266 TS_GR tsp_resB; 289 TS_GR tsp_resB;
267 TS_GR tsp_tlbiv; 290 TS_GR tsp_tlbiv;
268 TS_GR tsp_tlbia; 291 TS_GR tsp_tlbia;
269 TS_GR tsp_resC[6]; 292 TS_GR tsp_resC[6];
270}; 293};
271 294
272struct ts_pchip { 295struct ts_pchip {
273 TS_GR tsp_wsba[4]; /* Window Space Base Address */ 296 TS_GR tsp_wsba[4]; /* Window Space Base Address */
274 297
275 TS_GR tsp_wsm[4]; /* Window Space Mask */ 298 TS_GR tsp_wsm[4]; /* Window Space Mask */
276 299
277 TS_GR tsp_tba[4]; /* Translated Base Address */ 300 TS_GR tsp_tba[4]; /* Translated Base Address */
278 301
279 TS_GR tsp_pctl; /* Pchip Control */ 302 TS_GR tsp_pctl; /* Pchip Control */
280 TS_GR tsp_plat; /* Pchip Latency */ 303 TS_GR tsp_plat; /* Pchip Latency */
281 304
282 union { 305 union {
283 struct ts_pport p; 306 struct ts_pport p;
284 struct ts_gport g; 307 struct ts_gport g;
285 struct ts_aport a; 308 struct ts_aport a;
286 } port; 309 } port;
287 310
288 TS_GR tsp_sprts; /* ??? */ 311 TS_GR tsp_sprts; /* ??? */
289 TS_GR tsp_res[31]; 312 TS_GR tsp_res[31];
290}; 313};

cvs diff -r1.14 -r1.15 src/sys/arch/alpha/pci/tsvar.h (switch to unified diff)

--- src/sys/arch/alpha/pci/tsvar.h 2020/06/17 03:50:04 1.14
+++ src/sys/arch/alpha/pci/tsvar.h 2021/05/27 22:11:31 1.15
@@ -1,99 +1,100 @@ @@ -1,99 +1,100 @@
1/* $NetBSD: tsvar.h,v 1.14 2020/06/17 03:50:04 thorpej Exp $ */ 1/* $NetBSD: tsvar.h,v 1.15 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 4 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement: 15 * must display the following acknowledgement:
16 * This product includes software developed by Ross Harvey. 16 * This product includes software developed by Ross Harvey.
17 * 4. The name of Ross Harvey may not be used to endorse or promote products 17 * 4. The name of Ross Harvey may not be used to endorse or promote products
18 * derived from this software without specific prior written permission. 18 * derived from this software without specific prior written permission.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS 20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY 23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 */ 32 */
33 33
34#include <sys/extent.h> 34#include <sys/extent.h>
35#include <dev/isa/isavar.h> 35#include <dev/isa/isavar.h>
36#include <dev/pci/pcivar.h> 36#include <dev/pci/pcivar.h>
37#include <dev/i2c/i2cvar.h> 37#include <dev/i2c/i2cvar.h>
38#include <alpha/pci/pci_sgmap_pte64.h> 38#include <alpha/pci/pci_sgmap_pte64.h>
39 39
40#define _FSTORE (EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)) 40#define _FSTORE (EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long))
41 41
42#define tsvar() { Generate ctags(1) key. } 42#define tsvar() { Generate ctags(1) key. }
43 43
44struct tsp_config { 44struct tsp_config {
45 int pc_pslot; /* Pchip 0 or 1 */ 45 int pc_pslot; /* Pchip 0 or 1 */
46 int pc_initted; /* Initialized */ 46 int pc_initted; /* Initialized */
47 uint64_t pc_iobase; /* All Pchip space starts here */ 47 uint64_t pc_iobase; /* All Pchip space starts here */
48 struct ts_pchip *pc_csr; /* Pchip CSR space starts here */ 48 struct ts_pchip *pc_csr; /* Pchip CSR space starts here */
49 volatile uint64_t *pc_tlbia; /* Pchip TLBIA register address */  49 volatile uint64_t *pc_tlbia; /* Pchip TLBIA register address */
50 50
51 struct alpha_bus_space pc_iot, pc_memt; 51 struct alpha_bus_space pc_iot, pc_memt;
52 struct alpha_pci_chipset pc_pc; 52 struct alpha_pci_chipset pc_pc;
53 53
 54 struct alpha_bus_dma_tag pc_dmat64_direct;
54 struct alpha_bus_dma_tag pc_dmat_direct; 55 struct alpha_bus_dma_tag pc_dmat_direct;
55 struct alpha_bus_dma_tag pc_dmat_sgmap; 56 struct alpha_bus_dma_tag pc_dmat_sgmap;
56 57
57 struct alpha_sgmap pc_sgmap; 58 struct alpha_sgmap pc_sgmap;
58 59
59 uint32_t pc_hae_mem; 60 uint32_t pc_hae_mem;
60 uint32_t pc_hae_io; 61 uint32_t pc_hae_io;
61 62
62 long pc_io_exstorage[_FSTORE]; 63 long pc_io_exstorage[_FSTORE];
63 long pc_mem_exstorage[_FSTORE]; 64 long pc_mem_exstorage[_FSTORE];
64 struct extent *pc_io_ex, *pc_mem_ex; 65 struct extent *pc_io_ex, *pc_mem_ex;
65 int pc_mallocsafe; 66 int pc_mallocsafe;
66}; 67};
67 68
68struct tsp_attach_args { 69struct tsp_attach_args {
69 const char *tsp_name; 70 const char *tsp_name;
70 int tsp_slot; 71 int tsp_slot;
71}; 72};
72 73
73struct tsciic_softc { 74struct tsciic_softc {
74 device_t sc_dev; 75 device_t sc_dev;
75 struct i2c_controller sc_i2c; 76 struct i2c_controller sc_i2c;
76}; 77};
77 78
78struct tsciic_attach_args { 79struct tsciic_attach_args {
79 const char *tsciic_name; 80 const char *tsciic_name;
80}; 81};
81 82
82extern int tsp_console_hose; 83extern int tsp_console_hose;
83 84
84struct tsp_config *tsp_init(int, int); 85struct tsp_config *tsp_init(int, int);
85void tsp_pci_init(pci_chipset_tag_t, void *); 86void tsp_pci_init(pci_chipset_tag_t, void *);
86void tsp_dma_init(struct tsp_config *); 87void tsp_dma_init(struct tsp_config *);
87 88
88void tsp_bus_io_init(bus_space_tag_t, void *); 89void tsp_bus_io_init(bus_space_tag_t, void *);
89void tsp_bus_mem_init(bus_space_tag_t, void *); 90void tsp_bus_mem_init(bus_space_tag_t, void *);
90 91
91void tsp_bus_mem_init2(bus_space_tag_t, void *); 92void tsp_bus_mem_init2(bus_space_tag_t, void *);
92 93
93void tsciic_init(device_t); 94void tsciic_init(device_t);
94 95
95void tsp_print_error(unsigned int, unsigned long); 96void tsp_print_error(unsigned int, unsigned long);
96void tsc_print_misc(unsigned int, unsigned long); 97void tsc_print_misc(unsigned int, unsigned long);
97void tsc_print_dir(unsigned int, unsigned long); 98void tsc_print_dir(unsigned int, unsigned long);
98 99
99#define IPRINTF(i, f, ...) printf("%*s" f, i * 4, "", ##__VA_ARGS__) 100#define IPRINTF(i, f, ...) printf("%*s" f, i * 4, "", ##__VA_ARGS__)