aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/uart
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2013-08-21 14:26:15 +0000
committerIan Lepore <ian@FreeBSD.org>2013-08-21 14:26:15 +0000
commit167cb33f85968ce572debbeade439aa8738713ea (patch)
tree9caab8b17e1d35b508efe3380bef6104221e981e /sys/dev/uart
parentf44b688c579859c67e33f57813d0dc012163b067 (diff)
downloadsrc-167cb33f85968ce572debbeade439aa8738713ea.tar.gz
src-167cb33f85968ce572debbeade439aa8738713ea.zip
Make the uart ns8250 high-level interface public rather than static.
This makes it easier to implement new drivers which are "mostly ns8250" but with some small difference such as needing to enable clocks or poke a non-standard register at probe or attach time.
Notes
Notes: svn path=/head/; revision=254597
Diffstat (limited to 'sys/dev/uart')
-rw-r--r--sys/dev/uart/uart_dev_ns8250.c51
-rw-r--r--sys/dev/uart/uart_dev_ns8250.h60
2 files changed, 73 insertions, 38 deletions
diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c
index 8eca8f0f4dd8..1c337cacf3ac 100644
--- a/sys/dev/uart/uart_dev_ns8250.c
+++ b/sys/dev/uart/uart_dev_ns8250.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <dev/uart/uart.h>
#include <dev/uart/uart_cpu.h>
#include <dev/uart/uart_bus.h>
+#include <dev/uart/uart_dev_ns8250.h>
#include <dev/ic/ns16550.h>
@@ -239,7 +240,7 @@ static void ns8250_putc(struct uart_bas *bas, int);
static int ns8250_rxready(struct uart_bas *bas);
static int ns8250_getc(struct uart_bas *bas, struct mtx *);
-static struct uart_ops uart_ns8250_ops = {
+struct uart_ops uart_ns8250_ops = {
.probe = ns8250_probe,
.init = ns8250_init,
.term = ns8250_term,
@@ -352,32 +353,6 @@ ns8250_getc(struct uart_bas *bas, struct mtx *hwmtx)
return (c);
}
-/*
- * High-level UART interface.
- */
-struct ns8250_softc {
- struct uart_softc base;
- uint8_t fcr;
- uint8_t ier;
- uint8_t mcr;
-
- uint8_t ier_mask;
- uint8_t ier_rxbits;
- uint8_t busy_detect;
-};
-
-static int ns8250_bus_attach(struct uart_softc *);
-static int ns8250_bus_detach(struct uart_softc *);
-static int ns8250_bus_flush(struct uart_softc *, int);
-static int ns8250_bus_getsig(struct uart_softc *);
-static int ns8250_bus_ioctl(struct uart_softc *, int, intptr_t);
-static int ns8250_bus_ipend(struct uart_softc *);
-static int ns8250_bus_param(struct uart_softc *, int, int, int, int);
-static int ns8250_bus_probe(struct uart_softc *);
-static int ns8250_bus_receive(struct uart_softc *);
-static int ns8250_bus_setsig(struct uart_softc *, int);
-static int ns8250_bus_transmit(struct uart_softc *);
-
static kobj_method_t ns8250_methods[] = {
KOBJMETHOD(uart_attach, ns8250_bus_attach),
KOBJMETHOD(uart_detach, ns8250_bus_detach),
@@ -409,7 +384,7 @@ struct uart_class uart_ns8250_class = {
i = (i & s) ? (i & ~s) | d : i; \
}
-static int
+int
ns8250_bus_attach(struct uart_softc *sc)
{
struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc;
@@ -482,7 +457,7 @@ ns8250_bus_attach(struct uart_softc *sc)
return (0);
}
-static int
+int
ns8250_bus_detach(struct uart_softc *sc)
{
struct ns8250_softc *ns8250;
@@ -498,7 +473,7 @@ ns8250_bus_detach(struct uart_softc *sc)
return (0);
}
-static int
+int
ns8250_bus_flush(struct uart_softc *sc, int what)
{
struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc;
@@ -518,7 +493,7 @@ ns8250_bus_flush(struct uart_softc *sc, int what)
return (error);
}
-static int
+int
ns8250_bus_getsig(struct uart_softc *sc)
{
uint32_t new, old, sig;
@@ -539,7 +514,7 @@ ns8250_bus_getsig(struct uart_softc *sc)
return (sig);
}
-static int
+int
ns8250_bus_ioctl(struct uart_softc *sc, int request, intptr_t data)
{
struct uart_bas *bas;
@@ -612,7 +587,7 @@ ns8250_bus_ioctl(struct uart_softc *sc, int request, intptr_t data)
return (error);
}
-static int
+int
ns8250_bus_ipend(struct uart_softc *sc)
{
struct uart_bas *bas;
@@ -656,7 +631,7 @@ ns8250_bus_ipend(struct uart_softc *sc)
return (ipend);
}
-static int
+int
ns8250_bus_param(struct uart_softc *sc, int baudrate, int databits,
int stopbits, int parity)
{
@@ -670,7 +645,7 @@ ns8250_bus_param(struct uart_softc *sc, int baudrate, int databits,
return (error);
}
-static int
+int
ns8250_bus_probe(struct uart_softc *sc)
{
struct ns8250_softc *ns8250;
@@ -820,7 +795,7 @@ ns8250_bus_probe(struct uart_softc *sc)
return (0);
}
-static int
+int
ns8250_bus_receive(struct uart_softc *sc)
{
struct uart_bas *bas;
@@ -853,7 +828,7 @@ ns8250_bus_receive(struct uart_softc *sc)
return (0);
}
-static int
+int
ns8250_bus_setsig(struct uart_softc *sc, int sig)
{
struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc;
@@ -885,7 +860,7 @@ ns8250_bus_setsig(struct uart_softc *sc, int sig)
return (0);
}
-static int
+int
ns8250_bus_transmit(struct uart_softc *sc)
{
struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc;
diff --git a/sys/dev/uart/uart_dev_ns8250.h b/sys/dev/uart/uart_dev_ns8250.h
new file mode 100644
index 000000000000..39f4a0f27803
--- /dev/null
+++ b/sys/dev/uart/uart_dev_ns8250.h
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 2003 Marcel Moolenaar
+ * 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 AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _DEV_UART_DEV_NS8250_H_
+#define _DEV_UART_DEV_NS8250_H_
+
+/*
+ * High-level UART interface.
+ */
+struct ns8250_softc {
+ struct uart_softc base;
+ uint8_t fcr;
+ uint8_t ier;
+ uint8_t mcr;
+
+ uint8_t ier_mask;
+ uint8_t ier_rxbits;
+ uint8_t busy_detect;
+};
+
+extern struct uart_ops uart_ns8250_ops;
+
+int ns8250_bus_attach(struct uart_softc *);
+int ns8250_bus_detach(struct uart_softc *);
+int ns8250_bus_flush(struct uart_softc *, int);
+int ns8250_bus_getsig(struct uart_softc *);
+int ns8250_bus_ioctl(struct uart_softc *, int, intptr_t);
+int ns8250_bus_ipend(struct uart_softc *);
+int ns8250_bus_param(struct uart_softc *, int, int, int, int);
+int ns8250_bus_probe(struct uart_softc *);
+int ns8250_bus_receive(struct uart_softc *);
+int ns8250_bus_setsig(struct uart_softc *, int);
+int ns8250_bus_transmit(struct uart_softc *);
+
+#endif /* _DEV_UART_DEV_NS8250_H_ */