Wed Jun 24 03:38:01 2020 UTC ()
Add a PCI front-end for the "amdccp" (AMD Cryptographic Coprocessor)
driver.
(thorpej)
diff -r0 -r1.1 src/sys/dev/pci/amdccp_pci.c
diff -r1.428 -r1.429 src/sys/dev/pci/files.pci
/* $NetBSD: amdccp_pci.c,v 1.1 2020/06/24 03:38:01 thorpej Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: amdccp_pci.c,v 1.1 2020/06/24 03:38:01 thorpej Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/device.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#include <dev/ic/amdccpvar.h>
static int amdccp_pci_match(device_t, cfdata_t, void *);
static void amdccp_pci_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(amdccp_pci, sizeof(struct amdccp_softc),
amdccp_pci_match, amdccp_pci_attach, NULL, NULL);
#define AMDCCP_MEM_BAR PCI_BAR2
static const struct amdccp_pci_product {
pci_vendor_id_t vendor;
pci_product_id_t product;
} amdccp_pci_products[] = {
{ .vendor = PCI_VENDOR_AMD,
.product = PCI_PRODUCT_AMD_F16_CCP,
},
{ .vendor = PCI_VENDOR_AMD,
.product = PCI_PRODUCT_AMD_F17_CCP_1,
},
{ .vendor = PCI_VENDOR_AMD,
.product = PCI_PRODUCT_AMD_F17_CCP_2,
},
{ .vendor = PCI_VENDOR_AMD,
.product = PCI_PRODUCT_AMD_F17_7X_CCP,
},
};
static const struct amdccp_pci_product *
amdccp_pci_lookup(const struct pci_attach_args * const pa)
{
unsigned int i;
for (i = 0; i < __arraycount(amdccp_pci_products); i++) {
if (PCI_VENDOR(pa->pa_id) == amdccp_pci_products[i].vendor &&
PCI_PRODUCT(pa->pa_id) == amdccp_pci_products[i].product) {
return &amdccp_pci_products[i];
}
}
return NULL;
}
static int
amdccp_pci_match(device_t parent, cfdata_t cf, void *aux)
{
const struct pci_attach_args * const pa = aux;
return amdccp_pci_lookup(pa) != NULL;
}
static void
amdccp_pci_attach(device_t parent, device_t self, void *aux)
{
struct amdccp_softc * const sc = device_private(self);
const struct pci_attach_args * const pa = aux;
pcireg_t type;
sc->sc_dev = self;
aprint_naive("\n");
aprint_normal(": AMD Cryptographc Coprocessor\n");
type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, AMDCCP_MEM_BAR);
if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM) {
aprint_error_dev(self, "expected MEM register, got IO\n");
return;
}
if (pci_mapreg_map(pa, AMDCCP_MEM_BAR, type, 0,
&sc->sc_bst, &sc->sc_bsh, NULL, NULL) != 0) {
aprint_error_dev(self, "unable to map device registers\n");
return;
}
amdccp_common_attach(sc);
}
--- src/sys/dev/pci/files.pci 2020/05/21 22:58:46 1.428
+++ src/sys/dev/pci/files.pci 2020/06/24 03:38:01 1.429
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.pci,v 1.428 2020/05/21 22:58:46 macallan Exp $ | | 1 | # $NetBSD: files.pci,v 1.429 2020/06/24 03:38:01 thorpej Exp $ |
2 | # | | 2 | # |
3 | # Config file and device description for machine-independent PCI code. | | 3 | # Config file and device description for machine-independent PCI code. |
4 | # Included by ports that need it. Requires that the SCSI files be | | 4 | # Included by ports that need it. Requires that the SCSI files be |
5 | # defined first. | | 5 | # defined first. |
6 | | | 6 | |
7 | defflag opt_pci.h PCIVERBOSE PCI_CONFIG_DUMP PCI_NETBSD_CONFIGURE | | 7 | defflag opt_pci.h PCIVERBOSE PCI_CONFIG_DUMP PCI_NETBSD_CONFIGURE |
8 | defparam opt_pci.h PCI_NETBSD_ENABLE_IDE | | 8 | defparam opt_pci.h PCI_NETBSD_ENABLE_IDE |
9 | | | 9 | |
10 | defflag opt_bktr.h BKTR_430_FX_MODE BKTR_GPIO_ACCESS BKTR_NO_MSP_RESET | | 10 | defflag opt_bktr.h BKTR_430_FX_MODE BKTR_GPIO_ACCESS BKTR_NO_MSP_RESET |
11 | BKTR_REVERSE_MUTE BKTR_SIS_VIA_MODE BKTR_USE_PLL | | 11 | BKTR_REVERSE_MUTE BKTR_SIS_VIA_MODE BKTR_USE_PLL |
12 | defparam opt_bktr.h BKTR_OVERRIDE_CARD BKTR_OVERRIDE_TUNER BKTR_OVERRIDE_DBX | | 12 | defparam opt_bktr.h BKTR_OVERRIDE_CARD BKTR_OVERRIDE_TUNER BKTR_OVERRIDE_DBX |
13 | BKTR_OVERRIDE_MSP BKTR_SYSTEM_DEFAULT | | 13 | BKTR_OVERRIDE_MSP BKTR_SYSTEM_DEFAULT |
14 | | | 14 | |
| @@ -746,26 +746,30 @@ file dev/pci/viaenv.c viaenv | | | @@ -746,26 +746,30 @@ file dev/pci/viaenv.c viaenv |
746 | | | 746 | |
747 | # Intel PIIX4 power management controller | | 747 | # Intel PIIX4 power management controller |
748 | device piixpm: i2cbus, acpipmtimer | | 748 | device piixpm: i2cbus, acpipmtimer |
749 | attach piixpm at pci | | 749 | attach piixpm at pci |
750 | file dev/pci/piixpm.c piixpm | | 750 | file dev/pci/piixpm.c piixpm |
751 | | | 751 | |
752 | # AMD 768MPX power management controller | | 752 | # AMD 768MPX power management controller |
753 | defflag opt_amdpm.h AMDPM_RND_COUNTERS | | 753 | defflag opt_amdpm.h AMDPM_RND_COUNTERS |
754 | device amdpm: i2cbus, acpipmtimer | | 754 | device amdpm: i2cbus, acpipmtimer |
755 | attach amdpm at pci | | 755 | attach amdpm at pci |
756 | file dev/pci/amdpm.c amdpm | | 756 | file dev/pci/amdpm.c amdpm |
757 | file dev/pci/amdpm_smbus.c amdpm | | 757 | file dev/pci/amdpm_smbus.c amdpm |
758 | | | 758 | |
| | | 759 | # AMD Cryptographic Coprocessor |
| | | 760 | attach amdccp at pci with amdccp_pci |
| | | 761 | file dev/pci/amdccp_pci.c amdccp_pci |
| | | 762 | |
759 | # Hi/fn 7751 | | 763 | # Hi/fn 7751 |
760 | device hifn: opencrypto | | 764 | device hifn: opencrypto |
761 | attach hifn at pci | | 765 | attach hifn at pci |
762 | file dev/pci/hifn7751.c hifn | | 766 | file dev/pci/hifn7751.c hifn |
763 | | | 767 | |
764 | # Bluesteelnet 5501/5601, Broadcom 580x/582x security processor | | 768 | # Bluesteelnet 5501/5601, Broadcom 580x/582x security processor |
765 | device ubsec: opencrypto | | 769 | device ubsec: opencrypto |
766 | attach ubsec at pci | | 770 | attach ubsec at pci |
767 | file dev/pci/ubsec.c ubsec | | 771 | file dev/pci/ubsec.c ubsec |
768 | | | 772 | |
769 | # Aironet PC4500/PC4800 | | 773 | # Aironet PC4500/PC4800 |
770 | attach an at pci with an_pci | | 774 | attach an at pci with an_pci |
771 | file dev/pci/if_an_pci.c an_pci | | 775 | file dev/pci/if_an_pci.c an_pci |