Date: Wed, 21 Aug 2013 14:26:15 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254597 - head/sys/dev/uart Message-ID: <201308211426.r7LEQFL5075737@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Wed Aug 21 14:26:15 2013 New Revision: 254597 URL: http://svnweb.freebsd.org/changeset/base/254597 Log: 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. Added: head/sys/dev/uart/uart_dev_ns8250.h (contents, props changed) Modified: head/sys/dev/uart/uart_dev_ns8250.c Modified: head/sys/dev/uart/uart_dev_ns8250.c ============================================================================== --- head/sys/dev/uart/uart_dev_ns8250.c Wed Aug 21 08:01:52 2013 (r254596) +++ head/sys/dev/uart/uart_dev_ns8250.c Wed Aug 21 14:26:15 2013 (r254597) @@ -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 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 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, 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, 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, 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, return (0); } -static int +int ns8250_bus_transmit(struct uart_softc *sc) { struct ns8250_softc *ns8250 = (struct ns8250_softc*)sc; Added: head/sys/dev/uart/uart_dev_ns8250.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/uart/uart_dev_ns8250.h Wed Aug 21 14:26:15 2013 (r254597) @@ -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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308211426.r7LEQFL5075737>