From owner-p4-projects@FreeBSD.ORG Fri Apr 14 21:45:55 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2599416A404; Fri, 14 Apr 2006 21:45:55 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DB0B516A400 for ; Fri, 14 Apr 2006 21:45:54 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88BC543D46 for ; Fri, 14 Apr 2006 21:45:54 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3ELjs5M045769 for ; Fri, 14 Apr 2006 21:45:54 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3ELjsxe045766 for perforce@freebsd.org; Fri, 14 Apr 2006 21:45:54 GMT (envelope-from marcel@freebsd.org) Date: Fri, 14 Apr 2006 21:45:54 GMT Message-Id: <200604142145.k3ELjsxe045766@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 95282 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Apr 2006 21:45:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=95282 Change 95282 by marcel@marcel_nfs on 2006/04/14 21:45:12 Add new header for use by subordinate drivers. The header only defines what subordinate drivers need to know. Change the bus protocol to avoid that puc(4) has to hardcode which driver attaches to what type of port. Each Subordinate driver reads the PUC_IVAR_TYPE ivar to obtain the type of port it's being probed for and either accept or reject it. Which driver actually attaches to a particular port is then left to what the respective probe functions return and thus allows for vendor specific drivers. Affected files ... .. //depot/projects/uart/dev/ppc/ppc_puc.c#3 edit .. //depot/projects/uart/dev/puc/puc_bus.h#1 add .. //depot/projects/uart/dev/uart/uart_bus_puc.c#14 edit Differences ... ==== //depot/projects/uart/dev/ppc/ppc_puc.c#3 (text+ko) ==== @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2006 Marcel Moolenaar * Copyright (c) 1997-2000 Nicolas Souchu * Copyright (c) 2001 Alcove - Nicolas Souchu * All rights reserved. @@ -23,11 +24,11 @@ * 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: src/sys/dev/ppc/ppc_puc.c,v 1.2 2004/05/30 20:08:37 phk Exp $ - * */ +#include +__FBSDID("$FreeBSD: src/sys/dev/ppc/ppc_puc.c,v 1.2 2004/05/30 20:08:37 phk Exp $"); + #include #include #include @@ -35,6 +36,8 @@ #include +#include + #include #include #include @@ -74,9 +77,17 @@ }; static int -ppc_puc_probe(dev) - device_t dev; +ppc_puc_probe(device_t dev) { + device_t parent; + uintptr_t type; + + parent = device_get_parent(dev); + if (BUS_READ_IVAR(parent, dev, PUC_IVAR_TYPE, &type)) + return (ENXIO); + if (type != PUC_TYPE_PARALLEL) + return (ENXIO); + device_set_desc(dev, "Parallel port"); return (ppc_probe(dev)); } ==== //depot/projects/uart/dev/uart/uart_bus_puc.c#14 (text+ko) ==== @@ -33,16 +33,13 @@ #include #include #include + #include #include #include -#include -#include +#include -#include -#include - #include #include @@ -70,14 +67,19 @@ { device_t parent; struct uart_softc *sc; - uintptr_t rclk; + uintptr_t rclk, type; parent = device_get_parent(dev); sc = device_get_softc(dev); + if (BUS_READ_IVAR(parent, dev, PUC_IVAR_TYPE, &type)) + return (ENXIO); + if (type != PUC_TYPE_SERIAL) + return (ENXIO); + sc->sc_class = &uart_ns8250_class; - if (BUS_READ_IVAR(parent, dev, PUC_IVAR_FREQ, &rclk)) + if (BUS_READ_IVAR(parent, dev, PUC_IVAR_CLOCK, &rclk)) rclk = 0; return (uart_bus_probe(dev, 0, rclk, 0, 0)); }