Date: Sun, 24 May 2015 07:45:43 +0000 (UTC) From: Ganbold Tsagaankhuu <ganbold@FreeBSD.org> 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 Message-ID: <201505240745.t4O7jhXf021591@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505240745.t4O7jhXf021591>