summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2018-12-11 06:34:00 +0000
committerthorpej <thorpej@NetBSD.org>2018-12-11 06:34:00 +0000
commita813db806e5bb1db99e2da8a25f3e9c96ab54649 (patch)
tree0473678dce005af905cb032d33ea29b6da8dbaf8 /sys/dev/ic
parentcfec4bd15f0c636b80b0a0995487d6ff963571aa (diff)
Add a convenience function, com_init_regs_stride(), that shifts the register
offsets and size by the specified amount. Use in front-ends as appropriate.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/com.c21
-rw-r--r--sys/dev/ic/comvar.h4
2 files changed, 22 insertions, 3 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 0db131a8418..76e46353454 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.353 2018/12/09 16:00:40 thorpej Exp $ */
+/* $NetBSD: com.c,v 1.354 2018/12/11 06:34:00 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.353 2018/12/09 16:00:40 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.354 2018/12/11 06:34:00 thorpej Exp $");
#include "opt_com.h"
#include "opt_ddb.h"
@@ -276,6 +276,23 @@ com_init_regs(struct com_regs *regs, bus_space_tag_t st, bus_space_handle_t sh,
memcpy(regs->cr_map, com_std_map, sizeof(regs->cr_map));
}
+/*
+ * com_init_regs_stride --
+ * Convenience function for front-ends that have a stride between
+ * registers.
+ */
+void
+com_init_regs_stride(struct com_regs *regs, bus_space_tag_t st,
+ bus_space_handle_t sh, bus_addr_t addr, u_int regshift)
+{
+
+ com_init_regs(regs, st, sh, addr);
+ for (size_t i = 0; i < __arraycount(regs->cr_map); i++) {
+ regs->cr_map[i] <<= regshift;
+ }
+ regs->cr_nports <<= regshift;
+}
+
/*ARGSUSED*/
int
comspeed(long speed, long frequency, int type)
diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h
index 018037a0c84..cc4e8927950 100644
--- a/sys/dev/ic/comvar.h
+++ b/sys/dev/ic/comvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: comvar.h,v 1.90 2018/12/08 21:14:37 thorpej Exp $ */
+/* $NetBSD: comvar.h,v 1.91 2018/12/11 06:34:00 thorpej Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -106,6 +106,8 @@ struct com_regs {
void com_init_regs(struct com_regs *, bus_space_tag_t, bus_space_handle_t,
bus_addr_t);
+void com_init_regs_stride(struct com_regs *, bus_space_tag_t,
+ bus_space_handle_t, bus_addr_t, u_int);
struct comcons_info {
struct com_regs regs;