Date: Thu, 02 Aug 2012 06:17:26 +0900 (JST) From: Hiroki Sato <hrs@FreeBSD.org> To: freebsd-arm@FreeBSD.org Subject: DreamPlug LED Message-ID: <20120802.061726.2254798913983129673.hrs@allbsd.org>
next in thread | raw e-mail | index | archive | help
----Security_Multipart0(Thu_Aug__2_06_17_26_2012_057)-- Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Aug__2_06_17_26_2012_279)--" Content-Transfer-Encoding: 7bit ----Next_Part(Thu_Aug__2_06_17_26_2012_279)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I created the attached patch to add an LED control driver for DreamPlug. Can someone test it? /dev/led/* will appear and "echo 1 > /dev/led/BT" will turn the LED on. It is for stable/9 but almost applicable to head too. Please build a kernel after adding the following lines into the kernel config file: |include "../mv/kirkwood/std.dreamplug" |makeoptions FDT_DTS_FILE=dreamplug.dts -- Hiroki ----Next_Part(Thu_Aug__2_06_17_26_2012_279)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dreamplug-led-20120801-1.diff" Index: sys/boot/fdt/dts/dreamplug.dts =================================================================== --- sys/boot/fdt/dts/dreamplug.dts (revision 0) +++ sys/boot/fdt/dts/dreamplug.dts (working copy) @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2010 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Semihalf under sponsorship from + * the FreeBSD Foundation. + * + * 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. + * + * GlobalScale Technologies DreamPlug Device Tree Source. + * + * $FreeBSD$ + */ + +/dts-v1/; + +/ { + model = "GlobalScale Technologies Dreamplug"; + compatible = "globalscale,dreamplug-003-ds2001", "globalscale,dreamplug", "marvell,kirkwood-88f6281", "marvell,kirkwood"; + #address-cells = <1>; + #size-cells = <1>; + + aliases { + ethernet0 = &enet0; + ethernet1 = &enet1; + mpp = &MPP; + serial0 = &serial0; + serial1 = &serial1; + soc = &SOC; + sram = &SRAM; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "ARM,88FR131"; + reg = <0x0>; + d-cache-line-size = <32>; // 32 bytes + i-cache-line-size = <32>; // 32 bytes + d-cache-size = <0x4000>; // L1, 16K + i-cache-size = <0x4000>; // L1, 16K + timebase-frequency = <0>; + bus-frequency = <0>; + clock-frequency = <0>; + }; + + }; + + memory { + device_type = "memory"; + reg = <0x0 0x20000000>; // 512M at 0x0 + }; + + localbus@f1000000 { + #address-cells = <2>; + #size-cells = <1>; + compatible = "mrvl,lbc"; + + /* This reflects CPU decode windows setup. */ + ranges = <0x0 0x0f 0xf9300000 0x00100000 + 0x1 0x1e 0xfa000000 0x00100000 + 0x2 0x1d 0xfa100000 0x02000000 + 0x3 0x1b 0xfc100000 0x00000400>; + + nor@0,0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "cfi-flash"; + reg = <0x0 0x0 0x00100000>; + bank-width = <2>; + device-width = <1>; + }; + + led@1,0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "led"; + reg = <0x1 0x0 0x00100000>; + }; + + nor@2,0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "cfi-flash"; + reg = <0x2 0x0 0x02000000>; + bank-width = <2>; + device-width = <1>; + }; + }; + + SOC: soc88f6281@f1000000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges = <0x0 0xf1000000 0x00100000>; + bus-frequency = <0>; + + PIC: pic@20200 { + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <1>; + reg = <0x20200 0x3c>; + compatible = "mrvl,pic"; + }; + + timer@20300 { + compatible = "mrvl,timer"; + reg = <0x20300 0x30>; + interrupts = <1>; + interrupt-parent = <&PIC>; + mrvl,has-wdt; + }; + + MPP: mpp@10000 { + #pin-cells = <2>; + compatible = "mrvl,mpp"; + reg = <0x10000 0x34>; + pin-count = <50>; + pin-map = < + 0 2 /* MPP[0]: SPI_SCn */ + 1 2 /* MPP[1]: SPI_MOSI */ + 2 2 /* MPP[2]: SPI_SCK */ + 3 2 /* MPP[3]: SPI_MISO */ + 6 1 /* MPP[6]: SYSRST_OUTn */ + 8 2 /* MPP[8]: UA0_RTS */ + 9 2 /* MPP[9]: UA0_CTS */ + 10 3 /* MPP[10]: UA0_TXD */ + 11 3 /* MPP[11]: UA0_RXD */ + 12 1 /* MPP[12]: SD_CLK */ + 13 1 /* MPP[13]: SD_CMD */ + 14 1 /* MPP[14]: SD_D[0] */ + 15 1 /* MPP[17]: SD_D[1] */ + 21 5 /* MPP[21]: SATA0_AC */ + 23 5 /* MPP[23]: SATA0_PR */ + 28 0 /* MPP[28]: GPIO[28] */ + 29 1 /* MPP[29]: TSMP[9] */ + 37 4 /* MPP[37]: AU_SPDIFO */ + 38 4 /* MPP[38]: AU_SPDOFRMCLK */ + 39 4 /* MPP[39]: AU_I2SBCLK */ + 40 4 /* MPP[40]: AU_I2SDO */ + 41 4 /* MPP[41]: AU_I2SLRCLK */ + 42 4 /* MPP[42]: AU_I2SMCLK */ + 43 4 /* MPP[43]: AU_I2SDI */ + 44 4 /* MPP[44]: AU_EXTCLK */ + 47 0 /* MPP[47]: GPIO[47] BT LED */ + 48 0 /* MPP[48]: GPIO[48] WLAN LED */ + 49 0>; /* MPP[49]: GPIO[49] WLAN AP */ + }; + + GPIO: gpio@10100 { + #gpio-cells = <3>; + compatible = "mrvl,gpio"; + reg = <0x10100 0x20>; + gpio-controller; + interrupts = <35 36 37 38 39 40 41>; + interrupt-parent = <&PIC>; + pin-count = <50>; + }; + + gpioled@0 { + compatible = "mrvl,gpioled"; + + gpios = <&GPIO 47 2 0 /* GPIO[47] BT LED: OUT */ + &GPIO 48 2 0 /* GPIO[48] WLAN LED: OUT */ + &GPIO 49 2 0>; /* GPIO[49] WLAN AP LED: OUT */ + }; + + rtc@10300 { + compatible = "mrvl,rtc"; + reg = <0x10300 0x08>; + }; + + twsi@11000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "mrvl,twsi"; + reg = <0x11000 0x20>; + interrupts = <43>; + interrupt-parent = <&PIC>; + }; + + enet0: ethernet@72000 { + #address-cells = <1>; + #size-cells = <1>; + model = "V2"; + compatible = "mrvl,ge"; + reg = <0x72000 0x2000>; + ranges = <0x0 0x72000 0x2000>; + local-mac-address = [ 00 00 00 00 00 00 ]; + interrupts = <12 13 14 11 46>; + interrupt-parent = <&PIC>; + phy-handle = <&phy0>; + + mdio@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "mrvl,mdio"; + + phy0: ethernet-phy@0 { + reg = <0x0>; + }; + + phy1: ethernet-phy@1 { + reg = <0x1>; + }; + }; + }; + + enet1: ethernet@76000 { + #address-cells = <1>; + #size-cells = <1>; + model = "V2"; + compatible = "mrvl,ge"; + reg = <0x76000 0x02000>; + ranges = <0x0 0x76000 0x2000>; + local-mac-address = [ 00 00 00 00 00 00 ]; + interrupts = <16 17 18 15 47>; + interrupt-parent = <&PIC>; + phy-handle = <&phy1>; + }; + + serial0: serial@12000 { + compatible = "ns16550"; + reg = <0x12000 0x20>; + reg-shift = <2>; + clock-frequency = <0>; + interrupts = <33>; + interrupt-parent = <&PIC>; + }; + + serial1: serial@12100 { + compatible = "ns16550"; + reg = <0x12100 0x20>; + reg-shift = <2>; + clock-frequency = <0>; + interrupts = <34>; + interrupt-parent = <&PIC>; + }; + + crypto@30000 { + compatible = "mrvl,cesa"; + reg = <0x30000 0x10000>; + interrupts = <22>; + interrupt-parent = <&PIC>; + + sram-handle = <&SRAM>; + }; + + usb@50000 { + compatible = "mrvl,usb-ehci", "usb-ehci"; + reg = <0x50000 0x1000>; + interrupts = <48 19>; + interrupt-parent = <&PIC>; + }; + + xor@60000 { + compatible = "mrvl,xor"; + reg = <0x60000 0x1000>; + interrupts = <5 6 7 8>; + interrupt-parent = <&PIC>; + }; + + sata@80000 { + compatible = "mrvl,sata"; + reg = <0x80000 0x6000>; + interrupts = <21>; + interrupt-parent = <&PIC>; + } + + sdio@90000 { + compatible = "mrvl,sdio"; + reg = <0x90000 0x134>; + interrupts = <28>; + interrupt-parent = <&PIC>; + }; + }; + + SRAM: sram@fd000000 { + compatible = "mrvl,cesa-sram"; + reg = <0xfd000000 0x00100000>; + }; + + chosen { + stdin = "serial0"; + stdout = "serial0"; + }; + +}; Index: sys/arm/mv/mvvar.h =================================================================== --- sys/arm/mv/mvvar.h (revision 238979) +++ sys/arm/mv/mvvar.h (working copy) @@ -45,6 +45,7 @@ #include <vm/pmap.h> #include <machine/pmap.h> #include <machine/vm.h> +#include <machine/fdt.h> #define MV_TYPE_PCI 0 #define MV_TYPE_PCIE 1 @@ -55,6 +56,13 @@ int gc_output; /* GPIO output value */ }; +typedef int (*gpios_phandler_t)(phandle_t, pcell_t *, int); + +struct gpio_ctrl_entry { + const char *compat; + gpios_phandler_t handler; +}; + struct decode_win { int target; /* Mbus unit ID */ int attr; /* Attributes of the target interface */ Index: sys/arm/mv/gpioled.c =================================================================== --- sys/arm/mv/gpioled.c (revision 0) +++ sys/arm/mv/gpioled.c (working copy) @@ -0,0 +1,206 @@ +/*- + * Copyright (c) 2012 Hiroki Sato <hrs@FreeBSD.org>. + * 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. + * + * GPIO-LED bridge driver for Marvell GPIO Controller. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/bus.h> +#include <machine/fdt.h> + +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> + +#include <arm/mv/mvreg.h> +#include <arm/mv/mvvar.h> + +#include <dev/led/led.h> + +extern const char *gpioled_devdesc; +extern const char *gpioled_namelist[]; + +extern struct gpio_ctrl_entry gpio_controllers[]; + +struct gpioled_ledlist { + LIST_ENTRY(gpioled_ledlist) list; + + struct cdev *ll_cdev; + const char *ll_name; + int ll_pin; +}; + +struct gpioled_softc { + LIST_HEAD(, gpioled_ledlist) sc_llh; + + device_t sc_dev; +}; + +static MALLOC_DEFINE(M_GPIOLED, "GPIOLED", "GPIO LED driver"); + +static int +led_probe(device_t dev) +{ + + if (!ofw_bus_is_compatible(dev, "mrvl,gpioled")) + return (ENXIO); + + device_set_desc(dev, gpioled_devdesc); + + return (0); +} + +static void +led_onoff(void *args, int onoff) +{ + struct gpioled_ledlist *ll = (struct gpioled_ledlist *)args; + + mv_gpio_out(ll->ll_pin, 0, onoff); +} + +#define MAX_PINS_PER_NODE 5 +#define GPIOS_PROP_CELLS 4 +static int +led_attach(device_t dev) +{ + struct gpioled_softc *sc = device_get_softc(dev); + struct gpio_ctrl_entry *e; + struct gpioled_ledlist *ll = NULL; + phandle_t node, ctrl = 0; + ihandle_t ctrl_ihandle; + pcell_t *g; + pcell_t gpios[MAX_PINS_PER_NODE * GPIOS_PROP_CELLS]; + pcell_t gpio_cells, pincnt; + const char **nl; + int len, tuples, tuple_size; + int i; + + sc->sc_dev = dev; + LIST_INIT(&sc->sc_llh); + + if ((node = ofw_bus_get_node(dev)) == -1) + return (ENXIO); + if ((len = OF_getproplen(node, "gpios")) <= 0) + return (ENXIO); + OF_getprop(node, "gpios", &gpios, len); + + e = (struct gpio_ctrl_entry *)&gpio_controllers; + for (; e->compat; e++) { + ctrl_ihandle = (ihandle_t)gpios[0]; + ctrl_ihandle = fdt32_to_cpu(ctrl_ihandle); + ctrl = OF_instance_to_package(ctrl_ihandle); + if (fdt_is_compatible(ctrl, e->compat)) + break; + } + if (e == NULL) + return (ENXIO); + + if (OF_getprop(ctrl, "#gpio-cells", &gpio_cells, + sizeof(pcell_t)) < 0) + return (ENXIO); + gpio_cells = fdt32_to_cpu(gpio_cells); + if (gpio_cells != 3) + return (ENXIO); + + tuple_size = gpio_cells * sizeof(pcell_t) + sizeof(phandle_t); + tuples = len / tuple_size; + + if (OF_getprop(ctrl, "pin-count", &pincnt, sizeof(pcell_t)) < 0) + return (ENXIO); + pincnt = fdt32_to_cpu(pincnt); + + g = (pcell_t *)&gpios; + nl = gpioled_namelist; + + for (i = 0; i < tuples; i++) { + /* Ignore tuples if it too many than the name list. */ + if (nl[i] == NULL) + break; + + /* Skip controller reference. */ + g += sizeof(ihandle_t) / sizeof(pcell_t); + + /* The direction must be 2 (OUT). */ + if (fdt32_to_cpu(g[1]) != 2) + continue; + + /* Check maximum pin count. */ + if (fdt32_to_cpu(g[0]) > pincnt) + continue; + + ll = malloc(sizeof *ll, M_GPIOLED, M_WAITOK | M_ZERO); + ll->ll_pin = fdt32_to_cpu(g[0]); + ll->ll_name = nl[i]; + ll->ll_cdev = led_create(led_onoff, ll, ll->ll_name); + if (bootverbose) + device_printf(dev, "Add LED device: %s(%d)\n", + ll->ll_name, ll->ll_pin); + LIST_INSERT_HEAD(&sc->sc_llh, ll, list); + + g += gpio_cells; + } + + return (0); +} + +static int +led_detach(device_t dev) +{ + struct gpioled_softc *sc = device_get_softc(dev); + struct gpioled_ledlist *ll; + + while (!LIST_EMPTY(&sc->sc_llh)) { + ll = LIST_FIRST(&sc->sc_llh); + LIST_REMOVE(ll, list); + if (ll->ll_cdev != NULL) + led_destroy(ll->ll_cdev); + free(ll, M_GPIOLED); + } + + return (0); +} + +static device_method_t led_methods[] = { + DEVMETHOD(device_probe, led_probe), + DEVMETHOD(device_attach, led_attach), + DEVMETHOD(device_detach, led_detach), + {0, 0}, +}; + +static driver_t led_driver = { + "gpioled", + led_methods, + sizeof(struct gpioled_softc), +}; + +static devclass_t led_devclass; +DRIVER_MODULE(gpioled, simplebus, led_driver, led_devclass, 0, 0); +MODULE_VERSION(gpioled, 1); Index: sys/arm/mv/kirkwood/dreamplug_led.c =================================================================== --- sys/arm/mv/kirkwood/dreamplug_led.c (revision 0) +++ sys/arm/mv/kirkwood/dreamplug_led.c (working copy) @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2012 Hiroki Sato <hrs@FreeBSD.org>. + * 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 <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +const char *gpioled_namelist[] = { + "BT", /* GPIO[47] */ + "WLAN", /* GPIO[48] */ + "WLANAP", /* GPIO[49] */ + 0, +}; +const char *gpioled_devdesc = "DreamPlug Front Panel LED Driver"; Index: sys/arm/mv/kirkwood/files.dreamplug =================================================================== --- sys/arm/mv/kirkwood/files.dreamplug (revision 0) +++ sys/arm/mv/kirkwood/files.dreamplug (working copy) @@ -0,0 +1,6 @@ +# $FreeBSD: src/sys/arm/mv/kirkwood/files.sheevaplug,v 1.1.4.1 2011/09/23 00:51:37 kensmith Exp $ + +include "arm/mv/kirkwood/files.kirkwood" +arm/mv/kirkwood/sheevaplug.c standard +arm/mv/gpioled.c standard +arm/mv/kirkwood/dreamplug_led.c standard Index: sys/arm/mv/kirkwood/std.dreamplug =================================================================== --- sys/arm/mv/kirkwood/std.dreamplug (revision 0) +++ sys/arm/mv/kirkwood/std.dreamplug (working copy) @@ -0,0 +1,5 @@ +# $FreeBSD: src/sys/arm/mv/kirkwood/std.sheevaplug,v 1.3.2.1 2011/09/23 00:51:37 kensmith Exp $ + +include "../mv/std.mv" +include "../mv/kirkwood/std.kirkwood" +files "../mv/kirkwood/files.dreamplug" Index: sys/dev/ofw/ofw_bus_subr.c =================================================================== --- sys/dev/ofw/ofw_bus_subr.c (revision 238979) +++ sys/dev/ofw/ofw_bus_subr.c (working copy) @@ -167,7 +167,8 @@ onelen = strlen(onecompat); while (len > 0) { - if (strncasecmp(compat, onecompat, onelen) == 0) + if (strlen(compat) == onelen && + strncasecmp(compat, onecompat, onelen) == 0) /* Found it. */ return (1); @@ -183,16 +184,31 @@ ofw_bus_is_compatible_strict(device_t dev, const char *compatible) { const char *compat; + size_t len; if ((compat = ofw_bus_get_compat(dev)) == NULL) return (0); - if (strncasecmp(compat, compatible, strlen(compatible)) == 0) + len = strlen(compatible); + + if (strlen(compat) == len && + strncasecmp(compat, compatible, len) == 0) return (1); return (0); } +int +ofw_bus_has_prop(device_t dev, const char *propname) +{ + phandle_t node; + + if ((node = ofw_bus_get_node(dev)) == -1) + return (0); + + return (OF_hasprop(node, propname)); +} + #ifndef FDT void ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz) Index: sys/dev/ofw/ofw_bus_subr.h =================================================================== --- sys/dev/ofw/ofw_bus_subr.h (revision 238979) +++ sys/dev/ofw/ofw_bus_subr.h (working copy) @@ -74,4 +74,7 @@ int ofw_bus_is_compatible(device_t, const char *); int ofw_bus_is_compatible_strict(device_t, const char *); +/* Helper routine for checking exsistence of a prop */ +int ofw_bus_has_prop(device_t, const char *); + #endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */ Index: sys/dev/ofw/openfirm.c =================================================================== --- sys/dev/ofw/openfirm.c (revision 238979) +++ sys/dev/ofw/openfirm.c (working copy) @@ -261,6 +261,14 @@ return (OFW_GETPROPLEN(ofw_obj, package, propname)); } +/* Check exsistence of a property of a package. */ +int +OF_hasprop(phandle_t package, const char *propname) +{ + + return (OF_getproplen(package, propname) >= 0 ? 1 : 0); +} + /* Get the value of a property of a package. */ ssize_t OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen) Index: sys/dev/ofw/openfirm.h =================================================================== --- sys/dev/ofw/openfirm.h (revision 238979) +++ sys/dev/ofw/openfirm.h (working copy) @@ -105,6 +105,7 @@ ssize_t OF_getproplen(phandle_t node, const char *propname); ssize_t OF_getprop(phandle_t node, const char *propname, void *buf, size_t len); +int OF_hasprop(phandle_t node, const char *propname); ssize_t OF_searchprop(phandle_t node, const char *propname, void *buf, size_t len); ssize_t OF_getprop_alloc(phandle_t node, const char *propname, ----Next_Part(Thu_Aug__2_06_17_26_2012_279)---- ----Security_Multipart0(Thu_Aug__2_06_17_26_2012_057)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEABECAAYFAlAZnOYACgkQTyzT2CeTzy0B1QCfQrqXKh+3BHSw854XjbH1x5OI ouoAoKwsQfRAePMsTe36KKuy1Y6MzpDk =enZf -----END PGP SIGNATURE----- ----Security_Multipart0(Thu_Aug__2_06_17_26_2012_057)----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120802.061726.2254798913983129673.hrs>