diff options
| author | jakllsch <jakllsch@NetBSD.org> | 2018-10-19 21:09:09 +0000 |
|---|---|---|
| committer | jakllsch <jakllsch@NetBSD.org> | 2018-10-19 21:09:09 +0000 |
| commit | 2c0f1921d5eebb357496abe06ef4b46bfc799d91 (patch) | |
| tree | 663142ee90b031832be12c21263f544e87089c2b /sys/dev/fdt | |
| parent | 690000dab72d23ddaeb6abd1ba7b3d8c0042fe97 (diff) | |
Add amdccp(4) driver for AMD Cryptographic Coprocessor, as found on the
A11xx Opterons. Driver currently provides RNG service only.
Diffstat (limited to 'sys/dev/fdt')
| -rw-r--r-- | sys/dev/fdt/amdccp_fdt.c | 92 | ||||
| -rw-r--r-- | sys/dev/fdt/files.fdt | 6 |
2 files changed, 97 insertions, 1 deletions
diff --git a/sys/dev/fdt/amdccp_fdt.c b/sys/dev/fdt/amdccp_fdt.c new file mode 100644 index 00000000000..a459dd95703 --- /dev/null +++ b/sys/dev/fdt/amdccp_fdt.c @@ -0,0 +1,92 @@ +/* $NetBSD: amdccp_fdt.c,v 1.1 2018/10/19 21:09:10 jakllsch Exp $ */ + +/* + * Copyright (c) 2018 Jonathan A. Kollasch + * All rights reserved. + * + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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_fdt.c,v 1.1 2018/10/19 21:09:10 jakllsch Exp $"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/bus.h> + +#include <dev/fdt/fdtvar.h> + +#include <dev/ic/amdccpvar.h> + +struct amdccp_fdt_softc { + struct amdccp_softc sc_sc; +}; + +static int amdccp_fdt_match(device_t, cfdata_t, void *); +static void amdccp_fdt_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(amdccp_fdt, sizeof(struct amdccp_fdt_softc), + amdccp_fdt_match, amdccp_fdt_attach, NULL, NULL); + +static const struct of_compat_data compat_data[] = { + { "amd,ccp-seattle-v1a", }, + { NULL } +}; + +static int +amdccp_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + const struct fdt_attach_args * const faa = aux; + + return of_match_compat_data(faa->faa_phandle, compat_data); +} + +static void +amdccp_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct amdccp_fdt_softc * const fsc = device_private(self); + struct amdccp_softc * const sc = &fsc->sc_sc; + const struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + bus_addr_t addr; + bus_size_t size; + + fsc->sc_sc.sc_dev = self; + + if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } + + sc->sc_bst = faa->faa_bst; + if (bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh) != 0) { + aprint_error(": couldn't map registers\n"); + return; + } + + aprint_naive("\n"); + aprint_normal(": AMD CCP\n"); + + amdccp_common_attach(sc); +} diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt index 897f9f9ba7d..c180880ffa7 100644 --- a/sys/dev/fdt/files.fdt +++ b/sys/dev/fdt/files.fdt @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.40 2018/10/15 23:50:48 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.41 2018/10/19 21:09:10 jakllsch Exp $ include "external/bsd/libfdt/conf/files.libfdt" @@ -134,3 +134,7 @@ file dev/fdt/ahcisata_fdt.c ahcisata_fdt # Designware I2C attach dwiic at fdt with dwiic_fdt file dev/fdt/dwiic_fdt.c dwiic_fdt + +# AMD Cryptographic Coprocessor +attach amdccp at fdt with amdccp_fdt +file dev/fdt/amdccp_fdt.c amdccp_fdt |
