Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/marvell Add a convenience function, com_init_regs_st...
details: https://anonhg.NetBSD.org/src/rev/bdcdae6040e2
branches: trunk
changeset: 995184:bdcdae6040e2
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Dec 11 06:34:00 2018 +0000
description:
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:
sys/arch/hpcsh/dev/hd64461/hd64461uart.c | 9 +++------
sys/arch/mips/ingenic/ingenic_com.c | 10 +++-------
sys/arch/mips/rmi/rmixl_com.c | 14 +++-----------
sys/dev/ic/com.c | 21 +++++++++++++++++++--
sys/dev/ic/comvar.h | 4 +++-
sys/dev/marvell/com_mv.c | 18 +++++++-----------
6 files changed, 38 insertions(+), 38 deletions(-)
diffs (218 lines):
diff -r 2b37f2003447 -r bdcdae6040e2 sys/arch/hpcsh/dev/hd64461/hd64461uart.c
--- a/sys/arch/hpcsh/dev/hd64461/hd64461uart.c Tue Dec 11 05:46:14 2018 +0000
+++ b/sys/arch/hpcsh/dev/hd64461/hd64461uart.c Tue Dec 11 06:34:00 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hd64461uart.c,v 1.29 2018/12/08 17:46:11 thorpej Exp $ */
+/* $NetBSD: hd64461uart.c,v 1.30 2018/12/11 06:34:00 thorpej Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hd64461uart.c,v 1.29 2018/12/08 17:46:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd64461uart.c,v 1.30 2018/12/11 06:34:00 thorpej Exp $");
#include "opt_kgdb.h"
@@ -94,10 +94,7 @@
bus_space_handle_t hdl, bus_addr_t addr)
{
- com_init_regs(regs, tag, hdl, addr);
- for (size_t i = 0; i < __arraycount(regs->cr_map); i++)
- regs->cr_map[i] = regs->cr_map[i] << 1;
- regs->cr_nports <<= 1;
+ com_init_regs_stride(regs, tag, hdl, addr, 1);
}
void
diff -r 2b37f2003447 -r bdcdae6040e2 sys/arch/mips/ingenic/ingenic_com.c
--- a/sys/arch/mips/ingenic/ingenic_com.c Tue Dec 11 05:46:14 2018 +0000
+++ b/sys/arch/mips/ingenic/ingenic_com.c Tue Dec 11 06:34:00 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ingenic_com.c,v 1.8 2018/12/08 21:14:36 thorpej Exp $ */
+/* $NetBSD: ingenic_com.c,v 1.9 2018/12/11 06:34:00 thorpej Exp $ */
/*-
* Copyright (c) 2014 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.8 2018/12/08 21:14:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.9 2018/12/11 06:34:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,11 +82,7 @@
bus_space_handle_t sh, bus_addr_t addr)
{
- com_init_regs(regs, st, sh, addr);
- for (size_t i = 0; i < __arraycount(regs->cr_map); i++) {
- regs->cr_map[i] = regs->cr_map[i] << 2;
- }
- regs->cr_nports <<= 2;
+ com_init_regs_stride(regs, st, sh, addr, 2);
}
void
diff -r 2b37f2003447 -r bdcdae6040e2 sys/arch/mips/rmi/rmixl_com.c
--- a/sys/arch/mips/rmi/rmixl_com.c Tue Dec 11 05:46:14 2018 +0000
+++ b/sys/arch/mips/rmi/rmixl_com.c Tue Dec 11 06:34:00 2018 +0000
@@ -1,4 +1,4 @@
-/* $Id: rmixl_com.c,v 1.7 2018/12/08 21:14:37 thorpej Exp $ */
+/* $Id: rmixl_com.c,v 1.8 2018/12/11 06:34:00 thorpej Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
* Copyright (c) 2006 Garrett D'Amore.
@@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rmixl_com.c,v 1.7 2018/12/08 21:14:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rmixl_com.c,v 1.8 2018/12/11 06:34:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -288,15 +288,7 @@
bus_space_handle_t sh, bus_addr_t addr)
{
- com_init_regs(regsp, st, sh, addr);
-
- /*
- * map the 4 byte register stride
- */
- for (size_t i = 0; i < __arraycount(regsp->cr_map); i++)
- regsp->cr_map[i] = regsp->cr_map[i] * 4;
-
- regsp->cr_nports = RMIXL_IO_DEV_UART_SIZE;
+ com_init_regs_stride(regsp, st, sh, addr, 2);
}
void
diff -r 2b37f2003447 -r bdcdae6040e2 sys/dev/ic/com.c
--- a/sys/dev/ic/com.c Tue Dec 11 05:46:14 2018 +0000
+++ b/sys/dev/ic/com.c Tue Dec 11 06:34:00 2018 +0000
@@ -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 @@
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 -r 2b37f2003447 -r bdcdae6040e2 sys/dev/ic/comvar.h
--- a/sys/dev/ic/comvar.h Tue Dec 11 05:46:14 2018 +0000
+++ b/sys/dev/ic/comvar.h Tue Dec 11 06:34:00 2018 +0000
@@ -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 @@
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;
diff -r 2b37f2003447 -r bdcdae6040e2 sys/dev/marvell/com_mv.c
--- a/sys/dev/marvell/com_mv.c Tue Dec 11 05:46:14 2018 +0000
+++ b/sys/dev/marvell/com_mv.c Tue Dec 11 06:34:00 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com_mv.c,v 1.9 2018/12/08 21:14:37 thorpej Exp $ */
+/* $NetBSD: com_mv.c,v 1.10 2018/12/11 06:34:00 thorpej Exp $ */
/*
* Copyright (c) 2007, 2010 KIYOHARA Takashi
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com_mv.c,v 1.9 2018/12/08 21:14:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_mv.c,v 1.10 2018/12/11 06:34:00 thorpej Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -55,13 +55,10 @@
static void
mvuart_init_regs(struct com_regs *regs, bus_space_tag_t tag,
- bus_space_handle_t hdl, bus_addr_t addr, bus_size_t size)
+ bus_space_handle_t hdl, bus_addr_t addr);
{
- com_init_regs(regs, tag, hdl, addr);
- for (size_t i = 0; i < __arraycount(regs->cr_map); i++)
- regs->cr_map[i] = regs->cr_map[i] << 2;
- regs->cr_nports = size;
+ com_init_regs_stride(regs, tag, hdl, addr, 2);
}
@@ -85,8 +82,7 @@
if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset,
MVUART_SIZE, &ioh))
return 0;
- mvuart_init_regs(®s, mva->mva_iot, ioh, mva->mva_offset,
- MVUART_SIZE);
+ mvuart_init_regs(®s, mva->mva_iot, ioh, mva->mva_offset);
if (!com_probe_subr(®s))
return 0;
@@ -121,7 +117,7 @@
}
}
mvuart_init_regs(&sc->sc_regs,
- iot, ioh, mva->mva_addr + mva->mva_offset, mva->mva_size);
+ iot, ioh, mva->mva_addr + mva->mva_offset);
com_attach_subr(sc);
@@ -136,7 +132,7 @@
{
struct com_regs regs;
- mvuart_init_regs(®s, iot, 0x0, addr, MVUART_SIZE);
+ mvuart_init_regs(®s, iot, 0x0, addr);
return comcnattach1(®s, baud, sysfreq, COM_TYPE_16550_NOERS, mode);
}
Home |
Main Index |
Thread Index |
Old Index