From owner-freebsd-arm@FreeBSD.ORG Thu Aug 2 16:56:53 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E0E57106566C for ; Thu, 2 Aug 2012 16:56:53 +0000 (UTC) (envelope-from r.neese@gmail.com) Received: from mail-gg0-f182.google.com (mail-gg0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8A6198FC14 for ; Thu, 2 Aug 2012 16:56:53 +0000 (UTC) Received: by ggnk4 with SMTP id k4so2480930ggn.13 for ; Thu, 02 Aug 2012 09:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=RiYCsKNL0QEjtd7OzJGB+RT9blSmtbdo+A+c2j2QkyI=; b=hAIpA3It3hj+kz7fdCBbQVstA7AWkvTAZpu2IAYZqIoSZwbtJkNr57nvAhJN7EkzzX l+dO25CSqtsV3uz75cZEYqcsl2T+MuG74pTevECHW5bjJOmkd+tnpJz1Y5VdLaxOPLax V1A46TOUbNpE33kUwL02mUrDRaqb+JRxNIsH86iVnbjPV4hjucLXvInXeKChEqUGjHIl oVYGlJ+Ban0s9qAwoFc/dcvdLxEqTsW6qSAWhx+mTaQap2ET9sPZDfWW3Idj6r3DoSrM BTj5YvB2EX4NqjYOpGjUgBDvw7aEKowIqH1iywAmkQAakc0ikzuvcFjR3mlAsZDBghDx q2GQ== Received: by 10.236.143.4 with SMTP id k4mr21955202yhj.111.1343926612774; Thu, 02 Aug 2012 09:56:52 -0700 (PDT) Received: from [127.0.0.1] ([97.100.95.108]) by mx.google.com with ESMTPS id h15sm6008217ank.1.2012.08.02.09.56.51 (version=SSLv3 cipher=OTHER); Thu, 02 Aug 2012 09:56:51 -0700 (PDT) Message-ID: <501AB152.8010707@gmail.com> Date: Thu, 02 Aug 2012 12:56:50 -0400 From: Richard E Neese User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: Ian Lepore References: <501A0547.8090209@gmail.com> <1343915055.1128.35.camel@revolution.hippie.lan> In-Reply-To: <1343915055.1128.35.camel@revolution.hippie.lan> Content-Type: multipart/mixed; boundary="------------050907040200060709020602" Cc: freebsd-arm@freebsd.org Subject: Re: a full updated diff X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Aug 2012 16:56:54 -0000 This is a multi-part message in MIME format. --------------050907040200060709020602 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 8/2/2012 9:44 AM, Ian Lepore wrote: > On Thu, 2012-08-02 at 00:42 -0400, Richard E Neese wrote: >> i merged hrs@FreeBSD.org and my patches together for dreamplug updates. >> his added in the led lights I did not have in mine. >> But this gives 1 full dreamplug update. > Where's the diff? > > -- Ian > > Here is the fixed diff wit the double lines and typo's fixed --------------050907040200060709020602 Content-Type: text/plain; charset=windows-1252; name="dreamplug-svn-stable-080212-1253.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="dreamplug-svn-stable-080212-1253.diff" Index: lib/liblzma/config.h =================================================================== --- lib/liblzma/config.h (revision 238981) +++ lib/liblzma/config.h (working copy) @@ -85,9 +85,9 @@ #define VERSION "5.0.3" #if defined(__FreeBSD__) #include -#if defined(__NO_STRICT_ALIGNMENT) +/*#if defined(__NO_STRICT_ALIGNMENT) #define TUKLIB_FAST_UNALIGNED_ACCESS 1 -#endif +#endif*/ #include #if _BYTE_ORDER == _BIG_ENDIAN # define WORDS_BIGENDIAN 1 Index: etc/rc.d/fsck =================================================================== --- etc/rc.d/fsck (revision 238981) +++ etc/rc.d/fsck (working copy) @@ -27,7 +27,16 @@ if checkyesno background_fsck; then fsck -F -p else - fsck -p + if checkyesno force_fsck; then + echo "Force fsck enabled" + for filesystem in ${force_fsck_list} + do + echo "Force check $filesystem" + fsck -y $filesystem + done + else + fsck -p + fi fi case $? in Index: etc/master.passwd =================================================================== --- etc/master.passwd (revision 238981) +++ etc/master.passwd (working copy) @@ -1,6 +1,6 @@ # $FreeBSD$ # -root::0:0::0:0:Charlie &:/root:/bin/csh +root:$1$pUs8OwQY$mwQTkOTA8hwItKHdP6ECT1:0:0::0:0:Charlie &:/root:/bin/csh toor:*:0:0::0:0:Bourne-again Superuser:/root: daemon:*:1:1::0:0:Owner of many system processes:/root:/usr/sbin/nologin operator:*:2:5::0:0:System &:/:/usr/sbin/nologin 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/kirkwood/files.dreamplug =================================================================== --- sys/arm/mv/kirkwood/files.dreamplug (revision 0) +++ sys/arm/mv/kirkwood/files.dreamplug (working copy) @@ -0,0 +1,5 @@ +# $FreeBSD:$ + +include "arm/mv/kirkwood/files.kirkwood" +arm/mv/gpioled.c standard +arm/mv/kirkwood/dreamplug_led.c standard 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 . + * 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$"); + +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/dreamplug.c =================================================================== --- sys/arm/mv/kirkwood/dreamplug.c (revision 0) +++ sys/arm/mv/kirkwood/dreamplug.c (working copy) @@ -0,0 +1,44 @@ +/*- + * 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. + */ + +#include +__FBSDID("$FreeBSD:$"); + +#include +#include + +#include + +int +fdt_pci_devmap(phandle_t node, struct pmap_devmap *devmap, vm_offset_t io_va, + vm_offset_t mem_va) +{ + + return (0); +} 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,10 @@ +# $FreeBSD:$ + +include "../mv/std.mv" +include "../mv/kirkwood/std.kirkwood" +files "../mv/kirkwood/files.dreamplug" +# $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/arm/mv/mvvar.h =================================================================== --- sys/arm/mv/mvvar.h (revision 238981) +++ sys/arm/mv/mvvar.h (working copy) @@ -45,6 +45,7 @@ #include #include #include +#include #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 . + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +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/conf/DREAMPLUG =================================================================== --- sys/arm/conf/DREAMPLUG (revision 0) +++ sys/arm/conf/DREAMPLUG (working copy) @@ -0,0 +1,243 @@ +# +# Custom kernel for Marvell DreamPlug devices. +# +# $FreeBSD:$ +# + +ident DREAMPLUG +include "../mv/kirkwood/std.dreamplug" + +options SOC_MV_KIRKWOOD +makeoptions MODULES_OVERRIDE="" + +#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols +makeoptions WERROR="-Werror" + +options SCHED_4BSD #4BSD scheduler +options INET #InterNETworking +options INET6 #IPv6 communications protocols +options FFS #Berkeley Fast Filesystem +options MD_ROOT # MD is a potential root device +options NFSCL #New Network Filesystem Client +options NFSLOCKD #Network Lock Manager +options NFS_ROOT #NFS usable as /, requires NFSCL + +#bootp/dhcp for remote booting +#options BOOTP +#options BOOTP_NFSROOT +#options BOOTP_NFSV3 +#options BOOTP_WIRED_TO=mge0 + +# Root fs on USB device +options ROOTDEVNAME=\"ufs:/dev/da2s2\" + +options SYSVSHM #SYSV-style shared memory +options SYSVMSG #SYSV-style message queues +options SYSVSEM #SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions +options MUTEX_NOINLINE +options RWLOCK_NOINLINE +options NO_FFS_SNAPSHOT +options NO_SWAPPING + + +# Debugging +#options ALT_BREAK_TO_DEBUGGER +options BREAK_TO_DEBUGGER +options DDB +#options DEADLKRES #Enable the deadlock resolver +#options DIAGNOSTIC +#options INVARIANTS #Enable calls of extra sanity checking +#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS +options KDB +#options WITNESS #Enable checks to detect deadlocks and cycles +#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed +#options WITNESS_KDB +#options DEBUG + +# Serial ports +device uart + +#ata devices +device ata #base ata driver +options ATA_CAM # Handle legacy controllers with CAM +options ATA_STATIC_ID # Static device numbering + +# SCSI +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +device scbus # SCSI bus (required for SCSI) +device da # Direct Access (disks) +device sa +device cd # CD +device pass + +# SATA +device mvs #Marvell Sata driver +device ahci # AHCI-compatible SATA controllers + +# Partition support +options GEOM_PART_GPT +options GEOM_LABEL +options GEOM_ELI + +# UFS +options UFS_ACL +options UFS_DIRHASH +options UFS_GJOURNAL +options SOFTUPDATES + +# FAT support +options MSDOSFS + +# Misc FSs +options PROCFS +options EXT2FS +device mem +options PSEUDOFS #Pseudo-filesystem framework +options CD9660 #ISO 9660 filesystem +options VFS_AIO +options CD9660_ICONV + +# Sound +device sound +device snd_uaudio + +# Networking +device ether +device mge # Marvell Gigabit Ethernet controller +device mii +device miibus +device e1000phy +device bpf +options HZ=1000 +options DEVICE_POLLING + +#Misc Extra Netwroking +options NETATALK #Appletalk communications protocols +options NETSMB #SMB/CIFS requester +options SMBFS #SMB/CIFS filesystem + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device vlan # 802.1Q VLAN support +device tun # Packet tunnel. +device pty # BSD-style compatibility pseudo ttys +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) +device firmware # firmware assist module + +#crypto +device cesa # Marvell security engine +device crypto +device cryptodev + +#Wireless Networking +device wlan +options IEEE80211_DEBUG # enable debug msgs +options IEEE80211_SUPPORT_MESH # enable 802.11s draft support +device wlan_wep # 802.11 WEP support +device wlan_ccmp # 802.11 CCMP support +device wlan_tkip # 802.11 TKIP support +device wlan_amrr # AMRR transmit rate control algorithm + +# USB DEBUG +#options USB_DEBUG # enable debug msgs +#options USB_REQ_DEBUG + +# USB support +device usb # USB Bus (required) +device ehci # EHCI PCI->USB interface (USB 2.0) +device umass # Disks/Mass storage - Requires scbus and da +device usfs +device uhid +device ums + +#USB WIFI +device rum # Ralink Technology RT2501USB wireless NICs +device uath # Atheros AR5523 wireless NICs +device ural # Ralink Technology RT2500USB wireless NICs +device zyd # ZyDAS zb1211/zb1211b wireless NICs +device urtw # Realtek RTL8187B/L USB +device upgt # Conexant/Intersil PrismGT SoftMAC USB + +# USB Serial devices +device u3g # USB-based 3G modems (Option, Huawei, Sierra) +#options U3G_DEBUG + +#USB Over Ethernet +device cdce # Generic USB over Ethernet + +# MMC/SD (Currently not supported) +#device mv_sdio +#device mmc +#device mmcsd +#device sdhci + +#BLUETOOTH + +# I2C (TWSI) +device iic +device iicbus +device icee + +options LIBICONV +options LIBMCHAIN + +# Flattened Device Tree +options FDT +options FDT_DTB_STATIC +makeoptions FDT_DTS_FILE=dreamplug.dts + +#FireWall +device if_bridge + +# Encapsulating Interface +device enc + +# IPSec +options IPSEC +options IPSEC_NAT_T +options TCP_SIGNATURE #include support for RFC 2385 + +# IPFW support +options IPFIREWALL +options IPFIREWALL_DEFAULT_TO_ACCEPT +options IPFIREWALL_FORWARD +options IPFIREWALL_VERBOSE +options IPFIREWALL_VERBOSE_LIMIT=100 +options DUMMYNET +options IPDIVERT + +# altq(9). Enable the base part of the hooks with the ALTQ option. +# Individual disciplines must be built into the base system and can not be +# loaded as modules at this point. ALTQ requires a stable TSC so if yours is +# broken or changes with CPU throttling then you must also have the ALTQ_NOPCC +# option. +options ALTQ +options ALTQ_CBQ # Class Based Queueing +options ALTQ_RED # Random Early Detection +options ALTQ_RIO # RED In/Out +options ALTQ_HFSC # Hierarchical Packet Scheduler +options ALTQ_CDNR # Traffic conditioner +options ALTQ_PRIQ # Priority Queueing +options ALTQ_NOPCC # Required if the TSC is unusable +#options ALTQ_DEBUG + +# MROUTING enables the kernel multicast packet forwarder, which works +# with mrouted and XORP. +options MROUTING # Multicast routing + +# Add multiple route table support +options ROUTETABLES=16 + +# eliminating data copies on socket reads and writes. +# man 9 zero_copy +options ZERO_COPY_SOCKETS + +#PF +device pf +device pflog +device pfsync Index: sys/dev/ofw/ofw_bus_subr.c =================================================================== --- sys/dev/ofw/ofw_bus_subr.c (revision 238981) +++ 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 238981) +++ 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 238981) +++ 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 238981) +++ 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, --------------050907040200060709020602--