From owner-svn-src-stable@FreeBSD.ORG Sun Mar 22 10:08:42 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17B2D10656CA; Sun, 22 Mar 2009 10:08:42 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EECB08FC18; Sun, 22 Mar 2009 10:08:41 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2MA8fb8065555; Sun, 22 Mar 2009 10:08:41 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2MA8f6i065552; Sun, 22 Mar 2009 10:08:41 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200903221008.n2MA8f6i065552@svn.freebsd.org> From: Marius Strobl Date: Sun, 22 Mar 2009 10:08:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190256 - in stable/7/sys: . conf contrib/pf dev/ath/ath_hal dev/cxgb sparc64/sparc64 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2009 10:08:42 -0000 Author: marius Date: Sun Mar 22 10:08:41 2009 New Revision: 190256 URL: http://svn.freebsd.org/changeset/base/190256 Log: MFC: r182918 Add drivers for the power management devices found on Fireplane/ Safari- and JBus-based machines. Currently the main purpose of these drivers is debugging of the resource allocation on nexus(4) and the register content of these devices though. Added: stable/7/sys/sparc64/sparc64/jbusppm.c - copied unchanged from r182918, head/sys/sparc64/sparc64/jbusppm.c stable/7/sys/sparc64/sparc64/schppm.c - copied unchanged from r182918, head/sys/sparc64/sparc64/schppm.c Modified: stable/7/sys/ (props changed) stable/7/sys/conf/files.sparc64 stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/conf/files.sparc64 ============================================================================== --- stable/7/sys/conf/files.sparc64 Sun Mar 22 09:57:57 2009 (r190255) +++ stable/7/sys/conf/files.sparc64 Sun Mar 22 10:08:41 2009 (r190256) @@ -101,6 +101,7 @@ sparc64/sparc64/interrupt.S standard no- compile-with "${NORMAL_S} -mcpu=ultrasparc" sparc64/sparc64/intr_machdep.c standard sparc64/sparc64/iommu.c standard +sparc64/sparc64/jbusppm.c standard sparc64/sparc64/locore.S standard no-obj sparc64/sparc64/machdep.c standard sparc64/sparc64/mem.c optional mem @@ -116,6 +117,7 @@ sparc64/sparc64/prof_machdep.c optional sparc64/sparc64/rtc.c optional rtc ebus | rtc isa sparc64/sparc64/rwindow.c standard sparc64/sparc64/sc_machdep.c optional sc +sparc64/sparc64/schppm.c standard sparc64/sparc64/spitfire.c standard sparc64/sparc64/stack_machdep.c optional ddb | stack sparc64/sparc64/support.S standard \ Copied: stable/7/sys/sparc64/sparc64/jbusppm.c (from r182918, head/sys/sparc64/sparc64/jbusppm.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/sparc64/sparc64/jbusppm.c Sun Mar 22 10:08:41 2009 (r190256, copy of r182918, head/sys/sparc64/sparc64/jbusppm.c) @@ -0,0 +1,226 @@ +/*- + * Copyright (c) 2008 Marius Strobl + * 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define JBUSPPM_NREG 2 + +#define JBUSPPM_DEVID 0 +#define JBUSPPM_ESTAR 1 + +#define JBUSPPM_DEVID_JID 0x00 +#define JBUSPPM_DEVID_JID_MASTER 0x00040000 + +#define JBUSPPM_ESTAR_CTRL 0x00 +#define JBUSPPM_ESTAR_CTRL_1 0x00000001 +#define JBUSPPM_ESTAR_CTRL_2 0x00000002 +#define JBUSPPM_ESTAR_CTRL_32 0x00000020 +#define JBUSPPM_ESTAR_CTRL_MASK \ + (JBUSPPM_ESTAR_CTRL_1 | JBUSPPM_ESTAR_CTRL_2 | JBUSPPM_ESTAR_CTRL_32) +#define JBUSPPM_ESTAR_JCHNG 0x08 +#define JBUSPPM_ESTAR_JCHNG_DELAY_MASK 0x00000007 +#define JBUSPPM_ESTAR_JCHNG_START 0x00000010 +#define JBUSPPM_ESTAR_JCHNG_OCCURED 0x00000018 + +struct jbusppm_softc { + struct resource *sc_res[JBUSPPM_NREG]; + bus_space_tag_t sc_bt[JBUSPPM_NREG]; + bus_space_handle_t sc_bh[JBUSPPM_NREG]; +}; + +#define JBUSPPM_READ(sc, reg, off) \ + bus_space_read_8((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off)) +#define JBUSPPM_WRITE(sc, reg, off, val) \ + bus_space_write_8((sc)->sc_bt[(reg)], (sc)->sc_bh[(reg)], (off), (val)) + +static device_probe_t jbusppm_probe; +static device_attach_t jbusppm_attach; + +static device_method_t jbusppm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, jbusppm_probe), + DEVMETHOD(device_attach, jbusppm_attach), + + { NULL, NULL } +}; + +static devclass_t jbusppm_devclass; + +DEFINE_CLASS_0(jbusppm, jbusppm_driver, jbusppm_methods, + sizeof(struct jbusppm_softc)); +DRIVER_MODULE(jbusppm, nexus, jbusppm_driver, jbusppm_devclass, 0, 0); + +static int +jbusppm_probe(device_t dev) +{ + const char* compat; + + compat = ofw_bus_get_compat(dev); + if (compat != NULL && strcmp(ofw_bus_get_name(dev), "ppm") == 0 && + strcmp(compat, "jbus-ppm") == 0) { + device_set_desc(dev, "JBus power management"); + return (BUS_PROBE_DEFAULT); + } + return (ENXIO); +} + +static int +jbusppm_attach(device_t dev) +{ + struct jbusppm_softc *sc; + int i, rid; +#if 1 + device_t *children, tomatillo; + u_long tcount, tstart, jcount, jstart; + int j, nchildren; +#endif + + sc = device_get_softc(dev); + for (i = JBUSPPM_DEVID; i <= JBUSPPM_ESTAR; i++) { + rid = i; + /* + * The JBUSPPM_ESTAR resources is shared with that of the + * Tomatillo bus A controller configuration register bank. + */ +#if 0 + sc->sc_res[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &rid, (i == JBUSPPM_ESTAR ? RF_SHAREABLE : 0) | RF_ACTIVE); + if (sc->sc_res[i] == NULL) { + device_printf(dev, + "could not allocate resource %d\n", i); + goto fail; + } + sc->sc_bt[i] = rman_get_bustag(sc->sc_res[i]); + sc->sc_bh[i] = rman_get_bushandle(sc->sc_res[i]); +#else + /* + * Workaround for the fact that rman(9) only allows to + * share resources of the same size. + */ + if (i == JBUSPPM_ESTAR) { + if (bus_get_resource(dev, SYS_RES_MEMORY, i, &jstart, + &jcount) != 0) { + device_printf(dev, + "could not determine Estar resource\n"); + goto fail; + } + if (device_get_children(device_get_parent(dev), + &children, &nchildren) != 0) { + device_printf(dev, "could not get children\n"); + goto fail; + } + tomatillo = NULL; + for (j = 0; j < nchildren; j++) { + if (ofw_bus_get_type(children[j]) != NULL && + strcmp(ofw_bus_get_type(children[j]), + "pci") == 0 && + ofw_bus_get_compat(children[j]) != NULL && + strcmp(ofw_bus_get_compat(children[j]), + "pci108e,a801") == 0 && + ((bus_get_resource_start(children[j], + SYS_RES_MEMORY, 0) >> 20) & 1) == 0) { + tomatillo = children[j]; + break; + } + } + free(children, M_TEMP); + if (tomatillo == NULL) { + device_printf(dev, + "could not find Tomatillo\n"); + goto fail; + } + if (bus_get_resource(tomatillo, SYS_RES_MEMORY, 1, + &tstart, &tcount) != 0) { + device_printf(dev, + "could not determine Tomatillo " + "resource\n"); + goto fail; + } + sc->sc_res[i] = bus_alloc_resource(dev, SYS_RES_MEMORY, + &rid, tstart, tstart + tcount - 1, tcount, + RF_SHAREABLE | RF_ACTIVE); + } else + sc->sc_res[i] = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (sc->sc_res[i] == NULL) { + device_printf(dev, + "could not allocate resource %d\n", i); + goto fail; + } + sc->sc_bt[i] = rman_get_bustag(sc->sc_res[i]); + sc->sc_bh[i] = rman_get_bushandle(sc->sc_res[i]); + if (i == JBUSPPM_ESTAR) + bus_space_subregion(sc->sc_bt[i], sc->sc_bh[i], + jstart - tstart, jcount, &sc->sc_bh[i]); +#endif + } + + if (bootverbose) { + if ((JBUSPPM_READ(sc, JBUSPPM_DEVID, JBUSPPM_DEVID_JID) & + JBUSPPM_DEVID_JID_MASTER) != 0) + device_printf(dev, "master I/O bridge\n"); + device_printf(dev, "running at "); + switch (JBUSPPM_READ(sc, JBUSPPM_ESTAR, JBUSPPM_ESTAR_CTRL) & + JBUSPPM_ESTAR_CTRL_MASK) { + case JBUSPPM_ESTAR_CTRL_1: + printf("full"); + break; + case JBUSPPM_ESTAR_CTRL_2: + printf("half"); + break; + case JBUSPPM_ESTAR_CTRL_32: + printf("1/32"); + break; + default: + printf("unknown"); + break; + } + printf(" speed\n"); + } + + return (0); + + fail: + for (i = JBUSPPM_DEVID; i <= JBUSPPM_ESTAR && sc->sc_res[i] != NULL; + i++) + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->sc_res[i]), sc->sc_res[i]); + return (ENXIO); +} Copied: stable/7/sys/sparc64/sparc64/schppm.c (from r182918, head/sys/sparc64/sparc64/schppm.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/sparc64/sparc64/schppm.c Sun Mar 22 10:08:41 2009 (r190256, copy of r182918, head/sys/sparc64/sparc64/schppm.c) @@ -0,0 +1,132 @@ +/*- + * Copyright (c) 2008 Marius Strobl + * 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define SCHPPM_NREG 1 + +#define SCHPPM_ESTAR 0 + +#define SCHPPM_ESTAR_CTRL 0x00 +#define SCHPPM_ESTAR_CTRL_1 0x00000001 +#define SCHPPM_ESTAR_CTRL_2 0x00000002 +#define SCHPPM_ESTAR_CTRL_32 0x00000020 +#define SCHPPM_ESTAR_CTRL_MASK \ + (SCHPPM_ESTAR_CTRL_1 | SCHPPM_ESTAR_CTRL_2 | SCHPPM_ESTAR_CTRL_32) + +static struct resource_spec schppm_res_spec[] = { + { SYS_RES_MEMORY, SCHPPM_ESTAR, RF_ACTIVE }, + { -1, 0 } +}; + +struct schppm_softc { + struct resource *sc_res[SCHPPM_NREG]; +}; + +#define SCHPPM_READ(sc, reg, off) \ + bus_read_8((sc)->sc_res[(reg)], (off)) +#define SCHPPM_WRITE(sc, reg, off, val) \ + bus_write_8((sc)->sc_res[(reg)], (off), (val)) + +static device_probe_t schppm_probe; +static device_attach_t schppm_attach; + +static device_method_t schppm_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, schppm_probe), + DEVMETHOD(device_attach, schppm_attach), + + { NULL, NULL } +}; + +static devclass_t schppm_devclass; + +DEFINE_CLASS_0(schppm, schppm_driver, schppm_methods, + sizeof(struct schppm_softc)); +DRIVER_MODULE(schppm, nexus, schppm_driver, schppm_devclass, 0, 0); + +static int +schppm_probe(device_t dev) +{ + const char* compat; + + compat = ofw_bus_get_compat(dev); + if (compat != NULL && strcmp(ofw_bus_get_name(dev), "ppm") == 0 && + strcmp(compat, "gp2-ppm") == 0) { + device_set_desc(dev, "Schizo power management"); + return (BUS_PROBE_DEFAULT); + } + return (ENXIO); +} + +static int +schppm_attach(device_t dev) +{ + struct schppm_softc *sc; + + sc = device_get_softc(dev); + if (bus_alloc_resources(dev, schppm_res_spec, sc->sc_res)) { + device_printf(dev, "failed to allocate resources\n"); + bus_release_resources(dev, schppm_res_spec, sc->sc_res); + return (ENXIO); + } + + if (bootverbose) { + device_printf(dev, "running at "); + switch (SCHPPM_READ(sc, SCHPPM_ESTAR, SCHPPM_ESTAR_CTRL) & + SCHPPM_ESTAR_CTRL_MASK) { + case SCHPPM_ESTAR_CTRL_1: + printf("full"); + break; + case SCHPPM_ESTAR_CTRL_2: + printf("half"); + break; + case SCHPPM_ESTAR_CTRL_32: + printf("1/32"); + break; + default: + printf("unknown"); + break; + } + printf(" speed\n"); + } + + return (0); +}