From owner-p4-projects@FreeBSD.ORG Sun Oct 31 02:25:53 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1C51816A4D0; Sun, 31 Oct 2004 02:25:53 +0000 (GMT) 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 CB36916A4CE for ; Sun, 31 Oct 2004 02:25:52 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id AFFE643D5A for ; Sun, 31 Oct 2004 02:25:52 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i9V2Pq2j000238 for ; Sun, 31 Oct 2004 02:25:52 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i9V2Pqj8000234 for perforce@freebsd.org; Sun, 31 Oct 2004 02:25:52 GMT (envelope-from marcel@freebsd.org) Date: Sun, 31 Oct 2004 02:25:52 GMT Message-Id: <200410310225.i9V2Pqj8000234@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 Subject: PERFORCE change 64005 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2004 02:25:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=64005 Change 64005 by marcel@marcel_nfs on 2004/10/31 02:25:29 Have the bus frontends call scc_bfe_probe() for further probe related processing. Affected files ... .. //depot/projects/uart/dev/scc/scc_bfe.h#4 edit .. //depot/projects/uart/dev/scc/scc_bfe_ebus.c#2 edit .. //depot/projects/uart/dev/scc/scc_bfe_sbus.c#2 edit .. //depot/projects/uart/dev/scc/scc_core.c#2 edit Differences ... ==== //depot/projects/uart/dev/scc/scc_bfe.h#4 (text+ko) ==== @@ -78,6 +78,7 @@ int scc_bfe_attach(device_t dev); int scc_bfe_detach(device_t dev); +int scc_bfe_probe(device_t dev); struct resource *scc_bus_alloc_resource(device_t, device_t, int, int *, u_long, u_long, u_long, u_int); ==== //depot/projects/uart/dev/scc/scc_bfe_ebus.c#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * @@ -53,7 +53,7 @@ if (!strcmp(nm, "se")) { device_set_desc(dev, "Siemens SAB 82532 dual channel SCC"); sc->sc_class = &scc_sab82532_class; - return (0); + return (scc_bfe_probe(dev)); } return (ENXIO); } ==== //depot/projects/uart/dev/scc/scc_bfe_sbus.c#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 2004 Marcel Moolenaar * All rights reserved. * @@ -53,7 +53,7 @@ if (!strcmp(nm, "zs")) { device_set_desc(dev, "Zilog Z8530 dual channel SCC"); sc->sc_class = &scc_z8530_class; - return (0); + return (scc_bfe_probe(dev)); } return (ENXIO); } ==== //depot/projects/uart/dev/scc/scc_core.c#2 (text+ko) ==== @@ -47,6 +47,13 @@ int scc_bfe_attach(device_t dev) { + struct scc_softc *sc; + + sc = device_get_softc(dev); + sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid, + 0, ~0, sc->sc_class->sc_range, RF_ACTIVE); + if (sc->sc_rres == NULL) + return (ENXIO); return (ENXIO); } @@ -58,6 +65,48 @@ return (ENXIO); } +int +scc_bfe_probe(device_t dev) +{ + struct scc_softc *sc; + + /* + * Initialize the instance. Note that the instance (=softc) does + * not necessarily match the hardware specific softc. We can't do + * anything about it now, because we may not attach to the device. + * Hardware drivers cannot use any of the class specific fields + * while probing. + */ + sc = device_get_softc(dev); + kobj_init((kobj_t)sc, (kobj_class_t)sc->sc_class); + sc->sc_dev = dev; + if (device_get_desc(dev) == NULL) + device_set_desc(dev, sc->sc_class->name); + + /* + * Allocate the register resource. We assume that all SCCs have a + * single register window in either I/O port space or memory mapped + * I/O space. Any SCC that needs multiple windows will consequently + * not be supported by this driver as-is. We try I/O port space + * first to satisfy the EBus code. + */ + sc->sc_rrid = 0; + sc->sc_rtype = SYS_RES_IOPORT; + sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid, + 0, ~0, sc->sc_class->sc_range, RF_ACTIVE); + if (sc->sc_rres == NULL) { + sc->sc_rrid = 0; + sc->sc_rtype = SYS_RES_MEMORY; + sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, + &sc->sc_rrid, 0, ~0, sc->sc_class->sc_range, RF_ACTIVE); + if (sc->sc_rres == NULL) + return (ENXIO); + } + + bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres); + return (0); +} + struct resource * scc_bus_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags)