From owner-svn-src-head@FreeBSD.ORG Sun May 24 07:45:44 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 334E1C93; Sun, 24 May 2015 07:45:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 20EC61DED; Sun, 24 May 2015 07:45:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4O7jilJ021594; Sun, 24 May 2015 07:45:44 GMT (envelope-from ganbold@FreeBSD.org) Received: (from ganbold@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4O7jhXf021591; Sun, 24 May 2015 07:45:43 GMT (envelope-from ganbold@FreeBSD.org) Message-Id: <201505240745.t4O7jhXf021591@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ganbold set sender to ganbold@FreeBSD.org using -f From: Ganbold Tsagaankhuu Date: Sun, 24 May 2015 07:45:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283360 - in head/sys/dev: acpi_support gpio led X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 May 2015 07:45:44 -0000 Author: ganbold Date: Sun May 24 07:45:42 2015 New Revision: 283360 URL: https://svnweb.freebsd.org/changeset/base/283360 Log: This implements default-state support as described in: https://www.kernel.org/doc/Documentation/devicetree/bindings/leds/leds-gpio.txt Without this booting the VSATV102 causes the blue "working" led to turn off when the kernel starts up. With this the led (which is turned on by the firmware) stays on since that's the default state specified in the FDT. Expanded the meaning of the led_create_state state parameter in order to implement support for "keep". The original values were: == 0 Off != 0 On The new values are: == -1 don't change / keep current setting == 0 Off != -1 && != 0 On This should have no effect on acpi_asus_attach which only calls led_create_state with state set to 1. Updated acpi_ibm_attach in order to avoid surprises. Differential Revision: https://reviews.freebsd.org/D2615 Submitted by: John Wehle Reviewed by: gonzo, loos Modified: head/sys/dev/acpi_support/acpi_ibm.c head/sys/dev/gpio/gpioled.c head/sys/dev/led/led.c Modified: head/sys/dev/acpi_support/acpi_ibm.c ============================================================================== --- head/sys/dev/acpi_support/acpi_ibm.c Sun May 24 07:32:02 2015 (r283359) +++ head/sys/dev/acpi_support/acpi_ibm.c Sun May 24 07:45:42 2015 (r283360) @@ -445,7 +445,8 @@ acpi_ibm_attach(device_t dev) /* Hook up light to led(4) */ if (sc->light_set_supported) - sc->led_dev = led_create_state(ibm_led, sc, "thinklight", sc->light_val); + sc->led_dev = led_create_state(ibm_led, sc, "thinklight", + (sc->light_val ? 1 : 0)); return (0); } Modified: head/sys/dev/gpio/gpioled.c ============================================================================== --- head/sys/dev/gpio/gpioled.c Sun May 24 07:32:02 2015 (r283359) +++ head/sys/dev/gpio/gpioled.c Sun May 24 07:45:42 2015 (r283360) @@ -166,8 +166,10 @@ static int gpioled_attach(device_t dev) { struct gpioled_softc *sc; + int state; #ifdef FDT phandle_t node; + char *default_state; char *name; #else const char *name; @@ -177,10 +179,29 @@ gpioled_attach(device_t dev) sc->sc_dev = dev; sc->sc_busdev = device_get_parent(dev); GPIOLED_LOCK_INIT(sc); + + state = 0; + #ifdef FDT - name = NULL; if ((node = ofw_bus_get_node(dev)) == -1) return (ENXIO); + + if (OF_getprop_alloc(node, "default-state", + sizeof(char), (void **)&default_state) != -1) { + if (strcasecmp(default_state, "on") == 0) + state = 1; + else if (strcasecmp(default_state, "off") == 0) + state = 0; + else if (strcasecmp(default_state, "keep") == 0) + state = -1; + else { + device_printf(dev, + "unknown value for default-state in FDT\n"); + } + free(default_state, M_OFWPROP); + } + + name = NULL; if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1) OF_getprop_alloc(node, "name", 1, (void **)&name); #else @@ -189,8 +210,8 @@ gpioled_attach(device_t dev) name = NULL; #endif - sc->sc_leddev = led_create(gpioled_control, sc, name ? name : - device_get_nameunit(dev)); + sc->sc_leddev = led_create_state(gpioled_control, sc, name ? name : + device_get_nameunit(dev), state); #ifdef FDT if (name != NULL) free(name, M_OFWPROP); Modified: head/sys/dev/led/led.c ============================================================================== --- head/sys/dev/led/led.c Sun May 24 07:32:02 2015 (r283359) +++ head/sys/dev/led/led.c Sun May 24 07:45:42 2015 (r283360) @@ -293,7 +293,8 @@ led_create_state(led_t *func, void *priv mtx_lock(&led_mtx); sc->dev->si_drv1 = sc; LIST_INSERT_HEAD(&led_list, sc, list); - sc->func(sc->private, state != 0); + if (state != -1) + sc->func(sc->private, state != 0); mtx_unlock(&led_mtx); return (sc->dev);