summaryrefslogtreecommitdiff
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-04-20 04:37:22 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-04-20 04:37:22 +0000
commita81444beb21996e9e2da43fea54dc17a974a1b8d (patch)
treebbd634b9c7003096e1eed18789c9550f6e08a55a /sys/dev/fdt
parent4981398be1f052f9004563077f088dce600f9b50 (diff)
add a small driver for AMDs cryptographic co processor.
the hardware provides crypto offload, zlib offload, and an rng. this code only supports the rng at the moment. this device is present on their amd seatlle platforms, and very present on their epyc stuff. ok kettenis@ jmatthew@
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/ccp_fdt.c70
-rw-r--r--sys/dev/fdt/files.fdt5
2 files changed, 74 insertions, 1 deletions
diff --git a/sys/dev/fdt/ccp_fdt.c b/sys/dev/fdt/ccp_fdt.c
new file mode 100644
index 00000000000..3174b5252e3
--- /dev/null
+++ b/sys/dev/fdt/ccp_fdt.c
@@ -0,0 +1,70 @@
+/* $OpenBSD: ccp_fdt.c,v 1.1 2018/04/20 04:37:21 dlg Exp $ */
+/*
+ * Copyright (c) 2018 David Gwynne <dlg@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+
+#include <machine/bus.h>
+#include <machine/fdt.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_misc.h>
+#include <dev/ofw/ofw_regulator.h>
+#include <dev/ofw/fdt.h>
+
+#include <dev/ic/ccpvar.h>
+
+static int ccp_fdt_match(struct device *, void *, void *);
+static void ccp_fdt_attach(struct device *, struct device *, void *);
+
+struct cfattach ccp_fdt_ca = {
+ sizeof(struct ccp_softc),
+ ccp_fdt_match,
+ ccp_fdt_attach
+};
+
+static int
+ccp_fdt_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "amd,ccp-seattle-v1a");
+}
+
+static void
+ccp_fdt_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct ccp_softc *sc = (struct ccp_softc *)self;
+ struct fdt_attach_args *faa = aux;
+
+ if (faa->fa_nreg < 1) {
+ printf(": no registers\n");
+ return;
+ }
+
+ sc->sc_iot = faa->fa_iot;
+
+ if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
+ faa->fa_reg[0].size, 0, &sc->sc_ioh)) {
+ printf(": cannot map registers\n");
+ return;
+ }
+
+ ccp_attach(sc);
+}
diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt
index 6b20ad09289..4c58981bb48 100644
--- a/sys/dev/fdt/files.fdt
+++ b/sys/dev/fdt/files.fdt
@@ -1,4 +1,4 @@
-# $OpenBSD: files.fdt,v 1.57 2018/04/02 21:40:59 kettenis Exp $
+# $OpenBSD: files.fdt,v 1.58 2018/04/20 04:37:21 dlg Exp $
#
# Config file and device description for machine-independent FDT code.
# Included by ports that need it.
@@ -229,3 +229,6 @@ file dev/fdt/imxuart.c imxuart
device fec: ether, ifnet, mii, ifmedia
attach fec at fdt
file dev/fdt/if_fec.c fec
+
+attach ccp at fdt with ccp_fdt
+file dev/fdt/ccp_fdt.c ccp_fdt