From owner-svn-src-all@FreeBSD.ORG Tue Dec 9 01:01:02 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AADE31065677; Tue, 9 Dec 2008 01:01:02 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 98BAC8FC18; Tue, 9 Dec 2008 01:01:02 +0000 (UTC) (envelope-from nwhitehorn@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 mB9112gN075631; Tue, 9 Dec 2008 01:01:02 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mB9112IL075629; Tue, 9 Dec 2008 01:01:02 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <200812090101.mB9112IL075629@svn.freebsd.org> From: Nathan Whitehorn Date: Tue, 9 Dec 2008 01:01:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185782 - head/sys/powerpc/powermac X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2008 01:01:02 -0000 Author: nwhitehorn Date: Tue Dec 9 01:01:02 2008 New Revision: 185782 URL: http://svn.freebsd.org/changeset/base/185782 Log: Add the ability to control the sleep LED with led(4). Adding this fairly useless feature gives us a reasonably complete PMU implementation. Modified: head/sys/powerpc/powermac/pmu.c head/sys/powerpc/powermac/pmuvar.h Modified: head/sys/powerpc/powermac/pmu.c ============================================================================== --- head/sys/powerpc/powermac/pmu.c Tue Dec 9 00:25:57 2008 (r185781) +++ head/sys/powerpc/powermac/pmu.c Tue Dec 9 01:01:02 2008 (r185782) @@ -11,8 +11,6 @@ * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -41,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -71,6 +70,7 @@ static u_int pmu_adb_send(device_t dev, static u_int pmu_adb_autopoll(device_t dev, uint16_t mask); static void pmu_poll(device_t dev); +static void pmu_set_sleepled(void *xsc, int onoff); static int pmu_server_mode(SYSCTL_HANDLER_ARGS); static int pmu_query_battery(struct pmu_softc *sc, int batt, struct pmu_battstate *info); @@ -333,6 +333,9 @@ pmu_attach(device_t dev) } sc->sc_autopoll = 0; + sc->sc_batteries = 0; + sc->adb_bus = NULL; + sc->sc_leddev = NULL; /* Init PMU */ @@ -439,6 +442,12 @@ pmu_attach(device_t dev) } } + /* + * Set up LED interface + */ + + sc->sc_leddev = led_create(pmu_set_sleepled, sc, "sleepled"); + return (bus_generic_attach(dev)); } @@ -449,6 +458,9 @@ pmu_detach(device_t dev) sc = device_get_softc(dev); + if (sc->sc_leddev != NULL) + led_destroy(sc->sc_leddev); + bus_teardown_intr(dev, sc->sc_irq, sc->sc_ih); bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irqrid, sc->sc_irq); bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr); @@ -711,6 +723,19 @@ pmu_adb_autopoll(device_t dev, uint16_t return 0; } +static void +pmu_set_sleepled(void *xsc, int onoff) +{ + struct pmu_softc *sc = xsc; + uint8_t cmd[] = {4, 0, 0}; + + cmd[2] = onoff; + + mtx_lock(&sc->sc_mutex); + pmu_send(sc, PMU_SET_SLEEPLED, 3, cmd, 0, NULL); + mtx_unlock(&sc->sc_mutex); +} + static int pmu_server_mode(SYSCTL_HANDLER_ARGS) { Modified: head/sys/powerpc/powermac/pmuvar.h ============================================================================== --- head/sys/powerpc/powermac/pmuvar.h Tue Dec 9 00:25:57 2008 (r185781) +++ head/sys/powerpc/powermac/pmuvar.h Tue Dec 9 01:01:02 2008 (r185782) @@ -11,9 +11,6 @@ * 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. - * 3. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -76,6 +73,7 @@ #define PMU_I2C_CMD 0x9a /* i2c commands */ #define PMU_GET_LID_STATE 0xdc /* Report lid state */ #define PMU_GET_VERSION 0xea /* Identify thyself */ +#define PMU_SET_SLEEPLED 0xee /* Set sleep LED on/off */ /* Bits in PMU interrupt and interrupt mask bytes */ #define PMU_INT_ADB_AUTO 0x04 /* ADB autopoll, when PMU_INT_ADB */ @@ -161,6 +159,7 @@ struct pmu_softc { device_t adb_bus; volatile int sc_autopoll; int sc_batteries; + struct cdev *sc_leddev; }; struct pmu_battstate {