Thu Jun 25 16:40:40 2020 UTC ()
Include all necessary letters in the word "Cryptographic".


(thorpej)
diff -r1.1 -r1.2 src/sys/dev/pci/amdccp_pci.c

cvs diff -r1.1 -r1.2 src/sys/dev/pci/amdccp_pci.c (switch to unified diff)

--- src/sys/dev/pci/amdccp_pci.c 2020/06/24 03:38:01 1.1
+++ src/sys/dev/pci/amdccp_pci.c 2020/06/25 16:40:40 1.2
@@ -1,119 +1,119 @@ @@ -1,119 +1,119 @@
1/* $NetBSD: amdccp_pci.c,v 1.1 2020/06/24 03:38:01 thorpej Exp $ */ 1/* $NetBSD: amdccp_pci.c,v 1.2 2020/06/25 16:40:40 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2020 The NetBSD Foundation, Inc. 4 * Copyright (c) 2020 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe. 8 * by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: amdccp_pci.c,v 1.1 2020/06/24 03:38:01 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: amdccp_pci.c,v 1.2 2020/06/25 16:40:40 thorpej Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/bus.h> 36#include <sys/bus.h>
37#include <sys/cpu.h> 37#include <sys/cpu.h>
38#include <sys/device.h> 38#include <sys/device.h>
39 39
40#include <dev/pci/pcireg.h> 40#include <dev/pci/pcireg.h>
41#include <dev/pci/pcivar.h> 41#include <dev/pci/pcivar.h>
42#include <dev/pci/pcidevs.h> 42#include <dev/pci/pcidevs.h>
43 43
44#include <dev/ic/amdccpvar.h> 44#include <dev/ic/amdccpvar.h>
45 45
46static int amdccp_pci_match(device_t, cfdata_t, void *); 46static int amdccp_pci_match(device_t, cfdata_t, void *);
47static void amdccp_pci_attach(device_t, device_t, void *); 47static void amdccp_pci_attach(device_t, device_t, void *);
48 48
49CFATTACH_DECL_NEW(amdccp_pci, sizeof(struct amdccp_softc), 49CFATTACH_DECL_NEW(amdccp_pci, sizeof(struct amdccp_softc),
50 amdccp_pci_match, amdccp_pci_attach, NULL, NULL); 50 amdccp_pci_match, amdccp_pci_attach, NULL, NULL);
51 51
52#define AMDCCP_MEM_BAR PCI_BAR2 52#define AMDCCP_MEM_BAR PCI_BAR2
53 53
54static const struct amdccp_pci_product { 54static const struct amdccp_pci_product {
55 pci_vendor_id_t vendor; 55 pci_vendor_id_t vendor;
56 pci_product_id_t product; 56 pci_product_id_t product;
57} amdccp_pci_products[] = { 57} amdccp_pci_products[] = {
58 { .vendor = PCI_VENDOR_AMD, 58 { .vendor = PCI_VENDOR_AMD,
59 .product = PCI_PRODUCT_AMD_F16_CCP, 59 .product = PCI_PRODUCT_AMD_F16_CCP,
60 }, 60 },
61 { .vendor = PCI_VENDOR_AMD, 61 { .vendor = PCI_VENDOR_AMD,
62 .product = PCI_PRODUCT_AMD_F17_CCP_1, 62 .product = PCI_PRODUCT_AMD_F17_CCP_1,
63 }, 63 },
64 { .vendor = PCI_VENDOR_AMD, 64 { .vendor = PCI_VENDOR_AMD,
65 .product = PCI_PRODUCT_AMD_F17_CCP_2, 65 .product = PCI_PRODUCT_AMD_F17_CCP_2,
66 }, 66 },
67 { .vendor = PCI_VENDOR_AMD, 67 { .vendor = PCI_VENDOR_AMD,
68 .product = PCI_PRODUCT_AMD_F17_7X_CCP, 68 .product = PCI_PRODUCT_AMD_F17_7X_CCP,
69 }, 69 },
70}; 70};
71 71
72static const struct amdccp_pci_product * 72static const struct amdccp_pci_product *
73amdccp_pci_lookup(const struct pci_attach_args * const pa) 73amdccp_pci_lookup(const struct pci_attach_args * const pa)
74{ 74{
75 unsigned int i; 75 unsigned int i;
76 76
77 for (i = 0; i < __arraycount(amdccp_pci_products); i++) { 77 for (i = 0; i < __arraycount(amdccp_pci_products); i++) {
78 if (PCI_VENDOR(pa->pa_id) == amdccp_pci_products[i].vendor && 78 if (PCI_VENDOR(pa->pa_id) == amdccp_pci_products[i].vendor &&
79 PCI_PRODUCT(pa->pa_id) == amdccp_pci_products[i].product) { 79 PCI_PRODUCT(pa->pa_id) == amdccp_pci_products[i].product) {
80 return &amdccp_pci_products[i]; 80 return &amdccp_pci_products[i];
81 } 81 }
82 } 82 }
83 return NULL; 83 return NULL;
84} 84}
85 85
86static int 86static int
87amdccp_pci_match(device_t parent, cfdata_t cf, void *aux) 87amdccp_pci_match(device_t parent, cfdata_t cf, void *aux)
88{ 88{
89 const struct pci_attach_args * const pa = aux; 89 const struct pci_attach_args * const pa = aux;
90 90
91 return amdccp_pci_lookup(pa) != NULL; 91 return amdccp_pci_lookup(pa) != NULL;
92} 92}
93 93
94static void 94static void
95amdccp_pci_attach(device_t parent, device_t self, void *aux) 95amdccp_pci_attach(device_t parent, device_t self, void *aux)
96{ 96{
97 struct amdccp_softc * const sc = device_private(self); 97 struct amdccp_softc * const sc = device_private(self);
98 const struct pci_attach_args * const pa = aux; 98 const struct pci_attach_args * const pa = aux;
99 pcireg_t type; 99 pcireg_t type;
100 100
101 sc->sc_dev = self; 101 sc->sc_dev = self;
102 102
103 aprint_naive("\n"); 103 aprint_naive("\n");
104 aprint_normal(": AMD Cryptographc Coprocessor\n"); 104 aprint_normal(": AMD Cryptographic Coprocessor\n");
105 105
106 type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, AMDCCP_MEM_BAR); 106 type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, AMDCCP_MEM_BAR);
107 if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM) { 107 if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM) {
108 aprint_error_dev(self, "expected MEM register, got IO\n"); 108 aprint_error_dev(self, "expected MEM register, got IO\n");
109 return; 109 return;
110 } 110 }
111 111
112 if (pci_mapreg_map(pa, AMDCCP_MEM_BAR, type, 0, 112 if (pci_mapreg_map(pa, AMDCCP_MEM_BAR, type, 0,
113 &sc->sc_bst, &sc->sc_bsh, NULL, NULL) != 0) { 113 &sc->sc_bst, &sc->sc_bsh, NULL, NULL) != 0) {
114 aprint_error_dev(self, "unable to map device registers\n"); 114 aprint_error_dev(self, "unable to map device registers\n");
115 return; 115 return;
116 } 116 }
117 117
118 amdccp_common_attach(sc); 118 amdccp_common_attach(sc);
119} 119}