svn commit: r335779 - in head/sys: arm/broadcom/bcm2835 conf

2018-06-28 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Jun 28 21:14:33 2018
New Revision: 335779
URL: https://svnweb.freebsd.org/changeset/base/335779

Log:
  [rpi] Add SDHOST device driver for Raspberry Pi
  
  SDHOST is another SD controller that is present on Raspberry Pi (the
  other one is SDHC and handled by bcm2835_sdhci driver). Both
  controllers are capable of providing interface to SD card, actual
  configuration can be set in dtb file. At the moment custom DTBs for
  RPi/RPi2 have sdhost node disabled. On RPi3 sdhost is disabled in
  snapshot images by applying mmc.dtbo overlay. To enalbe both devices
  user has to edit config.txt on FAT partition and remove or comment
  "dtoverlay=mmc" line.
  
  When no overlay applied on RPi3 SDHOST controls SD card and SDHC
  interface can be used for SDIO. mmc.dtbo overlay disables SDHOST node
  and switches SD card over to SDHC.  Likewise sdhost.dtbo overlay (not
  currently included in snapshot image, but can be obtained from firmare
  repo[1]) disabled SDHC node and switch SD card over to SDHOST.
  
  [1] https://github.com/raspberrypi/firmware/tree/master/boot/overlays
  
  Submitted by: Klaus P. Ohrhallinger 
  Differential Revision:https://reviews.freebsd.org/D14168

Added:
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c   (contents, props changed)
Modified:
  head/sys/arm/broadcom/bcm2835/files.bcm283x
  head/sys/conf/files.arm64

Added: head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c  Thu Jun 28 21:14:33 
2018(r335779)
@@ -0,0 +1,1301 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Klaus P. Ohrhallinger 
+ * All rights reserved.
+ *
+ * Based on bcm2835_sdhci.c:
+ * Copyright (c) 2012 Oleksandr Tymoshenko 
+ * 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$");
+
+/*
+ * pin 48-53 - card slot
+ * pin 34-39 - radio module
+ *
+ * alt-0 - rubbish SDHCI  (0x7e202000) aka sdhost
+ * alt-3 - advanced SDHCI (0x7e30) aka sdhci/mmc/sdio
+ *
+ * driving card slot with mmc:
+ *
+ * sdhost_pins {
+ * brcm,pins = <0x30 0x31 0x32 0x33 0x34 0x35>;
+ * brcm,function = <0x7>;
+ * brcm,pull = <0x0 0x2 0x2 0x2 0x2 0x2>;
+ * phandle = <0x17>;
+ * };
+ * sdio_pins {
+ * brcm,pins = <0x22 0x23 0x24 0x25 0x26 0x27>;
+ * brcm,function = <0x4>;
+ * brcm,pull = <0x0 0x2 0x2 0x2 0x2 0x2>;
+ * phandle = <0x18>;
+ * };
+ *
+ * driving card slot with sdhost:
+ *
+ * sdhost_pins {
+ * brcm,pins = <0x30 0x31 0x32 0x33 0x34 0x35>;
+ * brcm,function = <0x4>;
+ * brcm,pull = <0x0 0x2 0x2 0x2 0x2 0x2>;
+ * phandle = <0x17>;
+ * };
+ * sdio_pins {
+ * brcm,pins = <0x22 0x23 0x24 0x25 0x26 0x27>;
+ * brcm,function = <0x7>;
+ * brcm,pull = <0x0 0x2 0x2 0x2 0x2 0x2>;
+ * phandle = <0x18>;
+ * };
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "mmcbr_if.h"
+#include "sdhci_if.h"
+
+#include "opt_mmccam.h"
+
+#include "bcm2835_dma.h"
+#include 
+#include "bcm2835_vcbus.h"
+
+
+/* #define SDHOST_DEBUG */
+
+
+/* Registers */
+#define HC_COMMAND 0x00/* Command a

svn commit: r335675 - head/contrib/file/magic/Magdir

2018-06-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Jun 26 18:53:52 2018
New Revision: 335675
URL: https://svnweb.freebsd.org/changeset/base/335675

Log:
  Fix file(1) dumpdate reporting for dump(8) files
  
  Magic file for dump(8) had this dump and previous dump dates reversed.
  Fix order for all three flavours of the dump(8) format.
  This fix was committed to upstream repo as magic/Magdir/dump,v 1.17
  and will be merged during next vendor import.
  
  PR:   223155
  MFC after:2 weeks

Modified:
  head/contrib/file/magic/Magdir/dump

Modified: head/contrib/file/magic/Magdir/dump
==
--- head/contrib/file/magic/Magdir/dump Tue Jun 26 18:29:56 2018
(r335674)
+++ head/contrib/file/magic/Magdir/dump Tue Jun 26 18:53:52 2018
(r335675)
@@ -6,8 +6,8 @@
 # We specify both byte orders in order to recognize byte-swapped dumps.
 #
 0  namenew-dump-be
->4 bedate  x   Previous dump %s,
->8 bedate  x   This dump %s,
+>4 bedate  x   This dump %s,
+>8 bedate  x   Previous dump %s,
 >12belong  >0  Volume %d,
 >692   belong  0   Level zero, type:
 >692   belong  >0  Level %d, type:
@@ -25,8 +25,8 @@
 >888   belong  >0  Flags %x
 
 0  nameold-dump-be
-#>4bedate  x   Previous dump %s,
-#>8bedate  x   This dump %s,
+#>4bedate  x   This dump %s,
+#>8bedate  x   Previous dump %s,
 >12belong  >0  Volume %d,
 >692   belong  0   Level zero, type:
 >692   belong  >0  Level %d, type:
@@ -44,8 +44,8 @@
 >888   belong  >0  Flags %x
 
 0  nameufs2-dump-be
->896   beqdate x   Previous dump %s,
->904   beqdate x   This dump %s,
+>896   beqdate x   This dump %s,
+>904   beqdate x   Previous dump %s,
 >12belong  >0  Volume %d,
 >692   belong  0   Level zero, type:
 >692   belong  >0  Level %d, type:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335611 - head/sys/arm/broadcom/bcm2835

2018-06-24 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Jun 24 23:19:31 2018
New Revision: 335611
URL: https://svnweb.freebsd.org/changeset/base/335611

Log:
  [rpi] Fix compatiblity with upstream DTB for RPi 3B and 3B+
  
  Upstream dtb switched to using brcm,bcm2837 for platform
  compatibility string. Patch platfrom and cpufreq compatiblity
  data accordingly.
  
  Submitted by: Sylvain Garrigues 
  Tested by:db@
  Differential Revision:https://reviews.freebsd.org/D15998

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
  head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Sun Jun 24 21:46:29 
2018(r335610)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Sun Jun 24 23:19:31 
2018(r335611)
@@ -127,6 +127,7 @@ static struct ofw_compat_data compat_data[] = {
{ "broadcom,bcm2708-vc",1 },
{ "brcm,bcm2709",   1 },
{ "brcm,bcm2836",   1 },
+   { "brcm,bcm2837",   1 },
{ NULL, 0 }
 };
 

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Sun Jun 24 21:46:29 
2018(r335610)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Sun Jun 24 23:19:31 
2018(r335611)
@@ -154,4 +154,5 @@ static platform_method_t bcm2836_methods[] = {
 };
 FDT_PLATFORM_DEF2(bcm2836, bcm2836_legacy, "bcm2836 (legacy)", 0, 
"brcm,bcm2709", 100);
 FDT_PLATFORM_DEF2(bcm2836, bcm2836, "bcm2836", 0, "brcm,bcm2836", 100);
+FDT_PLATFORM_DEF2(bcm2836, bcm2837, "bcm2837", 0, "brcm,bcm2837", 100);
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335587 - head/share/man/man9

2018-06-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Jun 23 20:05:07 2018
New Revision: 335587
URL: https://svnweb.freebsd.org/changeset/base/335587

Log:
  Document multi variants of *prop_alloc functions
  
  Add documentation and symlinks for OF_getprop_alloc_multi
  and OF_getencprop_alloc_multi functions.
  
  Also while here fix copy-pasted .Dt value and add one more
  failure condition for OF_getencprop_alloc.

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/OF_getprop.9

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSat Jun 23 19:30:29 2018
(r335586)
+++ head/share/man/man9/MakefileSat Jun 23 20:05:07 2018
(r335587)
@@ -1540,7 +1540,9 @@ MLINKS+=OF_device_from_xref.9 OF_device_register_xref.
OF_device_from_xref.9 OF_xref_from_device.9
 MLINKS+=OF_getprop.9 OF_getencprop.9 \
OF_getprop.9 OF_getencprop_alloc.9 \
+   OF_getprop.9 OF_getencprop_alloc_multi.9 \
OF_getprop.9 OF_getprop_alloc.9 \
+   OF_getprop.9 OF_getprop_alloc_multi.9 \
OF_getprop.9 OF_getproplen.9 \
OF_getprop.9 OF_hasprop.9 \
OF_getprop.9 OF_nextprop.9 \

Modified: head/share/man/man9/OF_getprop.9
==
--- head/share/man/man9/OF_getprop.9Sat Jun 23 19:30:29 2018
(r335586)
+++ head/share/man/man9/OF_getprop.9Sat Jun 23 20:05:07 2018
(r335587)
@@ -25,8 +25,8 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 9, 2018
-.Dt OF_CHILD 9
+.Dd June 23, 2018
+.Dt OF_GETPROP 9
 .Os
 .Sh NAME
 .Nm OF_getprop ,
@@ -37,6 +37,8 @@
 .Nm OF_searchencprop ,
 .Nm OF_getprop_alloc ,
 .Nm OF_getencprop_alloc ,
+.Nm OF_getprop_alloc_multi ,
+.Nm OF_getencprop_alloc_multi ,
 .Nm OF_prop_free ,
 .Nm OF_nextprop ,
 .Nm OF_setprop
@@ -66,6 +68,12 @@
 .Ft ssize_t
 .Fn OF_getencprop_alloc "phandle_t node" "const char *propname" \
 "pcell_t **buf"
+.Ft ssize_t
+.Fn OF_getprop_alloc_multi "phandle_t node" "const char *propname" \
+"int elsz" "void **buf"
+.Ft ssize_t
+.Fn OF_getencprop_alloc_multi "phandle_t node" "const char *propname" \
+"int elsz" "pcell_t **buf"
 .Ft void
 .Fn OF_prop_free "void *buf"
 .Ft int
@@ -204,19 +212,73 @@ If the property has zero-length value,
 .Fa *buf
 is set to NULL.
 Returns -1 if the property does not exist or
-memory allocation failed.
+memory allocation failed or the size of the value is not
+divisible by a cell size (4 bytes).
 Allocated memory should be released when no longer required
 by calling
 .Fn OF_prop_free .
 The function might sleep when allocating memory.
 .Pp
+.Fn OF_getprop_alloc_multi
+allocates memory large enough to hold the
+value associated with the property
+.Fa propname
+of the device node
+.Fa node
+and copies the value into the newly allocated memory region.
+The value is expected to be an array of zero or more elements
+.Fa elsz
+bytes long.
+Returns the number of elements in the value and stores
+the address of the allocated memory in
+.Fa *buf .
+If the property has a zero-sized value
+.Fa *buf
+is set NULL.
+Returns -1 if the property does not exist or
+memory allocation failed or the size of the value is not
+divisible by
+.Fa elsz .
+Allocated memory should be released when no longer required
+by calling
+.Fn OF_prop_free .
+The function might sleep when allocating memory.
+.Pp
+.Fn OF_getencprop_alloc_multi
+allocates memory large enough to hold the
+value associated with the property
+.Fa propname
+of the device node
+.Fa node
+and copies the value into the newly allocated memory region, and
+then converts cell values from big-endian to host byte
+order.
+The value is expected to be an array of zero or more elements
+.Fa elsz
+bytes long.
+Returns the number of elements in the value and stores
+the address of the allocated memory in
+.Fa *buf .
+If the property has a zero-sized value
+.Fa *buf
+is set NULL.
+Returns -1 if the property does not exist or
+memory allocation failed or the size of the value is not
+divisible by
+.Fa elsz .
+Allocated memory should be released when no longer required
+by calling
+.Fn OF_prop_free .
+The function might sleep when allocating memory.
+.Pp
 .Fn OF_prop_free
 releases memory at
 .Fa buf
 that was allocated by
-.Fn OF_getprop_alloc
-or
-.Fn OF_getencprop_alloc .
+.Fn OF_getprop_alloc ,
+.Fn OF_getencprop_alloc ,
+.Fn OF_getprop_alloc_multi ,
+.Fn OF_getencprop_alloc_multi .
 .Pp
 .Fn OF_nextprop
 copies a maximum of
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335586 - head/share/man/man9

2018-06-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Jun 23 19:30:29 2018
New Revision: 335586
URL: https://svnweb.freebsd.org/changeset/base/335586

Log:
  Bump .Dd value after r335585

Modified:
  head/share/man/man9/fdt_pinctrl.9

Modified: head/share/man/man9/fdt_pinctrl.9
==
--- head/share/man/man9/fdt_pinctrl.9   Sat Jun 23 19:01:05 2018
(r335585)
+++ head/share/man/man9/fdt_pinctrl.9   Sat Jun 23 19:30:29 2018
(r335586)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 3, 2018
+.Dd June 23, 2018
 .Dt fdt_pinctrl 9
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r335585 - head/share/man/man9

2018-06-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Jun 23 19:01:05 2018
New Revision: 335585
URL: https://svnweb.freebsd.org/changeset/base/335585

Log:
  Fix invalid OF_getencprop_alloc usage in fdt_pinctrl(9)
  
  r332341 introduced OF_getencprop_alloc_multi that should be used
  instead of OF_getencprop_alloc to get multi-cell properties.
  Fix example to reflect this change.

Modified:
  head/share/man/man9/fdt_pinctrl.9

Modified: head/share/man/man9/fdt_pinctrl.9
==
--- head/share/man/man9/fdt_pinctrl.9   Sat Jun 23 18:20:17 2018
(r335584)
+++ head/share/man/man9/fdt_pinctrl.9   Sat Jun 23 19:01:05 2018
(r335585)
@@ -116,10 +116,10 @@ foo_configure_pins(device_t dev, phandle_t cfgxref)
 
cfgnode = OF_node_from_xref(cfgxref);
pins = NULL;
-   npins = OF_getencprop_alloc(cfgnode, "foo,pins", sizeof(*pins),
+   npins = OF_getencprop_alloc_multi(cfgnode, "foo,pins", sizeof(*pins),
(void **)&pins);
functions = NULL;
-   nfunctions = OF_getencprop_alloc(cfgnode, "foo,functions",
+   nfunctions = OF_getencprop_alloc_multi(cfgnode, "foo,functions",
sizeof(*functions), (void **)&functions);
...
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r333177 - head/sys/arm/broadcom/bcm2835

2018-05-02 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed May  2 20:04:25 2018
New Revision: 333177
URL: https://svnweb.freebsd.org/changeset/base/333177

Log:
  Unbreak RaspberryPi 2 boot after r332839
  
  r332839 changed number of cells per interrupt for local_intc from 1 to 2
  to pass type of IRQ. Driver expected only 1 cell so after r332839
  all interrupt children of local_intc failed to allocate IRQ resource.
  
  Fix this regression by relaxing check for number of cells in interrupt
  property to be either 1 or 2.
  
  PR:   227904

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2836.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2836.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2836.c Wed May  2 19:36:46 2018
(r333176)
+++ head/sys/arm/broadcom/bcm2835/bcm2836.c Wed May  2 20:04:25 2018
(r333177)
@@ -454,8 +454,10 @@ bcm_lintc_map_intr(device_t dev, struct intr_map_data 
return (ENOTSUP);
 
daf = (struct intr_map_data_fdt *)data;
-   if (daf->ncells != 1 || daf->cells[0] >= BCM_LINTC_NIRQS)
+   if (daf->ncells > 2 || daf->cells[0] >= BCM_LINTC_NIRQS)
return (EINVAL);
+
+   /* TODO: handle IRQ type here */
 
sc = device_get_softc(dev);
*isrcp = &sc->bls_isrcs[daf->cells[0]].bli_isrc;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332442 - head/lib/libc/gen

2018-04-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Apr 12 17:47:36 2018
New Revision: 332442
URL: https://svnweb.freebsd.org/changeset/base/332442

Log:
  Bump .Dd value (forgot to do this in r332439)
  
  MFC after:3 days
  X-MFC-With:   332439

Modified:
  head/lib/libc/gen/syslog.3

Modified: head/lib/libc/gen/syslog.3
==
--- head/lib/libc/gen/syslog.3  Thu Apr 12 17:43:19 2018(r332441)
+++ head/lib/libc/gen/syslog.3  Thu Apr 12 17:47:36 2018(r332442)
@@ -28,7 +28,7 @@
 .\" @(#)syslog.3   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd April 6, 2018
+.Dd April 12, 2018
 .Dt SYSLOG 3
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332439 - head/lib/libc/gen

2018-04-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Apr 12 17:05:27 2018
New Revision: 332439
URL: https://svnweb.freebsd.org/changeset/base/332439

Log:
  Fix quotes in the example code in syslog(3) BUGS section
  
  mdoc treats verbatim quotes in .Dl as a string delimiter and does
  not pass them to the rendered output. Use special char \*q to specify
  double quote
  
  PR:   216755
  MFC after:3 days

Modified:
  head/lib/libc/gen/syslog.3

Modified: head/lib/libc/gen/syslog.3
==
--- head/lib/libc/gen/syslog.3  Thu Apr 12 17:00:36 2018(r332438)
+++ head/lib/libc/gen/syslog.3  Thu Apr 12 17:05:27 2018(r332439)
@@ -295,4 +295,4 @@ for later interpolation by
 .Pp
 Always use the proper secure idiom:
 .Pp
-.Dl syslog(priority, "%s", string);
+.Dl syslog(priority, \*q%s\*q, string);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332392 - head/sys/arm/broadcom/bcm2835

2018-04-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Apr 10 20:31:25 2018
New Revision: 332392
URL: https://svnweb.freebsd.org/changeset/base/332392

Log:
  [pi] Do not attach bcm2835_pwm if DTB node is not enabled
  
  Switch to standard FDT-base driver behavior and don't attach
  if node "status" property value nn DTS is not set to "okay"
  
  On RPi PWM by default is disabled, to enable it pwm.dtbo
  from official repo[1] should be copied to overlays directory
  on SD card FAT partition and "dtoverlay=pwm" line added to
  config.txt. For more details see pwm overlay documentation[2]
  
  sysutils/rpi-firmware port now includes overlays, so they
  can be installed as a part of release image build.
  
  [1] https://github.com/raspberrypi/firmware/tree/master/boot
  [2] https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README
  
  No objections from:   phk@

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_pwm.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_pwm.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_pwm.c Tue Apr 10 20:22:36 2018
(r332391)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_pwm.c Tue Apr 10 20:31:25 2018
(r332392)
@@ -276,12 +276,8 @@ static int
 bcm_pwm_probe(device_t dev)
 {
 
-#if 0
-   // XXX: default state is disabled in RPI3 DTB, assume for now
-   // XXX: that people want the PWM to work if the KLD this module.
if (!ofw_bus_status_okay(dev))
return (ENXIO);
-#endif
 
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332342 - head/share/man/man9

2018-04-09 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Apr  9 22:23:45 2018
New Revision: 332342
URL: https://svnweb.freebsd.org/changeset/base/332342

Log:
  [man] Add documentation for OpenFirmware API
  
  Add man pages for following OpenFirmware functions:
  
  OF_child, OF_parent, OF_peer, OF_device_from_xref,
  OF_device_register_xref, OF_xref_from_device, OF_getprop,
  OF_getencprop, OF_getencprop_alloc, OF_getprop_alloc, OF_getproplen,
  OF_hasprop, OF_nextprop, OF_prop_free, OF_searchencprop,
  OF_searchprop, OF_setprop
  
  Edited by:wblock
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D14511

Added:
  head/share/man/man9/OF_child.9   (contents, props changed)
  head/share/man/man9/OF_device_from_xref.9   (contents, props changed)
  head/share/man/man9/OF_finddevice.9   (contents, props changed)
  head/share/man/man9/OF_getprop.9   (contents, props changed)
  head/share/man/man9/OF_node_from_xref.9   (contents, props changed)
  head/share/man/man9/OF_package_to_path.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileMon Apr  9 22:06:16 2018
(r332341)
+++ head/share/man/man9/MakefileMon Apr  9 22:23:45 2018
(r332342)
@@ -208,6 +208,12 @@ MAN=   accept_filter.9 \
namei.9 \
netisr.9 \
nv.9 \
+   OF_child.9 \
+   OF_device_from_xref.9 \
+   OF_finddevice.9 \
+   OF_getprop.9 \
+   OF_node_from_xref.9 \
+   OF_package_to_path.9 \
ofw_bus_is_compatible.9 \
ofw_bus_status_okay.9 \
osd.9 \
@@ -1527,6 +1533,21 @@ MLINKS+=nv.9 libnv.9 \
nv.9 nvlist_take_string_array.9 \
nv.9 nvlist_unpack.9 \
nv.9 nvlist_xfer.9
+MLINKS+=OF_child.9 OF_parent.9 \
+   OF_child.9 OF_peer.9
+MLINKS+=OF_device_from_xref.9 OF_device_register_xref.9 \
+   OF_device_from_xref.9 OF_xref_from_device.9
+MLINKS+=OF_getprop.9 OF_getencprop.9 \
+   OF_getprop.9 OF_getencprop_alloc.9 \
+   OF_getprop.9 OF_getprop_alloc.9 \
+   OF_getprop.9 OF_getproplen.9 \
+   OF_getprop.9 OF_hasprop.9 \
+   OF_getprop.9 OF_nextprop.9 \
+   OF_getprop.9 OF_prop_free.9 \
+   OF_getprop.9 OF_searchencprop.9 \
+   OF_getprop.9 OF_searchprop.9 \
+   OF_getprop.9 OF_setprop.9
+MLINKS+=OF_node_from_xref.9 OF_xref_from_node.9
 MLINKS+=ofw_bus_is_compatible.9 ofw_bus_is_compatible_strict.9 \
ofw_bus_is_compatible.9 ofw_bus_node_is_compatible.9 \
ofw_bus_is_compatible.9 ofw_bus_search_compatible.9

Added: head/share/man/man9/OF_child.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/OF_child.9  Mon Apr  9 22:23:45 2018
(r332342)
@@ -0,0 +1,76 @@
+.\"
+.\" Copyright (c) 2018 Oleksandr Tymoshenko 
+.\"
+.\" 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 DEVELOPERS ``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 DEVELOPERS 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd April 9, 2018
+.Dt OF_CHILD 9
+.Os
+.Sh NAME
+.Nm OF_child ,
+.Nm OF_parent ,
+.Nm OF_peer
+.Nd navigate device tree
+.Sh SYNOPSIS
+.In dev/ofw/ofw_bus.h
+.In dev/ofw/ofw_bus_subr.h
+.Ft phandle_t
+.Fn OF_child "phandle_t node"
+.Ft phandle_t
+.Fn OF_parent "phandle_t node"
+.Ft phandle_t
+.Fn OF_peer "phandle_t node"
+.Sh DESCRIPTION
+.Pp
+.Fn OF_child
+returns the phandle value of the first child of the
+.Fa node .
+Zero is returned if there are no child nodes.
+

svn commit: r332341 - in head/sys: arm/amlogic/aml8726 arm/annapurna/alpine arm/at91 arm/broadcom/bcm2835 arm/freescale/imx arm/nvidia/drm2 arm/ti dev/cpufreq dev/dpaa dev/extres/clk dev/extres/phy...

2018-04-09 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Apr  9 22:06:16 2018
New Revision: 332341
URL: https://svnweb.freebsd.org/changeset/base/332341

Log:
  Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc
  
  Change OF_getencprop_alloc semantics to be combination of malloc and
  OF_getencprop and return size of the property, not number of elements
  allocated.
  
  For the use cases where number of elements is preferred introduce
  OF_getencprop_alloc_multi helper function that copies semantics
  of OF_getencprop_alloc prior to this change.
  
  This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
  function signatures consistent with OF_getencprop_alloc and
  OF_getencprop_alloc_multi.
  
  Functionality-wise this patch is mostly rename of OF_getencprop_alloc
  to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
  where 1 was used as a block size.

Modified:
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
  head/sys/arm/annapurna/alpine/alpine_pci_msix.c
  head/sys/arm/at91/at91_pinctrl.c
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  head/sys/arm/freescale/imx/imx_iomux.c
  head/sys/arm/nvidia/drm2/tegra_drm_subr.c
  head/sys/arm/ti/ti_adc.c
  head/sys/arm/ti/ti_pinmux.c
  head/sys/dev/cpufreq/cpufreq_dt.c
  head/sys/dev/dpaa/qman_fdt.c
  head/sys/dev/extres/clk/clk.c
  head/sys/dev/extres/phy/phy.c
  head/sys/dev/extres/regulator/regulator.c
  head/sys/dev/extres/syscon/syscon.c
  head/sys/dev/fdt/fdt_clock.c
  head/sys/dev/fdt/fdt_pinctrl.c
  head/sys/dev/gpio/gpioregulator.c
  head/sys/dev/gpio/ofw_gpiobus.c
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/openfirm.c
  head/sys/dev/ofw/openfirm.h
  head/sys/dev/vnic/thunder_bgx_fdt.c
  head/sys/mips/ingenic/jz4780_pinctrl.c
  head/sys/mips/mediatek/fdt_reset.c
  head/sys/powerpc/mpc85xx/lbc.c

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Mon Apr  9 21:46:58 
2018(r332340)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Mon Apr  9 22:06:16 
2018(r332341)
@@ -195,7 +195,7 @@ aml8726_usb_phy_attach(device_t dev)
 
err = 0;
 
-   len = OF_getencprop_alloc(node, "usb-pwr-en",
+   len = OF_getencprop_alloc_multi(node, "usb-pwr-en",
3 * sizeof(pcell_t), (void **)&prop);
npwr_en = (len > 0) ? len : 0;
 

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c   Mon Apr  9 21:46:58 
2018(r332340)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c   Mon Apr  9 22:06:16 
2018(r332341)
@@ -167,7 +167,7 @@ aml8726_usb_phy_attach(device_t dev)
 
err = 0;
 
-   len = OF_getencprop_alloc(node, "usb-pwr-en",
+   len = OF_getencprop_alloc_multi(node, "usb-pwr-en",
3 * sizeof(pcell_t), (void **)&prop);
npwr_en = (len > 0) ? len : 0;
 
@@ -188,7 +188,7 @@ aml8726_usb_phy_attach(device_t dev)
 
OF_prop_free(prop);
 
-   len = OF_getencprop_alloc(node, "usb-hub-rst",
+   len = OF_getencprop_alloc_multi(node, "usb-hub-rst",
3 * sizeof(pcell_t), (void **)&prop);
if (len > 0) {
sc->hub_rst.dev = OF_device_from_xref(prop[0]);

Modified: head/sys/arm/annapurna/alpine/alpine_pci_msix.c
==
--- head/sys/arm/annapurna/alpine/alpine_pci_msix.c Mon Apr  9 21:46:58 
2018(r332340)
+++ head/sys/arm/annapurna/alpine/alpine_pci_msix.c Mon Apr  9 22:06:16 
2018(r332341)
@@ -188,7 +188,7 @@ al_msix_attach(device_t dev)
sc->gic_dev = gic_dev;
 
/* Manually read range of interrupts from DTB */
-   nintr = OF_getencprop_alloc(node, "interrupts",  sizeof(*intr),
+   nintr = OF_getencprop_alloc_multi(node, "interrupts", sizeof(*intr),
(void **)&intr);
if (nintr == 0) {
device_printf(dev, "Cannot read interrupts prop from DTB\n");

Modified: head/sys/arm/at91/at91_pinctrl.c
==
--- head/sys/arm/at91/at91_pinctrl.cMon Apr  9 21:46:58 2018
(r332340)
+++ head/sys/arm/at91/at91_pinctrl.cMon Apr  9 22:06:16 2018
(r332341)
@@ -101,7 +101,8 @@ at91_pinctrl_setup_dinfo(device_t dev, phandle_t node)
}
 
resource_list_init(&ndi->rl);
-   nreg = OF_getencprop_alloc(node, "reg", sizeof(*reg), (void **)®);
+   nreg = OF_getencprop_alloc_multi(node, "reg", sizeof(*reg),
+   (void **)®);
if (nreg == -1)
nreg = 0;
if (nreg % (sc->acells + sc->scells) != 0) {
@@ -127,7 +128,7 @@ at91_pinctrl_setup_dinfo(device_t dev, phandle_t node)
}
OF_prop_free(reg

svn commit: r332317 - head/share/man/man9

2018-04-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Apr  9 05:48:12 2018
New Revision: 332317
URL: https://svnweb.freebsd.org/changeset/base/332317

Log:
  [man] Fix return type of BUS_ADD_CHILD(9)
  
  Fix return type of BUS_ADD_CHILD(9) in SYNOPSYS section,
  it should be device_t, not int
  
  PR:   207389
  MFC after:3 days

Modified:
  head/share/man/man9/BUS_ADD_CHILD.9

Modified: head/share/man/man9/BUS_ADD_CHILD.9
==
--- head/share/man/man9/BUS_ADD_CHILD.9 Mon Apr  9 05:43:30 2018
(r332316)
+++ head/share/man/man9/BUS_ADD_CHILD.9 Mon Apr  9 05:48:12 2018
(r332317)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 28, 2015
+.Dd April 8, 2018
 .Dt BUS_ADD_CHILD 9
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Sh SYNOPSIS
 .In sys/param.h
 .In sys/bus.h
-.Ft int
+.Ft device_t
 .Fn BUS_ADD_CHILD "device_t dev" "int order" "const char *name" "int unit"
 .Sh DESCRIPTION
 The
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332312 - head/sys/dev/ofw

2018-04-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Apr  9 00:38:24 2018
New Revision: 332312
URL: https://svnweb.freebsd.org/changeset/base/332312

Log:
  Make OF_searchencprop signature consistent with OF_getencprop
  
  Use pcell_t* as a destination buffer argument instead of void
  pointer to be consistent with OF_getencprop signature.

Modified:
  head/sys/dev/ofw/openfirm.c
  head/sys/dev/ofw/openfirm.h

Modified: head/sys/dev/ofw/openfirm.c
==
--- head/sys/dev/ofw/openfirm.c Sun Apr  8 23:17:51 2018(r332311)
+++ head/sys/dev/ofw/openfirm.c Mon Apr  9 00:38:24 2018(r332312)
@@ -428,7 +428,7 @@ OF_searchprop(phandle_t node, const char *propname, vo
 }
 
 ssize_t
-OF_searchencprop(phandle_t node, const char *propname, void *buf, size_t len)
+OF_searchencprop(phandle_t node, const char *propname, pcell_t *buf, size_t 
len)
 {
ssize_t rv;
 

Modified: head/sys/dev/ofw/openfirm.h
==
--- head/sys/dev/ofw/openfirm.h Sun Apr  8 23:17:51 2018(r332311)
+++ head/sys/dev/ofw/openfirm.h Mon Apr  9 00:38:24 2018(r332312)
@@ -114,7 +114,7 @@ int OF_hasprop(phandle_t node, const char 
*propname);
 ssize_tOF_searchprop(phandle_t node, const char *propname, 
void *buf,
size_t len);
 ssize_tOF_searchencprop(phandle_t node, const char *propname,
-   void *buf, size_t len);
+   pcell_t *buf, size_t len);
 ssize_tOF_getprop_alloc(phandle_t node, const char *propname,
void **buf);
 ssize_tOF_getprop_alloc_multi(phandle_t node, const char 
*propname,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332311 - head/sys/arm64/coresight

2018-04-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Apr  8 23:17:51 2018
New Revision: 332311
URL: https://svnweb.freebsd.org/changeset/base/332311

Log:
  Fix one more OF_getprop_alloc instance missed in r332310
  
  X-MFC-With:   r332310

Modified:
  head/sys/arm64/coresight/coresight.c

Modified: head/sys/arm64/coresight/coresight.c
==
--- head/sys/arm64/coresight/coresight.cSun Apr  8 22:59:34 2018
(r332310)
+++ head/sys/arm64/coresight/coresight.cSun Apr  8 23:17:51 2018
(r332311)
@@ -68,7 +68,7 @@ coresight_get_ports(phandle_t dev_node,
node = dev_node;
 
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
-   ret = OF_getprop_alloc(child, "name", sizeof(*name), (void 
**)&name);
+   ret = OF_getprop_alloc(child, "name", (void **)&name);
if (ret == -1)
continue;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332310 - in head/sys: arm/allwinner arm/amlogic/aml8726 arm/broadcom/bcm2835 arm/freescale/vybrid arm/mv arm/nvidia arm/nvidia/tegra124 arm/ti arm/ti/cpsw arm/ti/usb dev/altera/avgen d...

2018-04-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Apr  8 22:59:34 2018
New Revision: 332310
URL: https://svnweb.freebsd.org/changeset/base/332310

Log:
  Clean up OF_getprop_alloc API
  
  OF_getprop_alloc takes element size argument and returns number of
  elements in the property. There are valid use cases for such behavior
  but mostly API consumers pass 1 as element size to get string
  properties. What API users would expect from OF_getprop_alloc is to be
  a combination of malloc + OF_getprop with the same semantic of return
  value. This patch modifies API signature to match these expectations.
  
  For the valid use cases with element size != 1 and to reduce
  modification scope new OF_getprop_alloc_multi function has been
  introduced that behaves the same way OF_getprop_alloc behaved prior to
  this patch.
  
  Reviewed by:  ian, manu
  Differential Revision:https://reviews.freebsd.org/D14850

Modified:
  head/sys/arm/allwinner/aw_gpio.c
  head/sys/arm/allwinner/aw_if_dwc.c
  head/sys/arm/allwinner/if_awg.c
  head/sys/arm/amlogic/aml8726/aml8726_ccm.c
  head/sys/arm/amlogic/aml8726/aml8726_mmc.c
  head/sys/arm/amlogic/aml8726/aml8726_pinctrl.c
  head/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  head/sys/arm/freescale/vybrid/vf_ccm.c
  head/sys/arm/mv/mv_localbus.c
  head/sys/arm/nvidia/as3722_gpio.c
  head/sys/arm/nvidia/as3722_regulators.c
  head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c
  head/sys/arm/nvidia/tegra_pinmux.c
  head/sys/arm/nvidia/tegra_usbphy.c
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/ti_hwmods.c
  head/sys/arm/ti/usb/omap_host.c
  head/sys/dev/altera/avgen/altera_avgen_fdt.c
  head/sys/dev/atkbdc/atkbdc_ebus.c
  head/sys/dev/etherswitch/e6000sw/e6000sw.c
  head/sys/dev/extres/regulator/regulator.c
  head/sys/dev/fdt/fdt_pinctrl.c
  head/sys/dev/fdt/fdt_slicer.c
  head/sys/dev/gpio/gpiokeys.c
  head/sys/dev/gpio/gpioled_fdt.c
  head/sys/dev/iicbus/adt746x.c
  head/sys/dev/le/lebuffer_sbus.c
  head/sys/dev/neta/if_mvneta_fdt.c
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/openfirm.c
  head/sys/dev/ofw/openfirm.h
  head/sys/dev/usb/controller/ehci_fsl.c
  head/sys/dev/vnic/thunder_bgx_fdt.c
  head/sys/mips/mediatek/mtk_pinctrl.c
  head/sys/powerpc/mpc85xx/fsl_diu.c
  head/sys/powerpc/powermac/macio.c
  head/sys/powerpc/powermac/uninorth.c
  head/sys/powerpc/psim/iobus.c
  head/sys/sparc64/central/central.c
  head/sys/sparc64/ebus/ebus.c
  head/sys/sparc64/fhc/fhc.c
  head/sys/sparc64/isa/isa.c
  head/sys/sparc64/pci/ofw_pci.c
  head/sys/sparc64/sbus/dma_sbus.c
  head/sys/sparc64/sbus/sbus.c
  head/sys/sparc64/sparc64/nexus.c
  head/sys/sparc64/sparc64/upa.c

Modified: head/sys/arm/allwinner/aw_gpio.c
==
--- head/sys/arm/allwinner/aw_gpio.cSun Apr  8 22:07:06 2018
(r332309)
+++ head/sys/arm/allwinner/aw_gpio.cSun Apr  8 22:59:34 2018
(r332310)
@@ -559,10 +559,10 @@ aw_gpio_parse_function(phandle_t node)
 {
char *function;
 
-   if (OF_getprop_alloc(node, "function", sizeof(*function),
+   if (OF_getprop_alloc(node, "function",
(void **)&function) != -1)
return (function);
-   if (OF_getprop_alloc(node, "allwinner,function", sizeof(*function),
+   if (OF_getprop_alloc(node, "allwinner,function",
(void **)&function) != -1)
return (function);
 

Modified: head/sys/arm/allwinner/aw_if_dwc.c
==
--- head/sys/arm/allwinner/aw_if_dwc.c  Sun Apr  8 22:07:06 2018
(r332309)
+++ head/sys/arm/allwinner/aw_if_dwc.c  Sun Apr  8 22:59:34 2018
(r332310)
@@ -72,7 +72,7 @@ a20_if_dwc_init(device_t dev)
node = ofw_bus_get_node(dev);
 
/* Configure PHY for MII or RGMII mode */
-   if (OF_getprop_alloc(node, "phy-mode", 1, (void **)&phy_type)) {
+   if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type)) {
error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", 
&clk_tx);
if (error != 0) {
device_printf(dev, "could not get tx clk\n");

Modified: head/sys/arm/allwinner/if_awg.c
==
--- head/sys/arm/allwinner/if_awg.c Sun Apr  8 22:07:06 2018
(r332309)
+++ head/sys/arm/allwinner/if_awg.c Sun Apr  8 22:59:34 2018
(r332310)
@@ -1233,7 +1233,7 @@ awg_setup_phy(device_t dev)
node = ofw_bus_get_node(dev);
use_syscon = false;
 
-   if (OF_getprop_alloc(node, "phy-mode", 1, (void **)&phy_type) == 0)
+   if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type) == 0)
return (0);
 
if (sc->syscon != NULL || sc->res[_RES_SYSCON] != NULL)

Modified: head/sys/arm/amlogic/a

svn commit: r332305 - head/share/man/man9

2018-04-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Apr  8 20:53:00 2018
New Revision: 332305
URL: https://svnweb.freebsd.org/changeset/base/332305

Log:
  Document ofw_bus_subr helpers "compatible" and "status" properties
  
  Add documentation for following functions:
  
  - ofw_bus_is_compatible
  - ofw_bus_is_compatible_strict
  - ofw_bus_node_is_compatible
  - ofw_bus_search_compatible
  - ofw_bus_get_status
  - ofw_bus_status_okay
  - ofw_bus_node_status_okay
  
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D14724

Added:
  head/share/man/man9/ofw_bus_is_compatible.9   (contents, props changed)
  head/share/man/man9/ofw_bus_status_okay.9   (contents, props changed)
Modified:
  head/share/man/man9/Makefile

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileSun Apr  8 20:52:09 2018
(r332304)
+++ head/share/man/man9/MakefileSun Apr  8 20:53:00 2018
(r332305)
@@ -208,6 +208,8 @@ MAN=accept_filter.9 \
namei.9 \
netisr.9 \
nv.9 \
+   ofw_bus_is_compatible.9 \
+   ofw_bus_status_okay.9 \
osd.9 \
owll.9 \
own.9 \
@@ -1525,6 +1527,11 @@ MLINKS+=nv.9 libnv.9 \
nv.9 nvlist_take_string_array.9 \
nv.9 nvlist_unpack.9 \
nv.9 nvlist_xfer.9
+MLINKS+=ofw_bus_is_compatible.9 ofw_bus_is_compatible_strict.9 \
+   ofw_bus_is_compatible.9 ofw_bus_node_is_compatible.9 \
+   ofw_bus_is_compatible.9 ofw_bus_search_compatible.9
+MLINKS+= ofw_bus_status_okay.9 ofw_bus_get_status.9 \
+   ofw_bus_status_okay.9 ofw_bus_node_status_okay.9
 MLINKS+=osd.9 osd_call.9 \
osd.9 osd_del.9 \
osd.9 osd_deregister.9 \

Added: head/share/man/man9/ofw_bus_is_compatible.9
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man9/ofw_bus_is_compatible.9 Sun Apr  8 20:53:00 2018
(r332305)
@@ -0,0 +1,147 @@
+.\" -*- nroff -*-
+.\"
+.\" Copyright (c) 2018 Oleksandr Tymoshenko
+.\"
+.\" All rights reserved.
+.\"
+.\" This program is free software.
+.\"
+.\" 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 DEVELOPERS ``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 DEVELOPERS 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd April 8, 2018
+.Dt ofw_bus_is_compatible 9
+.Os
+.Sh NAME
+.Nm ofw_bus_is_compatible
+.Nm ofw_bus_is_compatible_strict
+.Nm ofw_bus_node_is_compatible
+.Nm ofw_bus_search_compatible
+.Nd check device tree nodes for compatibility with drivers
+.Sh SYNOPSIS
+.In dev/ofw/openfirm.h
+.In dev/ofw/ofw_bus.h
+.In dev/ofw/ofw_bus_subr.h
+.Ft int
+.Fn ofw_bus_is_compatible "device_t dev" "const char *compatstr"
+.Ft int
+.Fn ofw_bus_is_compatible_strict "device_t dev" "const char *compatstr"
+.Ft int
+.Fn ofw_bus_node_is_compatible "phandle_t node" "const char *compatstr"
+.Ft const struct ofw_compat_data *
+.Fn ofw_bus_search_compatible "device_t dev" "const struct ofw_compat_data 
*compat"
+.Sh DESCRIPTION
+.Pp
+The "compatible" property of the device tree node is used to
+identify the type of the device the node represents.
+The property is a list of one or more strings that represent
+hardware types the device is compatible with.
+The common format for such strings is "vendor,hardware"
+where "vendor" is an abbreviated name of the manufacturer
+and "hardware" is a device identifier, for instance, "fsl"
+for "Freescale" 

svn commit: r332262 - in head/sys: arm/broadcom/bcm2835 arm/conf dts/arm

2018-04-07 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Apr  8 00:56:19 2018
New Revision: 332262
URL: https://svnweb.freebsd.org/changeset/base/332262

Log:
  [rpi] Add fdt_pinctrl(4) support to Raspberry Pi GPIO driver
  
  On Raspberry Pi platform GPIO controller also responsible for pins
  multiplexing. Pi code predates proper FDT support in FreeBSD so a
  lot of pinmux info is hardcoded. This patch:
  
  - Implements pinctl methods in bcm2835_gpio
  - Converts all devices with ad-hoc pinmux info to proper pin control
mechanisms and adds pinmux info in FreeBSD's custom dts files.
  - Adds fdt_pinctrl option to RPI2 and RPI-B kernels
  - Adds SPI pinmux config to FreeBSD's customization of GNU DTS.
  
  Reviewed by:  imp, manu
  Differential Revision:https://reviews.freebsd.org/D14104

Deleted:
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.h
Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
  head/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  head/sys/arm/broadcom/bcm2835/bcm2835_intr.c
  head/sys/arm/broadcom/bcm2835/bcm2835_pwm.c
  head/sys/arm/broadcom/bcm2835/bcm2835_spi.c
  head/sys/arm/broadcom/bcm2835/bcm2835_spivar.h
  head/sys/arm/broadcom/bcm2835/bcm2836.c
  head/sys/arm/conf/RPI-B
  head/sys/arm/conf/RPI2
  head/sys/dts/arm/rpi.dts
  head/sys/dts/arm/rpi2.dts

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sat Apr  7 23:31:55 2018
(r332261)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sun Apr  8 00:56:19 2018
(r332262)
@@ -100,7 +100,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
@@ -298,9 +297,7 @@ static int
 bcm_bsc_attach(device_t dev)
 {
struct bcm_bsc_softc *sc;
-   unsigned long start;
-   device_t gpio;
-   int i, rid;
+   int rid;
 
sc = device_get_softc(dev);
sc->sc_dev = dev;
@@ -315,31 +312,6 @@ bcm_bsc_attach(device_t dev)
 
sc->sc_bst = rman_get_bustag(sc->sc_mem_res);
sc->sc_bsh = rman_get_bushandle(sc->sc_mem_res);
-
-   /* Check the unit we are attaching by its base address. */
-   start = rman_get_start(sc->sc_mem_res);
-   for (i = 0; i < nitems(bcm_bsc_pins); i++) {
-   if (bcm_bsc_pins[i].start == (start & BCM_BSC_BASE_MASK))
-   break;
-   }
-   if (i == nitems(bcm_bsc_pins)) {
-   device_printf(dev, "only bsc0 and bsc1 are supported\n");
-   bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
-   return (ENXIO);
-   }
-
-   /*
-* Configure the GPIO pins to ALT0 function to enable BSC control
-* over the pins.
-*/
-   gpio = devclass_get_device(devclass_find("gpio"), 0);
-   if (!gpio) {
-   device_printf(dev, "cannot find gpio0\n");
-   bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
-   return (ENXIO);
-   }
-   bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].sda, BCM_GPIO_ALT0);
-   bcm_gpio_set_alternate(gpio, bcm_bsc_pins[i].scl, BCM_GPIO_ALT0);
 
rid = 0;
sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h  Sat Apr  7 23:31:55 
2018(r332261)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_bscvar.h  Sun Apr  8 00:56:19 
2018(r332262)
@@ -32,16 +32,6 @@
 #ifndef _BCM2835_BSCVAR_H
 #define _BCM2835_BSCVAR_H
 
-struct {
-   uint32_tsda;
-   uint32_tscl;
-   unsigned long   start;
-} bcm_bsc_pins[] = {
-   { 0, 1, 0x205000 }, /* BSC0 GPIO pins and base address. */
-   { 2, 3, 0x804000 }  /* BSC1 GPIO pins and base address. */
-};
-#defineBCM_BSC_BASE_MASK   0x00ff
-
 struct iic_msg;
 
 struct bcm_bsc_softc {

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_gpio.cSat Apr  7 23:31:55 
2018(r332261)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_gpio.cSun Apr  8 00:56:19 
2018(r332262)
@@ -48,11 +48,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
-#include 
-
 #include "gpio_if.h"
 
 #include "pic_if.h"
@@ -73,6 +72,19 @@ __FBSDID("$FreeBSD$");
 GPIO_INTR_LEVEL_HIGH | GPIO_INTR_EDGE_RISING | \
 GPIO_INTR_EDGE_FALLING | GPIO_INTR_EDGE_BOTH)
 
+#defineBCM2835_FSEL_GPIO_IN0
+#defineBCM2835_FSEL_GPIO_OUT   1
+#defineBCM2835_FSEL_ALT5   2
+#defineBCM2835_FSEL_ALT4   3
+#defineBCM2835_FSEL_ALT0   4
+#defineBCM2835_FSEL_ALT1   5
+#define  

svn commit: r331967 - head/sys/arm64/arm64

2018-04-03 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Apr  4 01:13:28 2018
New Revision: 331967
URL: https://svnweb.freebsd.org/changeset/base/331967

Log:
  Fix arm64 buildkernel target with "nooptions KDB"
  
  Make kdb_trap in breakpoint exception handler conditional. If "options KDB"
  is not present just panic with message that debugger is not enabled.
  
  PR:   224653

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Tue Apr  3 23:49:35 2018(r331966)
+++ head/sys/arm64/arm64/trap.c Wed Apr  4 01:13:28 2018(r331967)
@@ -323,8 +323,12 @@ do_el1h_sync(struct thread *td, struct trapframe *fram
break;
}
 #endif
+#ifdef KDB
kdb_trap(exception, 0,
(td->td_frame != NULL) ? td->td_frame : frame);
+#else
+   panic("No debugger in kernel.\n");
+#endif
frame->tf_elr += 4;
break;
case EXCP_WATCHPT_EL1:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331906 - head/sys/arm/xilinx

2018-04-02 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Apr  3 04:31:54 2018
New Revision: 331906
URL: https://svnweb.freebsd.org/changeset/base/331906

Log:
  Fix accidental USB port resets by GPIO on Zynq/Zedboard boards
  
  The Zynq/Zedboard GPIO driver attempts to tri-state all GPIO pins on
  boot up but the order in which I reset the hardware can cause the pins
  to be briefly held low before being tri-stated.  This is a problem on
  boards that use GPIO pins to reset devices.
  
  In particular, the Zybo and ZC-706 boards use a GPIO pin as a USB PHY
  reset.  If U-boot enables the USB port before booting the kernel, the
  GPIO driver attach causes a glitch on the USB PHY reset and the USB
  port loses power.  My fix is to have the GPIO driver leave the pins in
  whatever configuration U-boot placed them.
  
  PR:   225713
  Submitted by: Thomas Skibo 
  MFC after:1 week

Modified:
  head/sys/arm/xilinx/zy7_gpio.c

Modified: head/sys/arm/xilinx/zy7_gpio.c
==
--- head/sys/arm/xilinx/zy7_gpio.c  Tue Apr  3 03:41:55 2018
(r331905)
+++ head/sys/arm/xilinx/zy7_gpio.c  Tue Apr  3 04:31:54 2018
(r331906)
@@ -298,24 +298,6 @@ zy7_gpio_probe(device_t dev)
return (0);
 }
 
-static void
-zy7_gpio_hw_reset(struct zy7_gpio_softc *sc)
-{
-   int i;
-
-   for (i = 0; i < NUMBANKS; i++) {
-   WR4(sc, ZY7_GPIO_DATA(i), 0);
-   WR4(sc, ZY7_GPIO_DIRM(i), 0);
-   WR4(sc, ZY7_GPIO_OEN(i), 0);
-   WR4(sc, ZY7_GPIO_INT_DIS(i), 0x);
-   WR4(sc, ZY7_GPIO_INT_POLARITY(i), 0);
-   WR4(sc, ZY7_GPIO_INT_TYPE(i),
-   i == 1 ? 0x003f : 0x);
-   WR4(sc, ZY7_GPIO_INT_ANY(i), 0);
-   WR4(sc, ZY7_GPIO_INT_STAT(i), 0x);
-   }
-}
-
 static int zy7_gpio_detach(device_t dev);
 
 static int
@@ -337,9 +319,6 @@ zy7_gpio_attach(device_t dev)
zy7_gpio_detach(dev);
return (ENOMEM);
}
-
-   /* Completely reset. */
-   zy7_gpio_hw_reset(sc);
 
sc->busdev = gpiobus_attach_bus(dev);
if (sc->busdev == NULL) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r331229 - in head/sys: arm/amlogic/aml8726 arm/annapurna/alpine arm/broadcom/bcm2835 arm/freescale arm/freescale/vybrid arm/mv arm/samsung/exynos arm/ti/am335x dev/fdt dev/ofw dev/ow de...

2018-03-19 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar 20 00:03:49 2018
New Revision: 331229
URL: https://svnweb.freebsd.org/changeset/base/331229

Log:
  [ofw] fix errneous checks for OF_finddevice(9) return value
  
  OF_finddevices returns ((phandle_t)-1) in case of failure. Some code
  in existing drivers checked return value to be equal to 0 or
  less/equal to 0 which is also wrong because phandle_t is unsigned
  type. Most of these checks were for negative cases that were never
  triggered so trhere was no impact on functionality.
  
  Reviewed by:  nwhitehorn
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D14645

Modified:
  head/sys/arm/amlogic/aml8726/aml8726_clkmsr.c
  head/sys/arm/amlogic/aml8726/aml8726_mp.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
  head/sys/arm/annapurna/alpine/alpine_machdep.c
  head/sys/arm/broadcom/bcm2835/bcm2835_fb.c
  head/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
  head/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
  head/sys/arm/freescale/fsl_ocotp.c
  head/sys/arm/freescale/vybrid/vf_machdep.c
  head/sys/arm/mv/mv_common.c
  head/sys/arm/samsung/exynos/chrome_ec.c
  head/sys/arm/samsung/exynos/exynos5_ehci.c
  head/sys/arm/ti/am335x/am335x_lcd.c
  head/sys/arm/ti/am335x/am335x_lcd_syscons.c
  head/sys/dev/fdt/fdt_common.c
  head/sys/dev/ofw/ofw_subr.c
  head/sys/dev/ofw/openfirmio.c
  head/sys/dev/ow/owc_gpiobus.c
  head/sys/dev/vnic/thunder_bgx_fdt.c
  head/sys/powerpc/cpufreq/mpc85xx_jog.c
  head/sys/powerpc/pseries/platform_chrp.c

Modified: head/sys/arm/amlogic/aml8726/aml8726_clkmsr.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_clkmsr.c   Mon Mar 19 23:21:45 
2018(r331228)
+++ head/sys/arm/amlogic/aml8726/aml8726_clkmsr.c   Tue Mar 20 00:03:49 
2018(r331229)
@@ -255,14 +255,14 @@ aml8726_clkmsr_bus_frequency()
 * Try to access the clkmsr node directly i.e. through /aliases/.
 */
 
-   if ((node = OF_finddevice("clkmsr")) != 0)
+   if ((node = OF_finddevice("clkmsr")) != -1)
if (fdt_is_compatible_strict(node, "amlogic,aml8726-clkmsr"))
 goto moveon;
 
/*
 * Find the node the long way.
 */
-   if ((node = OF_finddevice("/soc")) == 0)
+   if ((node = OF_finddevice("/soc")) == -1)
return (0);
 
if ((node = fdt_find_compatible(node,

Modified: head/sys/arm/amlogic/aml8726/aml8726_mp.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_mp.c   Mon Mar 19 23:21:45 2018
(r331228)
+++ head/sys/arm/amlogic/aml8726/aml8726_mp.c   Tue Mar 20 00:03:49 2018
(r331229)
@@ -178,7 +178,7 @@ find_node_for_device(const char *device, const char **
 * Try to access the node directly i.e. through /aliases/.
 */
 
-   if ((node = OF_finddevice(device)) != 0)
+   if ((node = OF_finddevice(device)) != -1)
for (i = 0; compatible[i]; i++)
if (fdt_is_compatible_strict(node, compatible[i]))
return node;
@@ -188,7 +188,7 @@ find_node_for_device(const char *device, const char **
 */
 
for (i = 0; compatible[i]; i++) {
-   if ((node = OF_finddevice("/soc")) == 0)
+   if ((node = OF_finddevice("/soc")) == -1)
return (0);
 
if ((node = fdt_find_compatible(node, compatible[i], 1)) != 0)

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
==
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Mon Mar 19 23:21:45 
2018(r331228)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Tue Mar 20 00:03:49 
2018(r331229)
@@ -117,7 +117,7 @@ aml8726_usb_phy_mode(const char *dwcotg_path, uint32_t
phandle_t node;
ssize_t len;

-   if ((node = OF_finddevice(dwcotg_path)) == 0)
+   if ((node = OF_finddevice(dwcotg_path)) == -1)
return (ENXIO);
 
if (fdt_is_compatible_strict(node, "synopsys,designware-hs-otg2") == 0)

Modified: head/sys/arm/annapurna/alpine/alpine_machdep.c
==
--- head/sys/arm/annapurna/alpine/alpine_machdep.c  Mon Mar 19 23:21:45 
2018(r331228)
+++ head/sys/arm/annapurna/alpine/alpine_machdep.c  Tue Mar 20 00:03:49 
2018(r331229)
@@ -71,7 +71,7 @@ alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *siz
 {
phandle_t node;
 
-   if ((node = OF_finddevice("/")) == 0)
+   if ((node = OF_finddevice("/")) == -1)
return (ENXIO);
 
if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c
===

svn commit: r330727 - in head/sys: arm/broadcom/bcm2835 dts/arm

2018-03-09 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Mar 10 02:49:58 2018
New Revision: 330727
URL: https://svnweb.freebsd.org/changeset/base/330727

Log:
  [rpi] remove IRQ support for BCM233x RNG
  
  Upstream DTBs don't provide IRQ lines for the RNG. Moreover, harvesting
  bytes as often as the RNG interrupt is triggered (87 times per sec) is an
  overkill.
  
  For these reasons, get rid of the interrupt mode and make callout mode the
  default, with random bits harvested every 4 seconds.
  
  Submitted by: Sylvain Garrigues 
  Reviewed by:  ian, imp, manu, mmel
  Approved by:  emaste
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D14541

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_rng.c
  head/sys/dts/arm/rpi.dts
  head/sys/dts/arm/rpi2.dts

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_rng.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_rng.c Sat Mar 10 02:15:45 2018
(r330726)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_rng.c Sat Mar 10 02:49:58 2018
(r330727)
@@ -51,10 +51,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#if !defined(BCM2835_RNG_USE_CALLOUT)
-#defineBCM2835_RNG_USE_INTERRUPT
-#endif
-
 static device_attach_t bcm2835_rng_attach;
 static device_detach_t bcm2835_rng_detach;
 static device_probe_t bcm2835_rng_probe;
@@ -92,18 +88,15 @@ static device_probe_t bcm2835_rng_probe;
 #defineRNG_NUM_OSCILLATORS 6
 #defineRNG_STALL_COUNT_DEFAULT 10
 
+#defineRNG_CALLOUT_TICKS   (hz * 4)
+
 struct bcm2835_rng_softc {
device_tsc_dev;
struct resource *   sc_mem_res;
struct resource *   sc_irq_res;
void *  sc_intr_hdl;
-#if defined(BCM2835_RNG_USE_CALLOUT) || defined(BCM2835_RNG_USE_INTERRUPT)
uint32_tsc_buf[RNG_FIFO_WORDS];
-#endif
-#if defined(BCM2835_RNG_USE_CALLOUT)
struct callout  sc_rngto;
-   int sc_rnghz;
-#endif
int sc_stall_count;
int sc_rbg2x;
longsc_underrun;
@@ -214,20 +207,7 @@ bcm2835_rng_disable_intr(struct bcm2835_rng_softc *sc)
 bcm2835_rng_write4(sc, RNG_INT_MASK, mask);
 }
 
-#if defined(BCM2835_RNG_USE_INTERRUPT)
 static void
-bcm2835_rng_enable_intr(struct bcm2835_rng_softc *sc)
-{
-   uint32_t mask;
-
-   /* Clear the interrupt off bit in the interrupt mask register */
-   mask = bcm2835_rng_read4(sc, RNG_INT_MASK);
-   mask &= ~RNG_INT_OFF_BIT;
-bcm2835_rng_write4(sc, RNG_INT_MASK, mask);
-}
-#endif
-
-static void
 bcm2835_rng_start(struct bcm2835_rng_softc *sc)
 {
uint32_t ctrl;
@@ -244,11 +224,6 @@ bcm2835_rng_start(struct bcm2835_rng_softc *sc)
if (sc->sc_rbg2x)
ctrl |= RNG_RBG2X;
bcm2835_rng_write4(sc, RNG_CTRL, ctrl);
-
-#if defined(BCM2835_RNG_USE_INTERRUPT)
-   /* Enable the interrupt */
-   bcm2835_rng_enable_intr(sc);
-#endif
 }
 
 static void
@@ -263,12 +238,13 @@ bcm2835_rng_stop(struct bcm2835_rng_softc *sc)
 }
 
 static void
-bcm2835_rng_harvest(struct bcm2835_rng_softc *sc)
+bcm2835_rng_harvest(void *arg)
 {
uint32_t *dest;
uint32_t status;
u_int cnt, nread, num_avail, num_words;
int seen_underrun, num_stalls;
+   struct bcm2835_rng_softc *sc = arg;
 
dest = sc->sc_buf;
nread = num_words = 0;
@@ -316,9 +292,7 @@ bcm2835_rng_harvest(struct bcm2835_rng_softc *sc)
random_harvest_queue(sc->sc_buf, cnt, cnt * NBBY / 2,
RANDOM_PURE_BROADCOM);
 
-#if defined(BCM2835_RNG_USE_CALLOUT)
-   callout_reset(&sc->sc_rngto, sc->sc_rnghz, bcm2835_rng_harvest, sc);
-#endif
+   callout_reset(&sc->sc_rngto, RNG_CALLOUT_TICKS, bcm2835_rng_harvest, 
sc);
 }
 
 static int
@@ -390,10 +364,10 @@ bcm2835_rng_attach(device_t dev)
sc = device_get_softc(dev);
sc->sc_dev = dev;
sc->sc_stall_count = RNG_STALL_COUNT_DEFAULT;
-#ifdef BCM2835_RNG_USE_CALLOUT
+
/* Initialize callout */
callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
-#endif
+
TUNABLE_INT_FETCH("bcmrng.2xspeed", &sc->sc_rbg2x);
TUNABLE_INT_FETCH("bcmrng.stall_count", &sc->sc_stall_count);
 
@@ -406,27 +380,6 @@ bcm2835_rng_attach(device_t dev)
return (ENXIO);
}
 
-#if defined(BCM2835_RNG_USE_INTERRUPT)
-   /* Allocate interrupt resource */
-   rid = 0;
-   sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
-   RF_SHAREABLE | RF_ACTIVE);
-   if (sc->sc_irq_res == NULL) {
-   bcm2835_rng_detach(dev);
-   return (ENXIO);
-   }
-
-   /* Set up the interrupt handler */
-   error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
-   NULL, (driver_intr_t *)bcm2835_rng_harvest, sc, &sc->sc_intr_hdl);
-   if (error) {
-  

svn commit: r330558 - head/sys/dev/ichiic

2018-03-06 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar  6 23:39:43 2018
New Revision: 330558
URL: https://svnweb.freebsd.org/changeset/base/330558

Log:
  [ig4] Add support for i2c controllers on Skylake and Kaby Lake
  
  This was tested by Ben on  HP Chromebook 13 G1 with a
  Skylake CPU and Sunrise Point-LP I2C controller and by me on
  Minnowboard Turbot with Atom E3826 (formerly Bay Trail)
  
  Submitted by: Ben Pye 
  Reviewed by:  gonzo
  Obtained from:DragonflyBSD (a4549657 by Imre Vadász)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D13654

Modified:
  head/sys/dev/ichiic/ig4_acpi.c
  head/sys/dev/ichiic/ig4_iic.c
  head/sys/dev/ichiic/ig4_pci.c
  head/sys/dev/ichiic/ig4_reg.h
  head/sys/dev/ichiic/ig4_var.h

Modified: head/sys/dev/ichiic/ig4_acpi.c
==
--- head/sys/dev/ichiic/ig4_acpi.c  Tue Mar  6 23:28:12 2018
(r330557)
+++ head/sys/dev/ichiic/ig4_acpi.c  Tue Mar  6 23:39:43 2018
(r330558)
@@ -85,6 +85,8 @@ ig4iic_acpi_attach(device_t dev)
sc = device_get_softc(dev);
 
sc->dev = dev;
+   /* All the HIDs matched are Atom SOCs. */
+   sc->version = IG4_ATOM;
sc->regs_rid = 0;
sc->regs_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
  &sc->regs_rid, RF_ACTIVE);

Modified: head/sys/dev/ichiic/ig4_iic.c
==
--- head/sys/dev/ichiic/ig4_iic.c   Tue Mar  6 23:28:12 2018
(r330557)
+++ head/sys/dev/ichiic/ig4_iic.c   Tue Mar  6 23:39:43 2018
(r330558)
@@ -525,22 +525,38 @@ ig4iic_attach(ig4iic_softc_t *sc)
mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_DEF);
sx_init(&sc->call_lock, "IG4 call lock");
 
-   v = reg_read(sc, IG4_REG_COMP_TYPE);
-   v = reg_read(sc, IG4_REG_COMP_PARAM1);
-   v = reg_read(sc, IG4_REG_GENERAL);
-   if ((v & IG4_GENERAL_SWMODE) == 0) {
-   v |= IG4_GENERAL_SWMODE;
-   reg_write(sc, IG4_REG_GENERAL, v);
+   if (sc->version == IG4_ATOM)
+   v = reg_read(sc, IG4_REG_COMP_TYPE);
+   
+   if (sc->version == IG4_HASWELL || sc->version == IG4_ATOM) {
+   v = reg_read(sc, IG4_REG_COMP_PARAM1);
v = reg_read(sc, IG4_REG_GENERAL);
+   /*
+* The content of IG4_REG_GENERAL is different for each
+* controller version.
+*/
+   if (sc->version == IG4_HASWELL &&
+   (v & IG4_GENERAL_SWMODE) == 0) {
+   v |= IG4_GENERAL_SWMODE;
+   reg_write(sc, IG4_REG_GENERAL, v);
+   v = reg_read(sc, IG4_REG_GENERAL);
+   }
}
 
-   v = reg_read(sc, IG4_REG_SW_LTR_VALUE);
-   v = reg_read(sc, IG4_REG_AUTO_LTR_VALUE);
+   if (sc->version == IG4_HASWELL) {
+   v = reg_read(sc, IG4_REG_SW_LTR_VALUE);
+   v = reg_read(sc, IG4_REG_AUTO_LTR_VALUE);
+   } else if (sc->version == IG4_SKYLAKE) {
+   v = reg_read(sc, IG4_REG_ACTIVE_LTR_VALUE);
+   v = reg_read(sc, IG4_REG_IDLE_LTR_VALUE);
+   }
 
-   v = reg_read(sc, IG4_REG_COMP_VER);
-   if (v != IG4_COMP_VER) {
-   error = ENXIO;
-   goto done;
+   if (sc->version == IG4_HASWELL || sc->version == IG4_ATOM) {
+   v = reg_read(sc, IG4_REG_COMP_VER);
+   if (v != IG4_COMP_VER) {
+   error = ENXIO;
+   goto done;
+   }
}
v = reg_read(sc, IG4_REG_SS_SCL_HCNT);
v = reg_read(sc, IG4_REG_SS_SCL_LCNT);
@@ -591,8 +607,13 @@ ig4iic_attach(ig4iic_softc_t *sc)
/*
 * Don't do this, it blows up the PCI config
 */
-   reg_write(sc, IG4_REG_RESETS, IG4_RESETS_ASSERT);
-   reg_write(sc, IG4_REG_RESETS, IG4_RESETS_DEASSERT);
+   if (sc->version == IG4_HASWELL || sc->version == IG4_ATOM) {
+   reg_write(sc, IG4_REG_RESETS_HSW, IG4_RESETS_ASSERT_HSW);
+   reg_write(sc, IG4_REG_RESETS_HSW, IG4_RESETS_DEASSERT_HSW);
+   } else if (sc->version = IG4_SKYLAKE) {
+   reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_ASSERT_SKL);
+   reg_write(sc, IG4_REG_RESETS_SKL, IG4_RESETS_DEASSERT_SKL);
+   }
 #endif
 
mtx_lock(&sc->io_lock);
@@ -727,14 +748,27 @@ ig4iic_dump(ig4iic_softc_t *sc)
REGDUMP(sc, IG4_REG_DMA_RDLR);
REGDUMP(sc, IG4_REG_SDA_SETUP);
REGDUMP(sc, IG4_REG_ENABLE_STATUS);
-   REGDUMP(sc, IG4_REG_COMP_PARAM1);
-   REGDUMP(sc, IG4_REG_COMP_VER);
-   REGDUMP(sc, IG4_REG_COMP_TYPE);
-   REGDUMP(sc, IG4_REG_CLK_PARMS);
-   REGDUMP(sc, IG4_REG_RESETS);
-   REGDUMP(sc, IG4_REG_GENERAL);
-   REGDUMP(sc, IG4_REG_SW_LTR_VALUE);
-   REGDUMP(sc, IG4_REG_AUTO_LTR_VALUE);
+   if 

svn commit: r330309 - in head/share/man: man4 man9

2018-03-02 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Mar  3 02:49:49 2018
New Revision: 330309
URL: https://svnweb.freebsd.org/changeset/base/330309

Log:
  [fdt_pinctrl] Add man pages for fdt_pinctrl driver
  
  - Add fdt_pinctrl(4) with general information for the driver
  - Add fdt_pinctrl(9) with fdt_pinctrl KPI description
  
  Reviewed by:  ian, manu, wblock
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D14235

Added:
  head/share/man/man4/fdt_pinctrl.4   (contents, props changed)
  head/share/man/man9/fdt_pinctrl.9   (contents, props changed)
Modified:
  head/share/man/man4/Makefile
  head/share/man/man9/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileSat Mar  3 02:39:54 2018
(r330308)
+++ head/share/man/man4/MakefileSat Mar  3 02:49:49 2018
(r330309)
@@ -165,6 +165,7 @@ MAN=aac.4 \
fd.4 \
fdc.4 \
fdt.4 \
+   fdt_pinctrl.4 \
fdtbus.4 \
ffclock.4 \
filemon.4 \

Added: head/share/man/man4/fdt_pinctrl.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/fdt_pinctrl.4   Sat Mar  3 02:49:49 2018
(r330309)
@@ -0,0 +1,127 @@
+.\" Copyright (c) 2018 Oleksandr Tymoshenko
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 2, 2018
+.Dt "FDT_PINCTRL" 4
+.Os
+.Sh NAME
+.Nm fdt_pinctrl
+.Nd FDT I/O pin multiplexing support
+.Sh SYNOPSIS
+.Cd "device fdt_pinctrl"
+.Sh DESCRIPTION
+.Pp
+Pin multiplexing is a technology used to re-purpose a single
+physical connection (depending on chip packaging it may be
+pin, ball, or pad) to pull signal from one of SoC internal
+controllers to peripheral devices.
+For example, based on the actual device design, a single SoC chip
+pin can perform any of these roles: SPI clock, I2C
+data, GPIO pin, or PWM signal.
+Function selection is performed by the pinmux controller, a SoC
+hardware block, usually controlled a set of registers.
+Pinmux controller capabilities and register format depend
+on the actual hardware implementation.
+.Pp
+On
+.Xr fdt 4
+based systems, the pinmux controller is represented by a node in
+the device tree.
+It may have any number of child nodes representing pin
+configuration groups.
+Properties of such nodes are hardware-specific and handled
+by individual pinctrl drivers.
+.Ss Example 1
+Pinmux controller device tree node
+.Bd -literal
+pinctrl@7e22 {
+compatible = "vndr,soc1715-pinctrl";
+reg = <0x7e22 0x100>
+
+spi0_pins: spi0 {
+vndr,pins = <11 12>
+vndr,functions = 
+}
+
+i2c0_pins: i2c0 {
+...
+}
+}
+.Ed
+.Pp
+Client devices are hardware devices that require certain pin
+configurations to function properly.
+Depending on the state the device is in (active, idle) it might
+require different pin configurations.
+Each configuration is described by setting the pinctrl-N
+property to the list of phandles pointing to specific child
+nodes of the pinmux controller node.
+N is an integer value starting with 0 and incremented by 1
+for every new set of pin configurations.
+pinctrl-0 is a default configuration that is applied in the
+.Xr fdt_pinctrl_configure_tree 9
+call.
+In addition to referring to pin configurations by index, they
+can be referred to by name if the 

Re: svn commit: r330072 - in head/sys: arm/broadcom/bcm2835 dts/arm

2018-02-27 Thread Oleksandr Tymoshenko
Michal Meloun (m...@freebsd.org) wrote:
> Author: mmel
> Date: Tue Feb 27 15:01:17 2018
> New Revision: 330072
> URL: https://svnweb.freebsd.org/changeset/base/330072
> 
> Log:
>   Switch to mainstream DTS for Raspberry Pi-B  and Pi-2.
>   This is first step in attempt to make FreeBSD compatible with all variants 
> of
>   RPi boards.
>   
>   Reviewed by:gonzo
>   MFC after:  3 weeks
> 
> Modified:
>   head/sys/arm/broadcom/bcm2835/bcm2835_intr.c
>   head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
>   head/sys/arm/broadcom/bcm2835/bcm2835_systimer.c
>   head/sys/arm/broadcom/bcm2835/bcm283x_dwc_fdt.c
>   head/sys/dts/arm/rpi.dts
>   head/sys/dts/arm/rpi2.dts

Thanks for working on this

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r329926 - head/sys/dev/gpio

2018-02-24 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Feb 24 20:19:31 2018
New Revision: 329926
URL: https://svnweb.freebsd.org/changeset/base/329926

Log:
  Add SPDX tags for chvgpio driver sources
  
  Also move $FreeBSD$ keyword in header to BSD license
  
  MFC after:2 weeks

Modified:
  head/sys/dev/gpio/chvgpio.c
  head/sys/dev/gpio/chvgpio_reg.h

Modified: head/sys/dev/gpio/chvgpio.c
==
--- head/sys/dev/gpio/chvgpio.c Sat Feb 24 20:12:01 2018(r329925)
+++ head/sys/dev/gpio/chvgpio.c Sat Feb 24 20:19:31 2018(r329926)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (c) 2017 Tom Jones 
  * All rights reserved.
  *

Modified: head/sys/dev/gpio/chvgpio_reg.h
==
--- head/sys/dev/gpio/chvgpio_reg.h Sat Feb 24 20:12:01 2018
(r329925)
+++ head/sys/dev/gpio/chvgpio_reg.h Sat Feb 24 20:19:31 2018
(r329926)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (c) 2017 Tom Jones 
  * All rights reserved.
  *
@@ -23,6 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
+ * $FreeBSD$
  */
 
 /*
@@ -40,7 +43,6 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD$
  */
 
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r329832 - in head: share/man/man4 sys/conf sys/dev/gpio sys/modules sys/modules/chvgpio

2018-02-22 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Feb 22 19:12:32 2018
New Revision: 329832
URL: https://svnweb.freebsd.org/changeset/base/329832

Log:
  [chvgpio] add GPIO driver for Intel Z8xxx SoC family
  
  Add chvgpio(4) driver for Intel Z8xxx SoC family. This product
  was formerly known as Cherry Trail but Linux and OpenBSD drivers
  refer to it as Cherry View. This driver is derived from OpenBSD
  one so the name is kept for alignment with another BSD system.
  
  Submitted by: Tom Jones 
  Reviewed by:  gonzo, wblock(man page)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D13086

Added:
  head/share/man/man4/chvgpio.4   (contents, props changed)
  head/sys/dev/gpio/chvgpio.c   (contents, props changed)
  head/sys/dev/gpio/chvgpio_reg.h   (contents, props changed)
  head/sys/modules/chvgpio/
  head/sys/modules/chvgpio/Makefile   (contents, props changed)
Modified:
  head/share/man/man4/Makefile
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/modules/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileThu Feb 22 18:49:53 2018
(r329831)
+++ head/share/man/man4/MakefileThu Feb 22 19:12:32 2018
(r329832)
@@ -97,6 +97,7 @@ MAN=  aac.4 \
bwi.4 \
bwn.4 \
${_bytgpio.4} \
+   ${_chvgpio.4} \
capsicum.4 \
cardbus.4 \
carp.4 \
@@ -796,6 +797,7 @@ _amdtemp.4= amdtemp.4
 _asmc.4=   asmc.4
 _bxe.4=bxe.4
 _bytgpio.4=bytgpio.4
+_chvgpio.4=chvgpio.4
 _coretemp.4=   coretemp.4
 _cpuctl.4= cpuctl.4
 _dpms.4=   dpms.4

Added: head/share/man/man4/chvgpio.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/chvgpio.4   Thu Feb 22 19:12:32 2018
(r329832)
@@ -0,0 +1,65 @@
+.\" Copyright (c) 2017
+.\"Tom Jones   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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd November 17, 2017
+.Dt CHVGPIO 4
+.Os
+.Sh NAME
+.Nm chvgpio
+.Nd Intel Cherry View SoC GPIO controller
+.Sh SYNOPSIS
+.Cd "device gpio"
+.Cd "device chvgpio"
+.Sh DESCRIPTION
+.Nm
+supports the GPIO controller that can be found in Intel's Cherry View SoC
+family.
+.Pp
+The Cherry View SoC has 5 banks of GPIO pins, NORTH, EAST, SOUTHEAST, SOUTHWEST
+and VIRTUAL.
+All but VIRTUAL are exposed to userland as
+.Pa /dev/gpiocN ,
+where N is 0-3.
+Pins in each bank are pre-named to match names in the Intel® Atom™ Z8000
+Processor Series Vol 2
+.Sh SEE ALSO
+.Xr gpio 3 ,
+.Xr gpio 4 ,
+.Xr gpioctl 8
+.Rs
+.%T Intel® Atom™ Z8000 Processor Series Vol 1
+.Re
+.Rs
+.%T Intel® Atom™ Z8000 Processor Series Vol 2
+.Re
+.Sh HISTORY
+The
+.Nm
+manual page first appeared in
+.Fx 12 .
+.Sh AUTHORS
+This driver and man page were written by
+.An Tom Jones Aq Mt t...@enoti.me .

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Thu Feb 22 18:49:53 2018(r329831)
+++ head/sys/conf/files.amd64   Thu Feb 22 19:12:32 2018(r329832)
@@ -293,6 +293,7 @@ dev/fdc/fdc_acpi.c  optionalfdc
 dev/fdc/fdc_isa.c  optionalfdc isa
 dev/fdc/fdc_pccard.c   optionalfdc pccard
 dev/gpio/bytgpio.c optionalbytgpio
+dev/gpio/chvgpio.c optionalchvgpio
 dev/hpt27xx/hpt27xx_os_bsd.c   optionalhpt27xx
 dev/hpt27xx/hpt27xx_osm_bsd.c  optionalhpt27xx
 dev/hpt27xx/hpt27xx_config.c   optionalhpt27xx

Mo

Re: svn commit: r328257 - in head/sys: arm/broadcom/bcm2835 dts/arm modules

2018-01-30 Thread Oleksandr Tymoshenko
Poul-Henning Kamp (p...@phk.freebsd.dk) wrote:
> 
> In message <20180130025048.ga76...@bluezbox.com>, Oleksandr Tymoshenko writes:
> 
> >> You seem to have skipped the bit about "without reboot" ?
> >
> >No I haven't. config.txt is parsed by VC firmware on boot time
> >and pwm.dtbo is applied even before boot loader kicks in. When
> >kernel starts pwm node has pinctl information ready and status
> >property is set to "okay". So if you download next available image,
> >flash and boot it and run kldload bcm2835_pwm it will give you
> >working PWM device out of the box without reboot.
> 
> But only if you add pwm.dtbo to config.txt and reboot, because
> I see nothing indicating that we will put it there in the
> release images we (may start to) produce ?

No. We're going to add them in our release image. That's what
I meant by "working with Glen and Brad". Glen as release
engineer built all those scripts that prepare SoC images.
He works closely with FreeBSD/ARM community and although
I can't speak for him I hope he won't object to the change
that introduces new feature and doesn't violate POLA.
We already install two overlays that are required to get
reasonable boot-time defaults. 

PI3 release image config is here:
http://svn.freebsd.org/base/head/release/arm64/RPI3.conf

Adding pwm.dtbo is one-line change. Adding line to config.txt
is one more line.

RaspBSD is volunteer project by Brad Davis so it's completely
up to him whether to enable PWM by default or not. He knows his
userbase best. All one can do is to make a case and present it
to Brad.

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328257 - in head/sys: arm/broadcom/bcm2835 dts/arm modules

2018-01-29 Thread Oleksandr Tymoshenko
Poul-Henning Kamp (p...@phk.freebsd.dk) wrote:
> 
> In message <20180129132736.ga66...@bluezbox.com>, Oleksandr Tymoshenko writes:
> 
> >> If I pick a RPI[23] out of the box, download a FreeBSD image,
> >> put the card in and play around, I should be able to put a
> >> LED in a breadboard and configure a line for PWM or attach
> >> an I2C or SPI device without reboot between every single
> >> experiment.
> >
> >No problem. We include pwm.dtbo in our snapshot and config.txt.
> >We have PWM running out of the box. Problem solved, no need for
> >any hacks. I'll gladly work with Glen and Brad to get this
> >functionality in snapshots/builds.
> 
> You seem to have skipped the bit about "without reboot" ?

No I haven't. config.txt is parsed by VC firmware on boot time
and pwm.dtbo is applied even before boot loader kicks in. When
kernel starts pwm node has pinctl information ready and status
property is set to "okay". So if you download next available image,
flash and boot it and run kldload bcm2835_pwm it will give you
working PWM device out of the box without reboot.

It's end-user experience you described. This approach works well
with soon to be added pinctl and does not require
ofw_bus_status_okay hack. Please commit a fix for it.
 
> >Raspberry Pi and other hobbyist ARM boards are basically Lego.
> >They can be turned into multiple things and that's their selling
> >point. They're hackers' toys.
> 
> That's *exactly* why I want us to support them better.
> 
> >You ignored my question: what would be authoritative source for this
> >kind of info? World is not perfect, FreeBSD/arm support is not perfect.
> >We have limited resources. Where we should apply them to guide
> >new contributors?
> 
> At the very least have some place to point developers for a
> resonably up-to-date idea of what the FDT related architecture
> in FreeBSD is.

Fair point. It can be chapter in Handbook.
 
> Either documentation or source code (preferably with a bit of
> contextual comments) on our chosen reference platform.  (Source
> code on ref-platform is probably more robust, as there is a
> better chance that it will be kept current.)

I don't think we have designated reference platform at the moment,
but it's a good idea to have one. Pi's platform is too weird to
be reference. TI's AM335x or iMX would be a good candidate I think
They are complex enough to illustrate all the concepts yet not super
complex. There is probably some bugs there from the dawn of FDT era but
thery can be cleaned out. Nvidia's SoCs are not very accessible.
And I don't have any knowledge about how complex Allwinner codebase is.
 
> >You also ignored my question about clkman fix. Provided you have
> >all the documentation you need [...]
> 
> I don't.  The information for the PWM case was based on an affine
> transform of information for the GPIO clock some shrewed guesses
> and finally in-lab measurement of what actually transpired when I
> frobbed registers.
> 
> But more importantly, I have no idea what servies *a* clock
> manager offers, through which apis and to what clients and
> at what level of abstraction and flexibility ?

Wrong wording on my side. It should have been: "if somebody put
together all required documentation on clk framework would you
be up to fix clkmgr driver?" Doesn't matter now, mmel@
volunteered to look into this.

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328257 - in head/sys: arm/broadcom/bcm2835 dts/arm modules

2018-01-29 Thread Oleksandr Tymoshenko
Poul-Henning Kamp (p...@phk.freebsd.dk) wrote:
> 
> In message <20180129063950.ga59...@bluezbox.com>, Oleksandr Tymoshenko writes:
> 
> >PWM drivers: https://reviews.freebsd.org/D14104
> 
> I'll test this in my next timeslot.
> 
> >We do not include these
> >overlays in official snapshots and I think this should be fixed.
> 
> That's one of the details I ran into:  The DTS for the DTB
> in the RaspBSD.org images is not in our tree.
> 
> Even if they are vendor-supplied, should they be in our tree for
> reasons of completeness/documentation/reproducible builds etc. ?

The answer is: it's complicated. There is no single source of
truth. Raspberry Pi's DTS in vendor tree is different from the
one in mainline Linux and therefore ours (we lag a bit behind
mainline Linux). As far as I know Nvidia is the same.  DTS world
is a mess and that's why people spend so much energy
communicating between vendors, mainline Linux and FreeBSD to get
this stuff standartized and to reduce chaos. Also FDT should
be supplied by vendor by definition. Closest thing to FDT in
beige box world is ACPI tables. It's just unfortunate state of
affairs that standard is in constant flux and Linux monopolized
distribution rights.
 
> >Summary: adding ofw_bus_status_okay check in probe method doesn't
> >require any additional functionality, ignoring it is inconsistent
> >with majority of FDT-based drivers' behavior.  There is trivial
> >way to enable PWM device in platform-conformant way. Will you
> >please commit fix for this bug? 
> 
> I prefer an architectural discussion about how we *want* this to
> work in the long run first.
> 
> My input:
> 
> If I pick a RPI[23] out of the box, download a FreeBSD image,
> put the card in and play around, I should be able to put a
> LED in a breadboard and configure a line for PWM or attach
> an I2C or SPI device without reboot between every single
> experiment.

No problem. We include pwm.dtbo in our snapshot and config.txt.
We have PWM running out of the box. Problem solved, no need for
any hacks. I'll gladly work with Glen and Brad to get this
functionality in snapshots/builds.

> If I mount any kind of "cape" board, requiring a reboot is
> a perfectly reasonable requirement (not to mention it being
> sane ESD procedure.)
> 
> That may indicate an overall model where we distinguish between
> "overlays loaded at boottime" and "no overlays loaded at
> boot time" and behave more liberally in the second case.
> 
> Or maybe we just need a well hidden but powerful switch that
> lets people say "God, Root, What difference?"
> 
> The crucial point is that we gain no friends or favours by enforcing
> needless cumbersome procedures, like reboots, just because there
> may some times be dangers without it, because very often the dangerous
> things people want to do is getting their job done or develop
> and improve FreeBSD.
> 
> I kindly point you to the wisdom of Kernighans "There is no
> escape" critique of PASCAL.
> 
> (Service message to the non-ancient developers:  That this bit of
> advice came from the bloke who had read Kernighan and therefore
> implemented "kern.geom.debugflags=0x10" to defeat the consistency
> protections in his new-fangled GEOM subsystem, even if it was
> dangerous - and he never once regretted it.)
 
Design discussion on dynamic overlays is welcome. FreeBSD/arm can
use more hands, brains, and set of fresh eyes. It's non-trivial
topic and I am really glad someone is working on it. I gave up
year ago. But committing bad hack and then requesting design
discussion is a hostage situation and not a dialog.

Raspberry Pi and other hobbyist ARM boards are basically Lego.
They can be turned into multiple things and that's their selling
point. They're hackers' toys. You approach them as a box product
and you approach them from the wrong angle. If you want box
product built with Lego, concentrate on how blocks are put
together, not on how joints work.

It looks to me like you apply your experience from x86 world and
look at FDT-based platforms as a smaller and weirder PCs. They're
not, they're completely different breed. They're not even
embedded systems with ad-hoc hardware info from 10 years ago,
they're order of magnitude more complex. With all due respect the
fact that we're having this discussion or that I have to explain
FDT/DTS files origins is an indicator of how little you understand
current situation in hobbyist embedded world or embedded FreeBSD
for that matters. I've been working on this stuff for last 5
years on and off, lately mostly off and I know I am behind all
the latest developments.

"Don't ignore status prop

Re: svn commit: r328257 - in head/sys: arm/broadcom/bcm2835 dts/arm modules

2018-01-28 Thread Oleksandr Tymoshenko
Poul-Henning Kamp (p...@phk.freebsd.dk) wrote:
> 
> In message <8d8ae9d10058fd72ce3ec467181c9...@megadrive.org>, Emmanuel Vadot 
> writes:
> 
> >  Sometimes it makes sense to reboot.
> 
> Yes, *sometimes* it does.
> 
> But *always* demanding reboot makes no sense ever.
> 
> >  Reference platform doesn't make much sense in the embedded world.
> 
> A reference platform which peple can look at to find out what the
> software architecture is supposed to be, in the near total absense of
> documentation for said software architecture makes a lot of sense.
> 
> >  I'm not upset at you for not using, I'm "upset" at you for not wanting 
> >to make the effort to implement them. Some are hard, some are easy.
> 
> FreeBSD is a hobby for me these days, that implied a certain amount
> of enjoyment and limited time.
> 
> Trying to guess what software architecture you want to be written,
> based on the non-existent documentation and with no reference-platform
> to look at, and then implementing it on a SOC where the hardware
> documentation spans the gamut from from missing over mangled to
> misleading, does not qualify as "enjoyment" for me and it certainly
> is not something I have time for.
> 
> >  What's funny though is that even with a pinctrl and clock management, 
> >we still don't have what is necessary to implement what you want 
> >(kldloading a driver and directly use pwm). For that we need overlays at 
> >runtime, pinmuxing at runtime and probably other things too.
> 
> I'm amazed if those things are not already part of our ambition ?
> 
> >  This is where I (and probably) other don't agree, this is backward.
> >  We must implement first proper pinctrl driver and clock management 
> >  instead of introduce hacks.
> 
> Who exactly are "We" ?
> 
> You indicated that you are not going to do it.
> 
> I can't because I don't know what it is that I am supposed to write.
> 
> Nobody else seems to be inclined to do it either.
> 
> So RPi as a platform is just in limbo forever ?
> 
> And where does this "Spanish Inquisition" road end?
> 
> Why are gpio and spi allowed to exist on the RPi platform?  Or is
> your next demand going to be that they also be removed pending a
> hypothetical pinctrl driver ?

So to stear discussion away from heated emotional exchange
and to the more practical side. As far as I understand there
are three contentious points: pinctl, clock management,
ignoring "status" property 

I2C and SPI drivers predate pinctl and proper FDT support. pin
config part there is ugly as hell and should have been
re-implemented long ago. Here is the patch that fixes these and
PWM drivers: https://reviews.freebsd.org/D14104

I don't know enough about extres/clk framework but I know how to
read code and where to look for references so I can document it.
RPi3 DTS bindings might be not compatible with our implementation of
extres/clk but I can check. Will it help you to fix clkman
driver in foreseeable future?

Ignoring value of ofw_bus_status_okay(dev) in probe method is
wrong for number of reasons and pinctl and clocks were brought up
as an example why "status" property is more than just
attach/dont-attach flag. So there is strictly technical reason
why it should be checked. Once this boilerplate code moves to
simplebus bus probe method as I believe Warner proposed drivers
will not be able to control this aspect any more.

There is blessed way to enable drivers on FDT-based platforms:
overlays. There is a bunch of precompiled blobs for RPi provided
by vendor[1]. To enable PWM on specific pin you need to add following
line to config.txt on boot partition:
dtoverlay=pwm,pin=12,func=4
It's documented here[2]. With proposed pinctl patch your driver
can work on any configurabe pin. We do not include these
overlays in official snapshots and I think this should be fixed.

This approach is not optimal but actual solution for dynamic
device management is complex and requires multiple steps.

There are some drivers in arm/broadcom/bcm2835 that ignore
status value, they should be fixed too. Probably on other
platforms too. I'll look into this to lead the way so to say.

Summary: adding ofw_bus_status_okay check in probe method doesn't
require any additional functionality, ignoring it is inconsistent
with majority of FDT-based drivers' behavior.  There is trivial
way to enable PWM device in platform-conformant way. Will you
please commit fix for this bug? 

All these best practices and guidelines are unwriteen, and
they're not always implemented on older platforms. And it's the
problem from which this situation has risen. They exist as an
"oral tradition" among people who extencively work with FDT-based
platforms and communicate in reviews or mailing list. There is no
entry in MAINTAINERS, no official developer's guide to embedded
systems, documentation exists mostly in a form of source code.
May be it can be improved. Where should they be codified or
documented (except man pages) to be authoritative source?  Where

Re: svn commit: r328257 - in head/sys: arm/broadcom/bcm2835 dts/arm modules

2018-01-27 Thread Oleksandr Tymoshenko
Adrian Chadd (adrian.ch...@gmail.com) wrote:
> Hi,
> 
> Find the middle ground. Don't dissuade the developer too much.
> 
> Here's an example:
> 
> Make the driver follow DTS, allow a tunable/kenv check for it to
> override whether it needs to be in the DTS or not (the "keep phk happy
> for now" compromise) and have it default to obeying the device tree.
> 
> That way phk is kept happy and the defaults are the same as normal-ish
> ARM /and/ you have a springboard to experiment with extending FDT
> overlays at runtime for people who wish to do so.

This doesn't sound right. I'm 100% with manu@ on this: driver needs to
be modified to follow DTS. A lot of work was spent to get FreeBSD FDT
support consistent over multiple platforms and to make sure it conforms
standard. When it comes to FDT support Pi port is inferior to the
majority of platforms that have been added later. I bear a fair share of
responsibility for this mess and it makes me appreciate all the effort
spent on correcting the situation even more.

Adding changes that violate standard and undermine all that work for
the convenience of a single developer is plain wrong. If current
framework is not good enough the way to go is to improve it, not hack
around its limitations

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327502 - head/sys/dev/nctgpio

2018-01-02 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Jan  2 20:58:05 2018
New Revision: 327502
URL: https://svnweb.freebsd.org/changeset/base/327502

Log:
  nctgpio: add new device id for the GPIO chip in PCEngines APU3
  
  PR:   224512
  Submitted by: m...@sentex.net
  MFC after:2 weeks

Modified:
  head/sys/dev/nctgpio/nctgpio.c

Modified: head/sys/dev/nctgpio/nctgpio.c
==
--- head/sys/dev/nctgpio/nctgpio.c  Tue Jan  2 20:22:31 2018
(r327501)
+++ head/sys/dev/nctgpio/nctgpio.c  Tue Jan  2 20:58:05 2018
(r327502)
@@ -140,6 +140,10 @@ struct nuvoton_vendor_device_id {
.chip_id= 0xc452,
.descr  = "Nuvoton NCT5104D (PC-Engines APU)",
},
+   {
+   .chip_id= 0xc453,
+   .descr  = "Nuvoton NCT5104D (PC-Engines APU3)",
+   },
 };
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327454 - head/sys/dev/vt/colors

2017-12-31 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Dec 31 23:40:06 2017
New Revision: 327454
URL: https://svnweb.freebsd.org/changeset/base/327454

Log:
  Fix GCC build broken by r32744
  
  Indicate in function declaration that vt_palette_init does not take any 
arguments

Modified:
  head/sys/dev/vt/colors/vt_termcolors.c

Modified: head/sys/dev/vt/colors/vt_termcolors.c
==
--- head/sys/dev/vt/colors/vt_termcolors.c  Sun Dec 31 22:43:24 2017
(r327453)
+++ head/sys/dev/vt/colors/vt_termcolors.c  Sun Dec 31 23:40:06 2017
(r327454)
@@ -144,7 +144,7 @@ vt_parse_rgb_triplet(const char *rgb, unsigned char *r
 }
 
 static void
-vt_palette_init()
+vt_palette_init(void)
 {
int i;
char rgb[32];
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327449 - head/sys/dev/vt/colors

2017-12-31 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Dec 31 21:29:20 2017
New Revision: 327449
URL: https://svnweb.freebsd.org/changeset/base/327449

Log:
  Unbreak build broken by r327444
  
  During review iterations function signature has changed in definition
  but not in actual call. Fix call to match the definition.
  
  Reported by:  Herbert J. Skuhra
  Pointyhat to: gonzo
  MFC after:2 weeks

Modified:
  head/sys/dev/vt/colors/vt_termcolors.c

Modified: head/sys/dev/vt/colors/vt_termcolors.c
==
--- head/sys/dev/vt/colors/vt_termcolors.c  Sun Dec 31 21:23:14 2017
(r327448)
+++ head/sys/dev/vt/colors/vt_termcolors.c  Sun Dec 31 21:29:20 2017
(r327449)
@@ -155,7 +155,7 @@ vt_palette_init()
snprintf(tunable, sizeof(tunable),
"kern.vt.color.%d.rgb", i);
if (TUNABLE_STR_FETCH(tunable, rgb, sizeof(rgb))) {
-   if (vt_parse_rgb_triplet(rgb, strlen(rgb), &r, &g, &b) 
== 0) {
+   if (vt_parse_rgb_triplet(rgb, &r, &g, &b) == 0) {
/* convert to percentages */
color_def[i].r = r*100/255;
color_def[i].g = g*100/255;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327444 - in head: share/man/man4 sys/dev/vt/colors

2017-12-31 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Dec 31 20:21:05 2017
New Revision: 327444
URL: https://svnweb.freebsd.org/changeset/base/327444

Log:
  vt(4): add support for configurable console palette
  
  Introduce new set of loader tunables kern.vt.color.N.rgb, where N is a
  number from 0 to 15. The value is either comma-separated list decimal
  numbers ranging from 0 to 255 that represent values of red, green, and
  blue components respectively (i.e. "128,128,128") or 6-digit hex triplet
  commonly used to represent colors in HTML or xterm settings (i.e. #808080)
  
  Each tunable overrides one of the 16 hardcoded palette codes and can be set
  in loader.conf(5)
  
  Reviewed by:  bcr(docs), jilles, manu, ray
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D13645

Modified:
  head/share/man/man4/vt.4
  head/sys/dev/vt/colors/vt_termcolors.c

Modified: head/share/man/man4/vt.4
==
--- head/share/man/man4/vt.4Sun Dec 31 20:20:55 2017(r327443)
+++ head/share/man/man4/vt.4Sun Dec 31 20:21:05 2017(r327444)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 19, 2016
+.Dd December 28, 2017
 .Dt "VT" 4
 .Os
 .Sh NAME
@@ -45,6 +45,7 @@ In
 .Xr loader.conf 5 :
 .Cd hw.vga.textmode=1
 .Cd kern.vty=vt
+.Cd kern.vt.color..rgb=""
 .Cd kern.vt.fb.default_mode="x"
 .Cd kern.vt.fb.modes.="x"
 .Pp
@@ -206,6 +207,16 @@ The
 kernel uses
 .Nm
 when this value is not set.
+.It Va kern.vt.color. Ns Ar colornum Ns Va .rgb
+Set this value to override default palette entry for color
+.Pa colornum
+which should be in a range from 0 to 15 inclusive.
+The value should be either a comma-separated triplet of
+red, green, and blue values in a range from 0 to 255 or
+HTML-like hex triplet.
+See
+.Sx EXAMPLES
+below.
 .It Va kern.vt.fb.default_mode
 Set this value to a graphic mode to override the default mode picked by the
 .Nm
@@ -310,6 +321,11 @@ The connector name was found in
 .Dl info: [drm] Connector LVDS-1: get mode from tunables:
 .Dl info: [drm]   - kern.vt.fb.modes.LVDS-1
 .Dl info: [drm]   - kern.vt.fb.default_mode
+.Pp
+To set black and white colors of console palette
+.Pp
+.Dl kern.vt.color.0.rgb="10,10,10"
+.Dl kern.vt.color.15.rgb="#f0f0f0"
 .Sh SEE ALSO
 .Xr kbdcontrol 1 ,
 .Xr login 1 ,

Modified: head/sys/dev/vt/colors/vt_termcolors.c
==
--- head/sys/dev/vt/colors/vt_termcolors.c  Sun Dec 31 20:20:55 2017
(r327443)
+++ head/sys/dev/vt/colors/vt_termcolors.c  Sun Dec 31 20:21:05 2017
(r327444)
@@ -33,14 +33,18 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
+#include 
 
 #include 
 
-static const struct {
+#define NCOLORS16
+
+static struct {
unsigned char r;/* Red percentage value. */
unsigned char g;/* Green percentage value. */
unsigned char b;/* Blue percentage value. */
-} color_def[16] = {
+} color_def[NCOLORS] = {
{0, 0,  0}, /* black */
{50,0,  0}, /* dark red */
{0, 50, 0}, /* dark green */
@@ -65,19 +69,112 @@ static const struct {
  *   - blue and red are swapped (1 <-> 4)
  *   - yellow ad cyan are swapped (3 <-> 6)
  */
-static const int cons_to_vga_colors[16] = {
+static const int cons_to_vga_colors[NCOLORS] = {
0, 4, 2, 6, 1, 5, 3, 7,
0, 4, 2, 6, 1, 5, 3, 7
 };
 
+static int
+vt_parse_rgb_triplet(const char *rgb, unsigned char *r,
+unsigned char *g, unsigned char *b)
+{
+   unsigned long v;
+   const char *ptr;
+   char *endptr;
+
+   ptr = rgb;
+
+   /* Handle #rrggbb case */
+   if (*ptr == '#') {
+   if (strlen(ptr) != 7)
+   return (-1);
+   v = strtoul(ptr + 1, &endptr, 16);
+   if (*endptr != '\0')
+   return (-1);
+
+   *r = (v >> 16) & 0xff;
+   *g = (v >>  8) & 0xff;
+   *b = v & 0xff;
+
+   return (0);
+   }
+
+   /* "r, g, b" case */
+   v = strtoul(ptr, &endptr, 10);
+   if (ptr == endptr)
+   return (-1);
+   if (v > 255)
+   return (-1);
+   *r = v & 0xff;
+   ptr = endptr;
+
+   /* skip separator */
+   while (*ptr == ',' || *ptr == ' ')
+   ptr++;
+
+   v = strtoul(ptr, &endptr, 10);
+   if (ptr == endptr)
+   return (-1);
+   if (v > 255)
+   return (-1);
+   *g = v & 0xff;
+   ptr = endptr;
+
+   /* skip separator */
+   while (*ptr == ',' || *ptr == ' ')
+   ptr++;
+
+   v = strtoul(ptr, &endptr, 10);
+   if (ptr == endptr)
+   return (-1);
+   if (v > 255)
+   return (-1);
+   *b = v & 0xff;
+   ptr = endptr;
+
+   /* skip trailing spaces */
+   while (*ptr == ' ')
+   ptr++;
+
+   /* unexp

svn commit: r325410 - head/sys/arm/allwinner

2017-11-04 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Nov  4 23:28:02 2017
New Revision: 325410
URL: https://svnweb.freebsd.org/changeset/base/325410

Log:
  Increase TX_MAX_SEGS from 10 to 20 for the if_awg.c driver
  
  Under certain traffic pattern awg driver does not recover from TX queue
  full condition. The actual source of the problem is not identified yet
  but jmcneill@ agreed that bumping TX_MAX_SEGS to 20 is OK as a workaround
  for the problem (NetBSD has it set to 128).
  
  Also add some diagnostic printfs to prevent silent failure of bus_dma
  functions in the future
  
  PR will be kept open until root cause of the issue is identified and fixed
  
  PR:   219927
  Submitted by: Tom Vijlbrief 
  Approved by:  jmcneill
  MFC after:2 weeks

Modified:
  head/sys/arm/allwinner/if_awg.c

Modified: head/sys/arm/allwinner/if_awg.c
==
--- head/sys/arm/allwinner/if_awg.c Sat Nov  4 22:23:41 2017
(r325409)
+++ head/sys/arm/allwinner/if_awg.c Sat Nov  4 23:28:02 2017
(r325410)
@@ -92,7 +92,7 @@ __FBSDID("$FreeBSD$");
 #defineTX_SKIP(n, o)   (((n) + (o)) & (TX_DESC_COUNT - 1))
 #defineRX_NEXT(n)  (((n) + 1) & (RX_DESC_COUNT - 1))
 
-#defineTX_MAX_SEGS 10
+#defineTX_MAX_SEGS 20
 
 #defineSOFT_RST_RETRY  1000
 #defineMII_BUSY_RETRY  1000
@@ -192,6 +192,7 @@ struct awg_softc {
struct resource *res[_RES_NITEMS];
struct mtx  mtx;
if_tifp;
+   device_tdev;
device_tmiibus;
struct callout  stat_ch;
struct task link_task;
@@ -421,14 +422,18 @@ awg_setup_txbuf(struct awg_softc *sc, int index, struc
sc->tx.buf_map[index].map, m, segs, &nsegs, BUS_DMA_NOWAIT);
if (error == EFBIG) {
m = m_collapse(m, M_NOWAIT, TX_MAX_SEGS);
-   if (m == NULL)
+   if (m == NULL) {
+   device_printf(sc->dev, "awg_setup_txbuf: m_collapse 
failed\n");
return (0);
+   }
*mp = m;
error = bus_dmamap_load_mbuf_sg(sc->tx.buf_tag,
sc->tx.buf_map[index].map, m, segs, &nsegs, BUS_DMA_NOWAIT);
}
-   if (error != 0)
+   if (error != 0) {
+   device_printf(sc->dev, "awg_setup_txbuf: 
bus_dmamap_load_mbuf_sg failed\n");
return (0);
+   }
 
bus_dmamap_sync(sc->tx.buf_tag, sc->tx.buf_map[index].map,
BUS_DMASYNC_PREWRITE);
@@ -1613,6 +1618,7 @@ awg_attach(device_t dev)
int error;
 
sc = device_get_softc(dev);
+   sc->dev = dev;
sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
node = ofw_bus_get_node(dev);
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r325048 - head/sys/dev/usb/net

2017-10-27 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Oct 27 21:22:38 2017
New Revision: 325048
URL: https://svnweb.freebsd.org/changeset/base/325048

Log:
  Fix MAC address detection regression introduced by r324184
  
  To accomodate all variaties of Pi DTS files floating around
  we look for MAC address property either in DTS node for
  USB ethernet (if it exists) or at predefined path
  ".../usb/hub/ethernet".
  
  After r324184 smsc_fdt_find_eth_node started to return node
  with compatibility string "usb424,ec00" as an eth node.
  In imported GNU dts files this node still does not have
  MAC address related property, and therefor following check for
  "mac-address" and "local-mac-address" fails.
  
  To make this logic more robust do not just search for the node
  but also make sure it has required property, so if node with
  accepted compatibility string exists but doesn't have the
  property we fall back to looking for hardoded path mentioned above.

Modified:
  head/sys/dev/usb/net/if_smsc.c

Modified: head/sys/dev/usb/net/if_smsc.c
==
--- head/sys/dev/usb/net/if_smsc.c  Fri Oct 27 20:21:09 2017
(r325047)
+++ head/sys/dev/usb/net/if_smsc.c  Fri Oct 27 21:22:38 2017
(r325048)
@@ -1637,6 +1637,37 @@ smsc_fdt_find_eth_node_by_path(phandle_t start)
return (-1);
 }
 
+/*
+ * Look through known names that can contain mac address
+ * return 0 if valid MAC address has been found
+ */
+static int
+smsc_fdt_read_mac_property(phandle_t node, unsigned char *mac)
+{
+   int len;
+
+   /* Check if there is property */
+   if ((len = OF_getproplen(node, "local-mac-address")) > 0) {
+   if (len != ETHER_ADDR_LEN)
+   return (EINVAL);
+
+   OF_getprop(node, "local-mac-address", mac,
+   ETHER_ADDR_LEN);
+   return (0);
+   }
+
+   if ((len = OF_getproplen(node, "mac-address")) > 0) {
+   if (len != ETHER_ADDR_LEN)
+   return (EINVAL);
+
+   OF_getprop(node, "mac-address", mac,
+   ETHER_ADDR_LEN);
+   return (0);
+   }
+
+   return (ENXIO);
+}
+
 /**
  * Get MAC address from FDT blob.  Firmware or loader should fill
  * mac-address or local-mac-address property.  Returns 0 if MAC address
@@ -1646,37 +1677,22 @@ static int
 smsc_fdt_find_mac(unsigned char *mac)
 {
phandle_t node, root;
-   int len;
 
root = OF_finddevice("/");
node = smsc_fdt_find_eth_node(root);
+   if (node != -1) {
+   if (smsc_fdt_read_mac_property(node, mac) == 0)
+   return (0);
+   }
+
/*
 * If it's not FreeBSD FDT blob for RPi, try more
 * generic .../usb/hub/ethernet
 */
-   if (node == -1)
-   node = smsc_fdt_find_eth_node_by_path(root);
+   node = smsc_fdt_find_eth_node_by_path(root);
 
-   if (node != -1) {
-   /* Check if there is property */
-   if ((len = OF_getproplen(node, "local-mac-address")) > 0) {
-   if (len != ETHER_ADDR_LEN)
-   return (EINVAL);
-
-   OF_getprop(node, "local-mac-address", mac,
-   ETHER_ADDR_LEN);
-   return (0);
-   }
-
-   if ((len = OF_getproplen(node, "mac-address")) > 0) {
-   if (len != ETHER_ADDR_LEN)
-   return (EINVAL);
-
-   OF_getprop(node, "mac-address", mac,
-   ETHER_ADDR_LEN);
-   return (0);
-   }
-   }
+   if (node != -1)
+   return smsc_fdt_read_mac_property(node, mac);
 
return (ENXIO);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r322827 - head/sys/boot/fdt/dts/arm

2017-08-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Aug 24 02:08:52 2017
New Revision: 322827
URL: https://svnweb.freebsd.org/changeset/base/322827

Log:
  Add "xlnx,zynq-7000" to zedboard and zybo compatible property
  
  This property is required to boot CURRENT on zedboard and zybo
  
  PR:   221208
  Submitted by: Thomas Skibo 

Modified:
  head/sys/boot/fdt/dts/arm/zedboard.dts
  head/sys/boot/fdt/dts/arm/zybo.dts

Modified: head/sys/boot/fdt/dts/arm/zedboard.dts
==
--- head/sys/boot/fdt/dts/arm/zedboard.dts  Thu Aug 24 01:23:33 2017
(r322826)
+++ head/sys/boot/fdt/dts/arm/zedboard.dts  Thu Aug 24 02:08:52 2017
(r322827)
@@ -30,7 +30,7 @@
 
 / {
model = "zedboard";
-   compatible = "digilent,zedboard";
+   compatible = "digilent,zedboard", "xlnx,zynq-7000";
 
memory {
// First megabyte isn't accessible by all interconnect masters.

Modified: head/sys/boot/fdt/dts/arm/zybo.dts
==
--- head/sys/boot/fdt/dts/arm/zybo.dts  Thu Aug 24 01:23:33 2017
(r322826)
+++ head/sys/boot/fdt/dts/arm/zybo.dts  Thu Aug 24 02:08:52 2017
(r322827)
@@ -30,7 +30,7 @@
 
 / {
model = "zybo";
-   compatible = "digilent,zybo";
+   compatible = "digilent,zybo", "xlnx,zynq-7000";
 
memory {
// First megabyte isn't accessible by all interconnect masters.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r320387 - head/sys/arm/arm

2017-06-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Jun 26 21:45:33 2017
New Revision: 320387
URL: https://svnweb.freebsd.org/changeset/base/320387

Log:
  [arm] Use correct index value when checking range validity
  
  Reviewed by:  andrew
  MFC after:3 weeks
  Differential Revision:https://reviews.freebsd.org/D9145

Modified:
  head/sys/arm/arm/gic.c

Modified: head/sys/arm/arm/gic.c
==
--- head/sys/arm/arm/gic.c  Mon Jun 26 21:14:33 2017(r320386)
+++ head/sys/arm/arm/gic.c  Mon Jun 26 21:45:33 2017(r320387)
@@ -1445,11 +1445,11 @@ arm_gicv2m_alloc_msi(device_t dev, device_t child, int
break;
}
 
-   KASSERT((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI)!= 0,
+   KASSERT((psc->gic_irqs[end_irq].gi_flags & 
GI_FLAG_MSI)!= 0,
("%s: Non-MSI interrupt found", __func__));
 
/* This is already used */
-   if ((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI_USED) ==
+   if ((psc->gic_irqs[end_irq].gi_flags & 
GI_FLAG_MSI_USED) ==
GI_FLAG_MSI_USED) {
found = false;
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r316376 - head/sys/boot/fdt/dts/arm

2017-04-01 Thread Oleksandr Tymoshenko
Emmanuel Vadot (m...@freebsd.org) wrote:
> Author: manu
> Date: Sat Apr  1 21:55:09 2017
> New Revision: 316376
> URL: https://svnweb.freebsd.org/changeset/base/316376
> 
> Log:
>   Reduce the diff on beaglebone-black DTS.
>   
>   The HDMI TX (tda19988) is already enabled in upstream DTS so use it directly
>   instead.
> 
> Modified:
>   head/sys/boot/fdt/dts/arm/beaglebone-black.dts

BBB switched to using upstream DTS. I don't think
sys/boot/fdt/dts/arm/beaglebone* files are used anywhere.

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316371 - head/sys/arm/versatile

2017-04-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Apr  1 20:38:12 2017
New Revision: 316371
URL: https://svnweb.freebsd.org/changeset/base/316371

Log:
  [versatilepb] Fix keyboard driver after switching to upstream DTS
  
  FreeBSD's DTS contained only one PL050 node and driver considered it to
  be PS/2 keyboard. In reality PL050 is a PS/2 port that pushes bytes to/from
  the periphers connected to it. New DTS contains two nodes and QEMU emulates
  keyboard connected to port #0 and mouse connected to port #1. Since there
  is no way to say what's connected to port by checking DTS we hardcode
  this knowledge in the driver: it assumes keyboard on port #0 and ignores
  port #1 altogether.
  
  Also QEMU defaults emulated keyboard to scan code set 2 while driver used
  to work with scan code set 1 so when initializing driver make sure keyboard
  is switched to scan code set 1

Modified:
  head/sys/arm/versatile/pl050.c

Modified: head/sys/arm/versatile/pl050.c
==
--- head/sys/arm/versatile/pl050.c  Sat Apr  1 20:10:08 2017
(r316370)
+++ head/sys/arm/versatile/pl050.c  Sat Apr  1 20:38:12 2017
(r316371)
@@ -106,7 +106,10 @@ __FBSDID("$FreeBSD$");
 #defineKMI_DRIVER_NAME  "kmi"
 #defineKMI_NFKEY(sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* 
units */
 
+#defineSET_SCANCODE_SET0xf0
+
 struct kmi_softc {
+   device_t sc_dev;
keyboard_t sc_kbd;
keymap_t sc_keymap;
accentmap_t sc_accmap;
@@ -142,6 +145,8 @@ static int  kmi_ioctl(keyboard_t *, u_lon
 static int kmi_enable(keyboard_t *);
 static int kmi_disable(keyboard_t *);
 
+static int kmi_attached = 0;
+
 /* early keyboard probe, not supported */
 static int
 kmi_configure(int flags)
@@ -480,7 +485,6 @@ kmi_ioctl(keyboard_t *kbd, u_long cmd, c
}
 }
 
-
 /* clear the internal state of the keyboard */
 static void
 kmi_clear_state(keyboard_t *kbd)
@@ -610,6 +614,17 @@ pl050_kmi_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
 
+   /*
+* PL050 is plain PS2 port that pushes bytes to/from computer
+* VersatilePB has two such ports and QEMU simulates keyboard
+* connected to port #0 and mouse connected to port #1. This
+* information can't be obtained from device tree so we just
+* hardcode this knowledge here. We attach keyboard driver to
+* port #0 and ignore port #1
+*/
+   if (kmi_attached)
+   return (ENXIO);
+
if (ofw_bus_is_compatible(dev, "arm,pl050")) {
device_set_desc(dev, "PL050 Keyboard/Mouse Interface");
return (BUS_PROBE_DEFAULT);
@@ -625,7 +640,9 @@ pl050_kmi_attach(device_t dev)
keyboard_t *kbd;
int rid;
int i;
+   uint32_t ack;
 
+   sc->sc_dev = dev;
kbd = &sc->sc_kbd;
rid = 0;
 
@@ -654,6 +671,16 @@ pl050_kmi_attach(device_t dev)
 
/* TODO: clock & divisor */
 
+   pl050_kmi_write_4(sc, KMICR, KMICR_EN);
+
+   pl050_kmi_write_4(sc, KMIDATA, SET_SCANCODE_SET);
+   /* read out ACK */
+   ack = pl050_kmi_read_4(sc, KMIDATA);
+   /* Set Scan Code set 1 (XT) */
+   pl050_kmi_write_4(sc, KMIDATA, 1);
+   /* read out ACK */
+   ack = pl050_kmi_read_4(sc, KMIDATA);
+
pl050_kmi_write_4(sc, KMICR, KMICR_EN | KMICR_RXINTREN);
 
kbd_init_struct(kbd, KMI_DRIVER_NAME, KB_OTHER, 
@@ -689,6 +716,7 @@ pl050_kmi_attach(device_t dev)
if (bootverbose) {
genkbd_diag(kbd, bootverbose);
}
+   kmi_attached = 1;
return (0);
 
 detach:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316370 - in head/sys/arm: arm conf versatile

2017-04-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Apr  1 20:10:08 2017
New Revision: 316370
URL: https://svnweb.freebsd.org/changeset/base/316370

Log:
  [versatilepb] Convert VERSATILEPB kernel to INTRNG and switch to upstream DTB
  
  Scope of this change is somewhat larger than just converting to INTRNG.
  The reason for this is that INTRNG support required switching from custom
  to upstream DTS because custom DTS didn't have interrup routing information.
  This switch caused rewrite of PCI and CLCD drivers and adding SCM module.
  List of changes in this commit:
  
  - Enable INTRNG and switch to versatile-pb.dts
  
  - Add SCM driver that controls various peripheral devices like LCD or
PCI controller. Previously registers required for power-up and
configuring peripherals were part of their respective nodes. Upstream
DTS has dedicated node for SCM
  
  - Convert PL190 driver to INTRNG
  
  - Convert Versatile SIC (secondary interrupt controller) to INTRNG
  
  - Refactor CLCD driver to use SCM API to power up and configuration
  
  - Refactor PCI driver to use SCM API to enable controller
  
  - Refactor PCI driver to use interrupt map provided in DTS for
interrupt routing. As a result it fixes broken IRQ routing and
it's no longer required to run QEMU with "-global 
versatile_pci.broken-irq-mapping=1"
command-line arguments

Added:
  head/sys/arm/versatile/versatile_scm.c   (contents, props changed)
  head/sys/arm/versatile/versatile_scm.h   (contents, props changed)
Modified:
  head/sys/arm/arm/pl190.c
  head/sys/arm/conf/VERSATILEPB
  head/sys/arm/versatile/files.versatile
  head/sys/arm/versatile/versatile_clcd.c
  head/sys/arm/versatile/versatile_pci.c
  head/sys/arm/versatile/versatile_sic.c

Modified: head/sys/arm/arm/pl190.c
==
--- head/sys/arm/arm/pl190.cSat Apr  1 19:27:06 2017(r316369)
+++ head/sys/arm/arm/pl190.cSat Apr  1 20:10:08 2017(r316370)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 Oleksandr Tymoshenko 
+ * Copyright (c) 2012-2017 Oleksandr Tymoshenko 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,6 @@
  * SUCH DAMAGE.
  */
 
-
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -34,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include "pic_if.h"
+
 #ifdef  DEBUG
 #define dprintf(fmt, args...) printf(fmt, ##args)
 #else
@@ -62,17 +64,139 @@ __FBSDID("$FreeBSD$");
 
 #defineVIC_NIRQS   32
 
+struct pl190_intc_irqsrc {
+   struct intr_irqsrc  isrc;
+   u_int   irq;
+};
+
 struct pl190_intc_softc {
-   device_tsc_dev;
+   device_tdev;
+   struct mtx  mtx;
struct resource *   intc_res;
+   struct pl190_intc_irqsrcisrcs[VIC_NIRQS];
 };
 
-static struct pl190_intc_softc *pl190_intc_sc = NULL;
+#defineINTC_VIC_READ_4(sc, reg)\
+bus_read_4(sc->intc_res, (reg))
+#defineINTC_VIC_WRITE_4(sc, reg, val)  \
+bus_write_4(sc->intc_res, (reg), (val))
+
+#defineVIC_LOCK(_sc) mtx_lock_spin(&(_sc)->mtx)
+#defineVIC_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->mtx)
+
+static inline void
+pl190_intc_irq_dispatch(struct pl190_intc_softc *sc, u_int irq,
+struct trapframe *tf)
+{
+   struct pl190_intc_irqsrc *src;
+
+   src = &sc->isrcs[irq];
+   if (intr_isrc_dispatch(&src->isrc, tf) != 0)
+   device_printf(sc->dev, "Stray irq %u detected\n", irq);
+}
+
+static int
+pl190_intc_intr(void *arg)
+{
+   struct pl190_intc_softc *sc;
+   u_int cpu;
+   uint32_t num, pending;
+   struct trapframe *tf;
+
+   sc = arg;
+   cpu = PCPU_GET(cpuid);
+   tf = curthread->td_intr_frame;
+
+   VIC_LOCK(sc);
+   pending = INTC_VIC_READ_4(sc, VICIRQSTATUS);
+   VIC_UNLOCK(sc);
+   for (num = 0 ; num < VIC_NIRQS; num++) {
+   if (pending & (1 << num))
+   pl190_intc_irq_dispatch(sc, num, tf);
+   }
+
+   return (FILTER_HANDLED);
+}
+
+static void
+pl190_intc_disable_intr(device_t dev, struct intr_irqsrc *isrc)
+{
+   struct pl190_intc_softc *sc;
+   struct pl190_intc_irqsrc *src;
+
+   sc = device_get_softc(dev);
+   src = (struct pl190_intc_irqsrc *)isrc;
+
+   VIC_LOCK(sc);
+   INTC_VIC_WRITE_4(sc, VICINTENCLEAR, (1 << src->irq));
+   VIC_UNLOCK(sc);
+}
+
+static void
+pl190_intc_enable_intr(device_t dev, struct intr_irqsrc *isrc)
+{
+   struct pl190_intc_softc *sc;
+   struct pl190_intc_irqsrc *src;
 
-#defineintc_vic_read_4(reg)\
-bus_read_4(p

svn commit: r316306 - head/sys/arm/ti/am335x

2017-03-30 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Mar 30 21:54:57 2017
New Revision: 316306
URL: https://svnweb.freebsd.org/changeset/base/316306

Log:
  [am335x] Fix HDMI suport for Beaglebone Black
  
  Fallback to Linux video interface bindings introduced in r313068 worked
  with then current DTS but that DTS turned out to be not conformant to
  the the bindings spec. DTS import in r314854 fixed the conformancy but
  broke the functionality. This commit syncs up functionality to the actual
  spec.
  
  Reported by:  manu@

Modified:
  head/sys/arm/ti/am335x/am335x_lcd.c

Modified: head/sys/arm/ti/am335x/am335x_lcd.c
==
--- head/sys/arm/ti/am335x/am335x_lcd.c Thu Mar 30 21:39:03 2017
(r316305)
+++ head/sys/arm/ti/am335x/am335x_lcd.c Thu Mar 30 21:54:57 2017
(r316306)
@@ -342,7 +342,7 @@ am335x_mode_is_valid(const struct videom
 static void
 am335x_read_hdmi_property(device_t dev)
 {
-   phandle_t node;
+   phandle_t node, xref;
phandle_t endpoint;
phandle_t hdmi_xref;
struct am335x_lcd_softc *sc;
@@ -372,13 +372,15 @@ am335x_read_hdmi_property(device_t dev)
return;
 
for (endpoint = OF_child(node); endpoint != 0; endpoint = 
OF_peer(endpoint)) {
-   if (OF_getencprop(endpoint, "remote-endpoint", &node, 
sizeof(node)) != -1) {
-   /* port node of remote endpoint */
-   node = OF_node_from_xref(node);
-   /* port/ node */
+   if (OF_getencprop(endpoint, "remote-endpoint", &xref, 
sizeof(xref)) != -1) {
+   /* port/port@0/endpoint@0 */
+   node = OF_node_from_xref(xref);
+   /* port/port@0 */
node = OF_parent(node);
-   /* actual owner of port/endpoint, in our case HDMI 
framer */
-   sc->sc_hdmi_framer = OF_parent(node);
+   /* port */
+   node = OF_parent(node);
+   /* actual owner of port, in our case HDMI framer */
+   sc->sc_hdmi_framer = OF_xref_from_node(OF_parent(node));
if (sc->sc_hdmi_framer != 0)
return;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315967 - head/sys/arm/broadcom/bcm2835

2017-03-25 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Mar 25 22:58:37 2017
New Revision: 315967
URL: https://svnweb.freebsd.org/changeset/base/315967

Log:
  [rpi] Use compatibility string from upstream DTB for I2C controller
  
  FreeBSD uses upstream DTB for RPi3 build and compatibility string for
  i2c device is different there. Add this new string to compatibility data.
  
  Reported by:  Karl Denninger
  MFC after:3 days

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sat Mar 25 22:07:21 2017
(r315966)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sat Mar 25 22:58:37 2017
(r315967)
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
 static struct ofw_compat_data compat_data[] = {
{"broadcom,bcm2835-bsc",1},
{"brcm,bcm2708-i2c",1},
+   {"brcm,bcm2835-i2c",1},
{NULL,  0}
 };
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315178 - head/sys/dev/evdev

2017-03-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Mar 12 19:28:44 2017
New Revision: 315178
URL: https://svnweb.freebsd.org/changeset/base/315178

Log:
  [evdev] Fix Right Alt and Keypad Enter event codes for atkbd(4) and kbdmux(4) 
drivers
  
  Submitted by: Vladimir Kondratiev 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9320

Modified:
  head/sys/dev/evdev/evdev_utils.c

Modified: head/sys/dev/evdev/evdev_utils.c
==
--- head/sys/dev/evdev/evdev_utils.cSun Mar 12 19:27:44 2017
(r315177)
+++ head/sys/dev/evdev/evdev_utils.cSun Mar 12 19:28:44 2017
(r315178)
@@ -159,7 +159,7 @@ static uint16_t evdev_at_set1_scancodes[
KEY_PREVIOUSSONG,   NONE,   NONE,   NONE,
NONE,   NONE,   NONE,   NONE,
NONE,   KEY_NEXTSONG,   NONE,   NONE,
-   NONE,   KEY_KPENTER,KEY_RIGHTCTRL,  NONE,
+   KEY_KPENTER,KEY_RIGHTCTRL,  NONE,   NONE,
/* 0x20 - 0x3f. 0xE0 prefixed */
KEY_MUTE,   KEY_CALC,   KEY_PLAYPAUSE,  NONE,
KEY_STOPCD, NONE,   NONE,   NONE,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315177 - head/sys/dev/evdev

2017-03-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Mar 12 19:27:44 2017
New Revision: 315177
URL: https://svnweb.freebsd.org/changeset/base/315177

Log:
  [evdev] Fix race condition between client's event queue reading and dropping
  
  Submitted by: Vladimir Kondratiev 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9320

Modified:
  head/sys/dev/evdev/cdev.c

Modified: head/sys/dev/evdev/cdev.c
==
--- head/sys/dev/evdev/cdev.c   Sun Mar 12 19:26:24 2017(r315176)
+++ head/sys/dev/evdev/cdev.c   Sun Mar 12 19:27:44 2017(r315177)
@@ -162,7 +162,7 @@ static int
 evdev_read(struct cdev *dev, struct uio *uio, int ioflag)
 {
struct evdev_client *client;
-   struct input_event *event;
+   struct input_event event;
int ret = 0;
int remaining;
 
@@ -197,13 +197,14 @@ evdev_read(struct cdev *dev, struct uio 
}
 
while (ret == 0 && !EVDEV_CLIENT_EMPTYQ(client) && remaining > 0) {
-   event = &client->ec_buffer[client->ec_buffer_head];
+   memcpy(&event, &client->ec_buffer[client->ec_buffer_head],
+   sizeof(struct input_event));
client->ec_buffer_head =
(client->ec_buffer_head + 1) % client->ec_buffer_size;
remaining--;
 
EVDEV_CLIENT_UNLOCKQ(client);
-   ret = uiomove(event, sizeof(struct input_event), uio);
+   ret = uiomove(&event, sizeof(struct input_event), uio);
EVDEV_CLIENT_LOCKQ(client);
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315176 - head/sys/dev/evdev

2017-03-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Mar 12 19:26:24 2017
New Revision: 315176
URL: https://svnweb.freebsd.org/changeset/base/315176

Log:
  [evdev] Do not ignore result evdev_register in UI_DEV_CREATE handler
  
  Make sure that uinput state field reflects actual state by checking
  evdev_register result for errors
  
  Submitted by: Vladimir Kondratiev 
  Differential Revision:https://reviews.freebsd.org/D9320

Modified:
  head/sys/dev/evdev/uinput.c

Modified: head/sys/dev/evdev/uinput.c
==
--- head/sys/dev/evdev/uinput.c Sun Mar 12 18:59:16 2017(r315175)
+++ head/sys/dev/evdev/uinput.c Sun Mar 12 19:26:24 2017(r315176)
@@ -501,9 +501,10 @@ uinput_ioctl_sub(struct uinput_cdev_stat
 
evdev_set_methods(state->ucs_evdev, state, &uinput_ev_methods);
evdev_set_flag(state->ucs_evdev, EVDEV_FLAG_SOFTREPEAT);
-   evdev_register(state->ucs_evdev);
-   state->ucs_state = UINPUT_RUNNING;
-   return (0);
+   ret = evdev_register(state->ucs_evdev);
+   if (ret == 0)
+   state->ucs_state = UINPUT_RUNNING;
+   return (ret);
 
case UI_DEV_DESTROY:
if (state->ucs_state != UINPUT_RUNNING)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315031 - head/sys/tools/fdt

2017-03-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Mar 10 22:45:07 2017
New Revision: 315031
URL: https://svnweb.freebsd.org/changeset/base/315031

Log:
  [fdt] Make DTBs generated by make_dtb.sh overlay-ready
  
  Generate symbols node when compiling dts files so they can be modified
  during boot-time by applying overlays.

Modified:
  head/sys/tools/fdt/make_dtb.sh

Modified: head/sys/tools/fdt/make_dtb.sh
==
--- head/sys/tools/fdt/make_dtb.sh  Fri Mar 10 21:09:33 2017
(r315030)
+++ head/sys/tools/fdt/make_dtb.sh  Fri Mar 10 22:45:07 2017
(r315031)
@@ -20,5 +20,5 @@ for d in ${dts}; do
 dtb=${dtb_path}/`basename $d .dts`.dtb
 echo "converting $d -> $dtb"
 cpp -P -x assembler-with-cpp -I $S/gnu/dts/include -I 
$S/boot/fdt/dts/${MACHINE} -I $S/gnu/dts/${MACHINE} -include $d /dev/null | 
-   dtc -O dtb -o $dtb -b 0 -p 1024 -i $S/boot/fdt/dts/${MACHINE} -i 
$S/gnu/dts/${MACHINE}
+   dtc -@ -O dtb -o $dtb -b 0 -p 1024 -i $S/boot/fdt/dts/${MACHINE} -i 
$S/gnu/dts/${MACHINE}
 done
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315019 - head/sys/boot/fdt

2017-03-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Mar 10 19:15:57 2017
New Revision: 315019
URL: https://svnweb.freebsd.org/changeset/base/315019

Log:
  [loader][fdt] Fix applying overlays without __local_fixups__ node
  
  Do not return error if __local_fixups__ node is missing in DTB overlay
  because local fixup data is optional.
  
  Reported by:  Manuel Stuhn
  MFC after:1 week

Modified:
  head/sys/boot/fdt/fdt_overlay.c

Modified: head/sys/boot/fdt/fdt_overlay.c
==
--- head/sys/boot/fdt/fdt_overlay.c Fri Mar 10 19:13:38 2017
(r315018)
+++ head/sys/boot/fdt/fdt_overlay.c Fri Mar 10 19:15:57 2017
(r315019)
@@ -358,21 +358,26 @@ static int
 fdt_overlay_do_local_fixups(void *main_fdtp, void *overlay_fdtp)
 {
int overlay_local_fixups_o;
-   int len;
+   int len, rv;
const char *fixups;
uint32_t phandle_offset;
 
overlay_local_fixups_o = fdt_path_offset(overlay_fdtp, 
"/__local_fixups__");
 
-   if (overlay_local_fixups_o < 0)
-   return (-1);
+   if (overlay_local_fixups_o < 0) {
+   /* If not local fixups - do nothing */
+   if (overlay_local_fixups_o == -FDT_ERR_NOTFOUND)
+   return (0);
+   return (overlay_local_fixups_o);
+   }
 
phandle_offset = fdt_max_phandle(main_fdtp);
fdt_increase_phandles(overlay_fdtp, phandle_offset);
fixups = fdt_getprop_w(overlay_fdtp, overlay_local_fixups_o, "fixup", 
&len);
if (fixups) {
-   if (fdt_do_local_fixup(overlay_fdtp, fixups, len, 
phandle_offset) < 0)
-   return (-1);
+   rv = fdt_do_local_fixup(overlay_fdtp, fixups, len, 
phandle_offset);
+   if (rv < 0)
+   return (rv);
}
 
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315010 - head/gnu/usr.bin/dtc

2017-03-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Mar 10 17:37:55 2017
New Revision: 315010
URL: https://svnweb.freebsd.org/changeset/base/315010

Log:
  [dtc] regenerate version file if upstream Makefile has been changed
  
  Keep version file in sync by adding dependency to upstream Makefile

Modified:
  head/gnu/usr.bin/dtc/Makefile

Modified: head/gnu/usr.bin/dtc/Makefile
==
--- head/gnu/usr.bin/dtc/Makefile   Fri Mar 10 17:36:05 2017
(r315009)
+++ head/gnu/usr.bin/dtc/Makefile   Fri Mar 10 17:37:55 2017
(r315010)
@@ -34,7 +34,7 @@ OBJS+= dtc-parser.tab.o dtc-lexer.lex.o
 CLEANFILES+= dtc-parser.tab.o dtc-lexer.lex.o dtc-parser.tab.c \
dtc-parser.tab.h dtc-lexer.lex.c ${DTCVERSIONFILE}
 
-${DTCVERSIONFILE}:
+${DTCVERSIONFILE}: ${DTCDIR}/Makefile
@echo '#define DTC_VERSION "DTC ${DTCVERSION}"' > ${DTCVERSIONFILE}
 
 dtc-parser.tab.o:  dtc-parser.tab.c dtc-parser.tab.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r315009 - in head/contrib/dtc: . Documentation libfdt scripts

2017-03-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Mar 10 17:36:05 2017
New Revision: 315009
URL: https://svnweb.freebsd.org/changeset/base/315009

Log:
  Merge from vendor branch importing dtc 1.4.3
  
  Major new feature in this import is FDT overlay support

Added:
  head/contrib/dtc/Documentation/dt-object-internal.txt
 - copied unchanged from r314985, 
vendor/dtc/dist/Documentation/dt-object-internal.txt
  head/contrib/dtc/README
 - copied unchanged from r314985, vendor/dtc/dist/README
  head/contrib/dtc/libfdt/fdt_addresses.c
 - copied unchanged from r314985, vendor/dtc/dist/libfdt/fdt_addresses.c
  head/contrib/dtc/libfdt/fdt_overlay.c
 - copied unchanged from r314985, vendor/dtc/dist/libfdt/fdt_overlay.c
  head/contrib/dtc/scripts/kup-dtc
 - copied unchanged from r314985, vendor/dtc/dist/scripts/kup-dtc
Modified:
  head/contrib/dtc/Documentation/manual.txt
  head/contrib/dtc/Makefile
  head/contrib/dtc/checks.c
  head/contrib/dtc/data.c
  head/contrib/dtc/dtc-lexer.l
  head/contrib/dtc/dtc-parser.y
  head/contrib/dtc/dtc.c
  head/contrib/dtc/dtc.h
  head/contrib/dtc/fdtdump.c
  head/contrib/dtc/fdtget.c
  head/contrib/dtc/fdtput.c
  head/contrib/dtc/flattree.c
  head/contrib/dtc/fstree.c
  head/contrib/dtc/libfdt/Makefile.libfdt
  head/contrib/dtc/libfdt/fdt.c
  head/contrib/dtc/libfdt/fdt_ro.c
  head/contrib/dtc/libfdt/fdt_rw.c
  head/contrib/dtc/libfdt/fdt_strerror.c
  head/contrib/dtc/libfdt/fdt_wip.c
  head/contrib/dtc/libfdt/libfdt.h
  head/contrib/dtc/libfdt/libfdt_env.h
  head/contrib/dtc/libfdt/libfdt_internal.h
  head/contrib/dtc/libfdt/version.lds
  head/contrib/dtc/livetree.c
  head/contrib/dtc/srcpos.c
  head/contrib/dtc/srcpos.h
  head/contrib/dtc/treesource.c
  head/contrib/dtc/util.c
  head/contrib/dtc/util.h
Directory Properties:
  head/contrib/dtc/   (props changed)

Copied: head/contrib/dtc/Documentation/dt-object-internal.txt (from r314985, 
vendor/dtc/dist/Documentation/dt-object-internal.txt)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/contrib/dtc/Documentation/dt-object-internal.txt   Fri Mar 10 
17:36:05 2017(r315009, copy of r314985, 
vendor/dtc/dist/Documentation/dt-object-internal.txt)
@@ -0,0 +1,310 @@
+Device Tree Dynamic Object format internals
+---
+
+The Device Tree for most platforms is a static representation of
+the hardware capabilities. This is insufficient for platforms
+that need to dynamically insert Device Tree fragments into the
+live tree.
+
+This document explains the the Device Tree object format and
+modifications made to the Device Tree compiler, which make it possible.
+
+1. Simplified Problem Definition
+
+
+Assume we have a platform which boots using following simplified Device Tree.
+
+ foo.dts -
+   /* FOO platform */
+   / {
+   compatible = "corp,foo";
+
+   /* shared resources */
+   res: res {
+   };
+
+   /* On chip peripherals */
+   ocp: ocp {
+   /* peripherals that are always instantiated */
+   peripheral1 { ... };
+   };
+   };
+ foo.dts -
+
+We have a number of peripherals that after probing (using some undefined 
method)
+should result in different Device Tree configuration.
+
+We cannot boot with this static tree because due to the configuration of the
+foo platform there exist multiple conficting peripherals DT fragments.
+
+So for the bar peripheral we would have this:
+
+ foo+bar.dts -
+   /* FOO platform + bar peripheral */
+   / {
+   compatible = "corp,foo";
+
+   /* shared resources */
+   res: res {
+   };
+
+   /* On chip peripherals */
+   ocp: ocp {
+   /* peripherals that are always instantiated */
+   peripheral1 { ... };
+
+   /* bar peripheral */
+   bar {
+   compatible = "corp,bar";
+   ... /* various properties and child nodes */
+   };
+   };
+   };
+ foo+bar.dts -
+
+While for the baz peripheral we would have this:
+
+ foo+baz.dts -
+   /* FOO platform + baz peripheral */
+   / {
+   compatible = "corp,foo";
+
+   /* shared resources */
+   res: res {
+   /* baz resources */
+   baz_res: res_baz { ... };
+   };
+
+   /* 

svn commit: r314934 - in head/sys/modules: . spigen

2017-03-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Mar  9 01:21:28 2017
New Revision: 314934
URL: https://svnweb.freebsd.org/changeset/base/314934

Log:
  [spigen] Add spigen module
  
  spigen provides userland API to SPI bus. Make it available as a loadable
  module so people using official ARM images can enabled it on devices like
  BBB or RPi without re-building kernel
  
  MFC after:1 week

Added:
  head/sys/modules/spigen/
  head/sys/modules/spigen/Makefile   (contents, props changed)
Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Thu Mar  9 01:00:27 2017(r314933)
+++ head/sys/modules/Makefile   Thu Mar  9 01:21:28 2017(r314934)
@@ -346,6 +346,7 @@ SUBDIR= \
snp \
sound \
${_speaker} \
+   spigen \
${_splash} \
${_sppp} \
ste \

Added: head/sys/modules/spigen/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/modules/spigen/MakefileThu Mar  9 01:21:28 2017
(r314934)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH: ${SRCTOP}/sys/dev/spibus
+KMOD=  spigen
+SRCS=  spigen.c
+SRCS+= device_if.h bus_if.h opt_platform.h spibus_if.h
+
+.include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r314933 - head/sys/dev/spibus

2017-03-08 Thread Oleksandr Tymoshenko
Konstantin Belousov (kostik...@gmail.com) wrote:
> On Thu, Mar 09, 2017 at 01:00:27AM +0000, Oleksandr Tymoshenko wrote:
> > Author: gonzo
> > Date: Thu Mar  9 01:00:27 2017
> > New Revision: 314933
> > URL: https://svnweb.freebsd.org/changeset/base/314933
> > 
> > Log:
> >   [spigen] make spigen device ready to be compiled as a module
> >   
> >   - Add flag to indicate that device is opened by userland
> >   - Replace "always fail" detach method with proper detach implementation
> >   
> >   MFC after:1 week
> > 
> > Modified:
> >   head/sys/dev/spibus/spigen.c
> > 
> > Modified: head/sys/dev/spibus/spigen.c
> > ==
> > --- head/sys/dev/spibus/spigen.cThu Mar  9 00:58:21 2017
> > (r314932)
> > +++ head/sys/dev/spibus/spigen.cThu Mar  9 01:00:27 2017
> > (r314933)
> > @@ -53,6 +53,9 @@ __FBSDID("$FreeBSD$");
> >  
> >  #include "spibus_if.h"
> >  
> > +#defineSPIGEN_OPEN (1 << 0)
> > +#defineSPIGEN_MMAP_BUSY(1 << 1)
> > +
> >  struct spigen_softc {
> > device_t sc_dev;
> > struct cdev *sc_cdev;
> > @@ -63,8 +66,8 @@ struct spigen_softc {
> > vm_object_t sc_mmap_buffer; /* command, then data */
> > vm_offset_t sc_mmap_kvaddr;
> > size_t sc_mmap_buffer_size;
> > -   int sc_mmap_busy;
> > int sc_debug;
> > +   int sc_flags;
> >  };
> >  
> >  #ifdef FDT
> > @@ -191,10 +194,24 @@ spigen_attach(device_t dev)
> >  }
> >  
> >  static int 
> > -spigen_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
> > +spigen_open(struct cdev *cdev, int oflags, int devtype, struct thread *td)
> >  {
> > +   int error;
> > +   device_t dev;
> > +   struct spigen_softc *sc;
> >  
> > -   return (0);
> > +   error = 0;
> > +   dev = cdev->si_drv1;
> > +   sc = device_get_softc(dev);
> > +
> > +   mtx_lock(&sc->sc_mtx);
> > +   if (sc->sc_flags & SPIGEN_OPEN)
> > +   error = EBUSY;
> > +   else
> > +   sc->sc_flags |= SPIGEN_OPEN;
> > +   mtx_unlock(&sc->sc_mtx);
> > +
> > +   return (error);
> >  }
> >  
> >  static int
> > @@ -264,7 +281,7 @@ spigen_transfer_mmapped(struct cdev *cde
> > int error = 0;
> >  
> > mtx_lock(&sc->sc_mtx);
> > -   if (sc->sc_mmap_busy)
> > +   if (sc->sc_flags & SPIGEN_MMAP_BUSY)
> > error = EBUSY;
> > else if (stm->stm_command_length > sc->sc_command_length_max ||
> > stm->stm_data_length > sc->sc_data_length_max)
> > @@ -275,7 +292,7 @@ spigen_transfer_mmapped(struct cdev *cde
> > stm->stm_command_length + stm->stm_data_length)
> > error = ENOMEM;
> > if (error == 0)
> > -   sc->sc_mmap_busy = 1;
> > +   sc->sc_flags |= SPIGEN_MMAP_BUSY;
> > mtx_unlock(&sc->sc_mtx);
> > if (error)
> > return (error);
> > @@ -288,8 +305,8 @@ spigen_transfer_mmapped(struct cdev *cde
> > error = SPIBUS_TRANSFER(device_get_parent(dev), dev, &transfer);
> >  
> > mtx_lock(&sc->sc_mtx);
> > -   KASSERT(sc->sc_mmap_busy, ("mmap no longer marked busy"));
> > -   sc->sc_mmap_busy = 0;
> > +   KASSERT((sc->sc_flags & SPIGEN_MMAP_BUSY), ("mmap no longer marked 
> > busy"));
> > +   sc->sc_flags &= ~(SPIGEN_MMAP_BUSY);
> > mtx_unlock(&sc->sc_mtx);
> > return (error);
> >  }
> > @@ -391,6 +408,7 @@ spigen_close(struct cdev *cdev, int ffla
> > sc->sc_mmap_buffer = NULL;
> > sc->sc_mmap_buffer_size = 0;
> > }
> > +   sc->sc_flags &= ~(SPIGEN_OPEN);
> > mtx_unlock(&sc->sc_mtx);
> > return (0);
> >  }
> > @@ -398,8 +416,23 @@ spigen_close(struct cdev *cdev, int ffla
> >  static int
> >  spigen_detach(device_t dev)
> >  {
> > +   struct spigen_softc *sc;
> > +
> > +   sc = device_get_softc(dev);
> > +
> > +   mtx_lock(&sc->sc_mtx);
> > +   if (sc->sc_flags & SPIGEN_OPEN) {
> > +   mtx_unlock(&sc->sc_mtx);
> > +   return (EBUSY);
> > +   }
> > +   mtx_unlock(&sc->sc_mtx);
> This does not really work, since another thread might have already
> started executing open, but did not executed enough to set the flag. The
> destroy_dev(9) KPI guarantees that there is no other threads calling
> into devsw methods when the device is teared down. If you need to do an
> additional cleanup, do it after the call to destroy_dev().
> 
> BTW, since si_drv1 + open are used, you might close the usual race with
> the make_dev_s(9) KPI.

Thanks for the pointers, I'll clean up this code in next iteration.

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314933 - head/sys/dev/spibus

2017-03-08 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Mar  9 01:00:27 2017
New Revision: 314933
URL: https://svnweb.freebsd.org/changeset/base/314933

Log:
  [spigen] make spigen device ready to be compiled as a module
  
  - Add flag to indicate that device is opened by userland
  - Replace "always fail" detach method with proper detach implementation
  
  MFC after:1 week

Modified:
  head/sys/dev/spibus/spigen.c

Modified: head/sys/dev/spibus/spigen.c
==
--- head/sys/dev/spibus/spigen.cThu Mar  9 00:58:21 2017
(r314932)
+++ head/sys/dev/spibus/spigen.cThu Mar  9 01:00:27 2017
(r314933)
@@ -53,6 +53,9 @@ __FBSDID("$FreeBSD$");
 
 #include "spibus_if.h"
 
+#defineSPIGEN_OPEN (1 << 0)
+#defineSPIGEN_MMAP_BUSY(1 << 1)
+
 struct spigen_softc {
device_t sc_dev;
struct cdev *sc_cdev;
@@ -63,8 +66,8 @@ struct spigen_softc {
vm_object_t sc_mmap_buffer; /* command, then data */
vm_offset_t sc_mmap_kvaddr;
size_t sc_mmap_buffer_size;
-   int sc_mmap_busy;
int sc_debug;
+   int sc_flags;
 };
 
 #ifdef FDT
@@ -191,10 +194,24 @@ spigen_attach(device_t dev)
 }
 
 static int 
-spigen_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
+spigen_open(struct cdev *cdev, int oflags, int devtype, struct thread *td)
 {
+   int error;
+   device_t dev;
+   struct spigen_softc *sc;
 
-   return (0);
+   error = 0;
+   dev = cdev->si_drv1;
+   sc = device_get_softc(dev);
+
+   mtx_lock(&sc->sc_mtx);
+   if (sc->sc_flags & SPIGEN_OPEN)
+   error = EBUSY;
+   else
+   sc->sc_flags |= SPIGEN_OPEN;
+   mtx_unlock(&sc->sc_mtx);
+
+   return (error);
 }
 
 static int
@@ -264,7 +281,7 @@ spigen_transfer_mmapped(struct cdev *cde
int error = 0;
 
mtx_lock(&sc->sc_mtx);
-   if (sc->sc_mmap_busy)
+   if (sc->sc_flags & SPIGEN_MMAP_BUSY)
error = EBUSY;
else if (stm->stm_command_length > sc->sc_command_length_max ||
stm->stm_data_length > sc->sc_data_length_max)
@@ -275,7 +292,7 @@ spigen_transfer_mmapped(struct cdev *cde
stm->stm_command_length + stm->stm_data_length)
error = ENOMEM;
if (error == 0)
-   sc->sc_mmap_busy = 1;
+   sc->sc_flags |= SPIGEN_MMAP_BUSY;
mtx_unlock(&sc->sc_mtx);
if (error)
return (error);
@@ -288,8 +305,8 @@ spigen_transfer_mmapped(struct cdev *cde
error = SPIBUS_TRANSFER(device_get_parent(dev), dev, &transfer);
 
mtx_lock(&sc->sc_mtx);
-   KASSERT(sc->sc_mmap_busy, ("mmap no longer marked busy"));
-   sc->sc_mmap_busy = 0;
+   KASSERT((sc->sc_flags & SPIGEN_MMAP_BUSY), ("mmap no longer marked 
busy"));
+   sc->sc_flags &= ~(SPIGEN_MMAP_BUSY);
mtx_unlock(&sc->sc_mtx);
return (error);
 }
@@ -391,6 +408,7 @@ spigen_close(struct cdev *cdev, int ffla
sc->sc_mmap_buffer = NULL;
sc->sc_mmap_buffer_size = 0;
}
+   sc->sc_flags &= ~(SPIGEN_OPEN);
mtx_unlock(&sc->sc_mtx);
return (0);
 }
@@ -398,8 +416,23 @@ spigen_close(struct cdev *cdev, int ffla
 static int
 spigen_detach(device_t dev)
 {
+   struct spigen_softc *sc;
+
+   sc = device_get_softc(dev);
+
+   mtx_lock(&sc->sc_mtx);
+   if (sc->sc_flags & SPIGEN_OPEN) {
+   mtx_unlock(&sc->sc_mtx);
+   return (EBUSY);
+   }
+   mtx_unlock(&sc->sc_mtx);
 
-   return (EIO);
+   mtx_destroy(&sc->sc_mtx);
+
+if (sc->sc_cdev)
+destroy_dev(sc->sc_cdev);
+   
+   return (0);
 }
 
 static devclass_t spigen_devclass;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314672 - head/sys/arm/broadcom/bcm2835

2017-03-04 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Mar  4 17:34:36 2017
New Revision: 314672
URL: https://svnweb.freebsd.org/changeset/base/314672

Log:
  [rpi] rpi3 should use the same cpufreq logic as rpi2, not rpi-b
  
  RPi3 cpufreq is more like that on RPi2. Setting arm frequency
  above min (say, "sysctl hw.cpufreq.arm_freq=60001") turns on
  turbo mode, and the firmware automatically raises voltage, sets
  frequency to max 1200MHz, and throttle when overheat, etc.
  
  Swap if/else parts and use SOC_BCM2835 def so RPi3 can share the
  same cpufreq logic as RPi2, instead of falling to that for RPi.
  
  Submitted by: Jia-Shiun Li 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9640

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Sat Mar  4 16:59:55 
2017(r314671)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c Sat Mar  4 17:34:36 
2017(r314672)
@@ -66,16 +66,16 @@ __FBSDID("$FreeBSD$");
 #defineHZ2MHZ(freq) ((freq) / (1000 * 1000))
 #defineMHZ2HZ(freq) ((freq) * (1000 * 1000))
 
-#ifdef SOC_BCM2836
-#defineOFFSET2MVOLT(val) (((val) / 1000))
-#defineMVOLT2OFFSET(val) (((val) * 1000))
-#defineDEFAULT_ARM_FREQUENCY600
-#defineDEFAULT_LOWEST_FREQ  600
-#else
+#ifdef SOC_BCM2835
 #defineOFFSET2MVOLT(val) (1200 + ((val) * 25))
 #defineMVOLT2OFFSET(val) (((val) - 1200) / 25)
 #defineDEFAULT_ARM_FREQUENCY700
 #defineDEFAULT_LOWEST_FREQ  300
+#else
+#defineOFFSET2MVOLT(val) (((val) / 1000))
+#defineMVOLT2OFFSET(val) (((val) * 1000))
+#defineDEFAULT_ARM_FREQUENCY600
+#defineDEFAULT_LOWEST_FREQ  600
 #endif
 #defineDEFAULT_CORE_FREQUENCY   250
 #defineDEFAULT_SDRAM_FREQUENCY  400
@@ -1544,7 +1544,20 @@ bcm2835_cpufreq_make_freq_list(device_t 
if (min_freq > cpufreq_lowest_freq)
min_freq = cpufreq_lowest_freq;
 
-#ifdef SOC_BCM2836
+#ifdef SOC_BCM2835
+   /* from freq to min_freq */
+   for (idx = 0; idx < *count && freq >= min_freq; idx++) {
+   if (freq > sc->arm_min_freq)
+   volts = sc->max_voltage_core;
+   else
+   volts = sc->min_voltage_core;
+   sets[idx].freq = freq;
+   sets[idx].volts = volts;
+   sets[idx].lat = TRANSITION_LATENCY;
+   sets[idx].dev = dev;
+   freq -= MHZSTEP;
+   }
+#else
/* XXX RPi2 have only 900/600MHz */
idx = 0;
volts = sc->min_voltage_core;
@@ -1560,19 +1573,6 @@ bcm2835_cpufreq_make_freq_list(device_t 
sets[idx].dev = dev;
idx++;
}
-#else
-   /* from freq to min_freq */
-   for (idx = 0; idx < *count && freq >= min_freq; idx++) {
-   if (freq > sc->arm_min_freq)
-   volts = sc->max_voltage_core;
-   else
-   volts = sc->min_voltage_core;
-   sets[idx].freq = freq;
-   sets[idx].volts = volts;
-   sets[idx].lat = TRANSITION_LATENCY;
-   sets[idx].dev = dev;
-   freq -= MHZSTEP;
-   }
 #endif
*count = idx;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r314535 - in head/sys/modules: bytgpio intelspi

2017-03-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Mar  2 03:19:39 2017
New Revision: 314535
URL: https://svnweb.freebsd.org/changeset/base/314535

Log:
  [intelspi][bytgio] Fix buildworld with MODULES_WITH_WORLD set
  
  Add opt_platform.h and opt_acpi.h to the dependencies so modules can be
  built as a part of buildworld when MODULES_WITH_WORLD is set
  
  Reported by:  Andre Albsmeier (for 11-stable)
  MFC after:1 day

Modified:
  head/sys/modules/bytgpio/Makefile
  head/sys/modules/intelspi/Makefile

Modified: head/sys/modules/bytgpio/Makefile
==
--- head/sys/modules/bytgpio/Makefile   Thu Mar  2 02:10:59 2017
(r314534)
+++ head/sys/modules/bytgpio/Makefile   Thu Mar  2 03:19:39 2017
(r314535)
@@ -3,6 +3,6 @@
 .PATH: ${.CURDIR}/../../dev/gpio
 KMOD=  bytgpio
 SRCS=  bytgpio.c
-SRCS+= acpi_if.h device_if.h bus_if.h gpio_if.h
+SRCS+= acpi_if.h device_if.h bus_if.h gpio_if.h opt_acpi.h opt_platform.h
 
 .include 

Modified: head/sys/modules/intelspi/Makefile
==
--- head/sys/modules/intelspi/Makefile  Thu Mar  2 02:10:59 2017
(r314534)
+++ head/sys/modules/intelspi/Makefile  Thu Mar  2 03:19:39 2017
(r314535)
@@ -3,6 +3,6 @@
 .PATH: ${.CURDIR}/../../dev/intel
 KMOD=  intelspi
 SRCS=  spi.c
-SRCS+= acpi_if.h device_if.h bus_if.h spibus_if.h
+SRCS+= acpi_if.h device_if.h bus_if.h opt_acpi.h spibus_if.h
 
 .include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313757 - head/sys/dev/atkbdc

2017-02-14 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Feb 15 02:52:43 2017
New Revision: 313757
URL: https://svnweb.freebsd.org/changeset/base/313757

Log:
  [psm] Fix calculation for clickpad softbuttons at the top
  
  On laptops like the ThinkPad X240, ClickPad buttons are located at the
  top. The hw.psm.synaptics.softbuttons_y sysctl was supposed to allow this
  by setting the value to a negative one (e.g. -1700). However, the
  condition was wrong (double negative), and doing that placed the buttons
  in an unreachable area.
  
  PR:   216342
  Submitted by: Greg V 
  MFC after:1 week

Modified:
  head/sys/dev/atkbdc/psm.c

Modified: head/sys/dev/atkbdc/psm.c
==
--- head/sys/dev/atkbdc/psm.c   Wed Feb 15 01:50:58 2017(r313756)
+++ head/sys/dev/atkbdc/psm.c   Wed Feb 15 02:52:43 2017(r313757)
@@ -3194,7 +3194,7 @@ psmgestures(struct psm_softc *sc, finger
if (sc->synhw.capClickPad && ms->button & MOUSE_BUTTON1DOWN) {
y_ok = sc->syninfo.softbuttons_y >= 0 ?
start_y < sc->syninfo.softbuttons_y :
-   start_y > max_y - sc->syninfo.softbuttons_y;
+   start_y > max_y + sc->syninfo.softbuttons_y;
 
center_button = MOUSE_BUTTON2DOWN;
center_x = sc->syninfo.softbutton2_x;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313712 - head/sys/dev/sdhci

2017-02-13 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Feb 14 00:04:36 2017
New Revision: 313712
URL: https://svnweb.freebsd.org/changeset/base/313712

Log:
  [sdhci_acpi] Add support for Bay Trail SDHC SD card slot
  
  Add ACPI device 80860F14 with _UID 3 to the list of known devices. It
  make SD card available on NUCs and Minnowboard. Previously added _UID 1
  covered only eMMC devices.
  
  Reported by:  kib@
  MFC after:1 week

Modified:
  head/sys/dev/sdhci/sdhci_acpi.c

Modified: head/sys/dev/sdhci/sdhci_acpi.c
==
--- head/sys/dev/sdhci/sdhci_acpi.c Mon Feb 13 21:44:29 2017
(r313711)
+++ head/sys/dev/sdhci/sdhci_acpi.c Tue Feb 14 00:04:36 2017
(r313712)
@@ -60,9 +60,11 @@ static const struct sdhci_acpi_device {
const char  *desc;
u_int   quirks;
 } sdhci_acpi_devices[] = {
-   { "80860F14",   1,  "Intel Bay Trail eMMC 4.5 Controller",
+   { "80860F14",   1,  "Intel Bay Trail SD Host Controller",
SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
SDHCI_QUIRK_INTEL_POWER_UP_RESET },
+   { "80860F14",   3,  "Intel Bay Trail SD Host Controller",
+   SDHCI_QUIRK_INTEL_POWER_UP_RESET },
{ "80860F16",   0,  "Intel Bay Trail SD Host Controller",
0 },
{ NULL, 0, NULL, 0}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r313068 - head/sys/arm/ti/am335x

2017-02-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Feb  1 22:03:59 2017
New Revision: 313068
URL: https://svnweb.freebsd.org/changeset/base/313068

Log:
  [am335x] Fallback to standard video interface bindings when using Linux dts
  
  Historically AM335x LCDC driver used non-standard "hdmi" property to
  refer to HDMI framer. There is no such thing in upstream DTS, so to
  handle both cases fallback to bindings described in
  bindings/media/video-interfaces.txt in Linux documentation.
  
  We still make some assumptions that are not universally true: we
  assume that if remote endpoint is available it's going to be HDMI
  framer. Which is true for AM335x-based devices currently supported
  but may be not true for some custom hardware.
  
  MFC after:1 week

Modified:
  head/sys/arm/ti/am335x/am335x_lcd.c

Modified: head/sys/arm/ti/am335x/am335x_lcd.c
==
--- head/sys/arm/ti/am335x/am335x_lcd.c Wed Feb  1 21:57:07 2017
(r313067)
+++ head/sys/arm/ti/am335x/am335x_lcd.c Wed Feb  1 22:03:59 2017
(r313068)
@@ -343,15 +343,46 @@ static void
 am335x_read_hdmi_property(device_t dev)
 {
phandle_t node;
+   phandle_t endpoint;
phandle_t hdmi_xref;
struct am335x_lcd_softc *sc;
 
sc = device_get_softc(dev);
node = ofw_bus_get_node(dev);
-   if (OF_getencprop(node, "hdmi", &hdmi_xref, sizeof(hdmi_xref)) == -1)
-   sc->sc_hdmi_framer = 0;
-   else
-   sc->sc_hdmi_framer = hdmi_xref; 
+   sc->sc_hdmi_framer = 0;
+
+   /*
+* Old FreeBSD way of referencing to HDMI framer
+*/
+   if (OF_getencprop(node, "hdmi", &hdmi_xref, sizeof(hdmi_xref)) != -1) {
+   sc->sc_hdmi_framer = hdmi_xref;
+   return;
+   }
+
+   /*
+* Use bindings described in Linux docs:
+* bindings/media/video-interfaces.txt
+* We assume that the only endpoint in LCDC node
+* is HDMI framer.
+*/
+   node = ofw_bus_find_child(node, "port");
+
+   /* No media bindings */
+   if (node == 0)
+   return;
+
+   for (endpoint = OF_child(node); endpoint != 0; endpoint = 
OF_peer(endpoint)) {
+   if (OF_getencprop(endpoint, "remote-endpoint", &node, 
sizeof(node)) != -1) {
+   /* port node of remote endpoint */
+   node = OF_node_from_xref(node);
+   /* port/ node */
+   node = OF_parent(node);
+   /* actual owner of port/endpoint, in our case HDMI 
framer */
+   sc->sc_hdmi_framer = OF_parent(node);
+   if (sc->sc_hdmi_framer != 0)
+   return;
+   }
+   }
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r312969 - head/sys/modules/dtb/am335x

2017-01-29 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Jan 29 22:06:52 2017
New Revision: 312969
URL: https://svnweb.freebsd.org/changeset/base/312969

Log:
  [am335x] Fix DTB name in LINKS variable
  
  Fix apparent typo introduced by r312915, upstream DTBs are
  am335x-* not am3335x-*

Modified:
  head/sys/modules/dtb/am335x/Makefile

Modified: head/sys/modules/dtb/am335x/Makefile
==
--- head/sys/modules/dtb/am335x/MakefileSun Jan 29 22:00:47 2017
(r312968)
+++ head/sys/modules/dtb/am335x/MakefileSun Jan 29 22:06:52 2017
(r312969)
@@ -7,7 +7,7 @@ DTS=\
ufw.dts
 
 LINKS= \
-   ${DTBDIR}/am3335x-bone.dtb ${DTBDIR}/beaglebone.dtb \
-   ${DTBDIR}/am3335x-boneblack.dtb ${DTBDIR}/beaglebone-black.dtb
+   ${DTBDIR}/am335x-bone.dtb ${DTBDIR}/beaglebone.dtb \
+   ${DTBDIR}/am335x-boneblack.dtb ${DTBDIR}/beaglebone-black.dtb
 
 .include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r312670 - head/sys/boot/fdt/dts/arm

2017-01-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Jan 23 19:20:55 2017
New Revision: 312670
URL: https://svnweb.freebsd.org/changeset/base/312670

Log:
  [am335x] Use upstream tda19988 framer node from upstream DTS
  
  Remove custom DTS duplicate of tda19988 node and use upstream-provided
  one introduced by r295436. This duplication created two tdaX devices
  which confused fb driver into using only 640x480 area while setting
  display to native resolution.
  
  Reported by:  Michael Smith
  MFC after:3 days

Modified:
  head/sys/boot/fdt/dts/arm/beaglebone-black.dts

Modified: head/sys/boot/fdt/dts/arm/beaglebone-black.dts
==
--- head/sys/boot/fdt/dts/arm/beaglebone-black.dts  Mon Jan 23 17:44:33 
2017(r312669)
+++ head/sys/boot/fdt/dts/arm/beaglebone-black.dts  Mon Jan 23 19:20:55 
2017(r312670)
@@ -50,13 +50,7 @@
 };
 
 &i2c0 {
-   tda998x: hdmi-encoder {
-   compatible = "nxp,tda998x";
-   reg = <0x70>;
-
-   pinctrl-names = "default", "off";
-   pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
-   pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
+   tda998x: tda19988 {
status = "okay";
};
 };
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r312316 - head/sys/arm/xilinx

2017-01-16 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Jan 17 00:39:09 2017
New Revision: 312316
URL: https://svnweb.freebsd.org/changeset/base/312316

Log:
  [zynq] Fix panic on USB PHY initialization failure
  
  The Zedboard has a hardware bug where initialization of the USB PHY
  occasionally fails on boot-up. Fix regression in -CURRENT when
  kernel panics on such occasion. 11-RELEASE branch works fine
  
  PR:   215862
  Submitted by: Thomas Skibo 

Modified:
  head/sys/arm/xilinx/zy7_ehci.c

Modified: head/sys/arm/xilinx/zy7_ehci.c
==
--- head/sys/arm/xilinx/zy7_ehci.c  Tue Jan 17 00:35:23 2017
(r312315)
+++ head/sys/arm/xilinx/zy7_ehci.c  Tue Jan 17 00:39:09 2017
(r312316)
@@ -325,13 +325,10 @@ zy7_ehci_detach(device_t dev)
/* during module unload there are lots of children leftover */
device_delete_children(dev);

-   sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
-
-   if (sc->sc_irq_res && sc->sc_intr_hdl)
-   /* call ehci_detach() after ehci_init() called after
-* successful bus_setup_intr().
-*/
+   if ((sc->sc_flags & EHCI_SCFLG_DONEINIT) != 0) {
ehci_detach(sc);
+   sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
+   }
 
if (sc->sc_irq_res) {
if (sc->sc_intr_hdl != NULL)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r311911 - in head/sys: conf dev/sdhci modules modules/sdhci_acpi

2017-01-11 Thread Oleksandr Tymoshenko
Ngie Cooper (yaneurabeya) (yaneurab...@gmail.com) wrote:
> 
> > On Jan 10, 2017, at 5:53 PM, Oleksandr Tymoshenko  wrote:
> > 
> > Author: gonzo
> > Date: Wed Jan 11 01:53:54 2017
> > New Revision: 311911
> > URL: https://svnweb.freebsd.org/changeset/base/311911
> > 
> > Log:
> >  [sdhci] Add ACPI platform support for SDHCI driver
> > 
> >  - Create ACPI version of SDHCI attach/detach/accessors logic. Some
> >  platforms (e.g. BayTrail-based Minnowboard) expose SDHCI devices
> >  via ACPI, not PCI
> >  - Add sdchi_acpi kernel module
> > 
> >  Reviewed by:   ian, imp
> >  MFC after: 1 week
> >  Differential Revision: https://reviews.freebsd.org/D9112
> 
> 
> Hi,
>   This broke the build for a bit because of missing headers in SRCS. 
> Please MFC r311923 too.
> Thank you!

Oops. My apologies. Thanks for fixing. 

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r311911 - in head/sys: conf dev/sdhci modules modules/sdhci_acpi

2017-01-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Jan 11 01:53:54 2017
New Revision: 311911
URL: https://svnweb.freebsd.org/changeset/base/311911

Log:
  [sdhci] Add ACPI platform support for SDHCI driver
  
  - Create ACPI version of SDHCI attach/detach/accessors logic. Some
  platforms (e.g. BayTrail-based Minnowboard) expose SDHCI devices
  via ACPI, not PCI
  - Add sdchi_acpi kernel module
  
  Reviewed by:  ian, imp
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D9112

Added:
  head/sys/dev/sdhci/sdhci_acpi.c   (contents, props changed)
  head/sys/modules/sdhci_acpi/
  head/sys/modules/sdhci_acpi/Makefile   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/modules/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Jan 11 01:18:06 2017(r311910)
+++ head/sys/conf/files Wed Jan 11 01:53:54 2017(r311911)
@@ -2826,6 +2826,7 @@ dev/scc/scc_dev_z8530.c   optional scc
 dev/sdhci/sdhci.c  optional sdhci
 dev/sdhci/sdhci_fdt_gpio.c optional sdhci fdt gpio
 dev/sdhci/sdhci_if.m   optional sdhci
+dev/sdhci/sdhci_acpi.c optional sdhci acpi
 dev/sdhci/sdhci_pci.c  optional sdhci pci
 dev/sf/if_sf.c optional sf pci
 dev/sge/if_sge.c   optional sge pci

Added: head/sys/dev/sdhci/sdhci_acpi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/sdhci/sdhci_acpi.c Wed Jan 11 01:53:54 2017
(r311911)
@@ -0,0 +1,370 @@
+/*-
+ * Copyright (c) 2017 Oleksandr Tymoshenko 
+ * 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 ``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 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "sdhci.h"
+#include "mmcbr_if.h"
+#include "sdhci_if.h"
+
+static const struct sdhci_acpi_device {
+   const char* hid;
+   int uid;
+   const char  *desc;
+   u_int   quirks;
+} sdhci_acpi_devices[] = {
+   { "80860F14",   1,  "Intel Bay Trail eMMC 4.5 Controller",
+   SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
+   SDHCI_QUIRK_INTEL_POWER_UP_RESET },
+   { "80860F16",   0,  "Intel Bay Trail SD Host Controller",
+   0 },
+   { NULL, 0, NULL, 0}
+};
+
+static char *sdhci_ids[] = {
+   "80860F14",
+   "80860F16",
+   NULL
+};
+
+struct sdhci_acpi_softc {
+   u_int   quirks; /* Chip specific quirks */
+   struct resource *irq_res;   /* IRQ resource */
+   void*intrhand;  /* Interrupt handle */
+
+   struct sdhci_slot slot;
+   struct resource *mem_res;   /* Memory resource */
+};
+
+static void sdhci_acpi_intr(void *arg);
+static int sdhci_acpi_detach(device_t dev);
+
+static uint8_t
+sdhci_acpi_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off)
+{
+   struct sdhci_acpi_softc *sc = device_get_softc(dev);
+
+   bus_barrier(sc->mem_res, 0, 0xFF,
+   BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
+   return bus_read_1(sc->mem_res, off);
+}
+
+static void
+sdhci_acpi_write_1(device_t dev, struct sdhci_slot *slot, bus_size_t off, 
uint8_t val)
+{
+   struct sdhci_acpi_softc *sc = device_get_softc(dev);
+
+   bus_barrier(sc->mem_res, 0, 0xFF,
+

svn commit: r311891 - head/sys/boot/efi

2017-01-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Jan 10 20:15:24 2017
New Revision: 311891
URL: https://svnweb.freebsd.org/changeset/base/311891

Log:
  [efi] Build EFI bits with -fPIC on ARM
  
  clang 3.9.0 without -fPIC generates absolute jump table for
  switch/case statement which trips boot1.efi and loader.efi
  on ARM platform.
  
  Reviewed by:  andrew
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D9108

Modified:
  head/sys/boot/efi/Makefile.inc

Modified: head/sys/boot/efi/Makefile.inc
==
--- head/sys/boot/efi/Makefile.inc  Tue Jan 10 20:12:07 2017
(r311890)
+++ head/sys/boot/efi/Makefile.inc  Tue Jan 10 20:15:24 2017
(r311891)
@@ -23,4 +23,8 @@ CFLAGS+=  -fshort-wchar
 CFLAGS+=   -fPIC
 .endif
 
+.if ${MACHINE_CPUARCH} == "arm"
+CFLAGS+=   -fPIC
+.endif
+
 .include "../Makefile.inc"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r311890 - head/sys/boot/efi/loader/arch/arm

2017-01-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Jan 10 20:12:07 2017
New Revision: 311890
URL: https://svnweb.freebsd.org/changeset/base/311890

Log:
  [efi] Fix .rel.data.* being erroneously merged into .data on ARM
  
  Fix section pattern code to exclude .rel.data.* sections from being
  merged into .data. Otherwise relocations in those sections are lost
  in final binary
  
  Reviewed by:  andrew
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D9108

Modified:
  head/sys/boot/efi/loader/arch/arm/ldscript.arm

Modified: head/sys/boot/efi/loader/arch/arm/ldscript.arm
==
--- head/sys/boot/efi/loader/arch/arm/ldscript.arm  Tue Jan 10 20:09:35 
2017(r311889)
+++ head/sys/boot/efi/loader/arch/arm/ldscript.arm  Tue Jan 10 20:12:07 
2017(r311890)
@@ -18,7 +18,7 @@ SECTIONS
   . = ALIGN(16);
   .data:
   {
-*(.data *.data.*)
+*(.data .data.*)
 *(.gnu.linkonce.d*)
 *(.rodata)
 *(.rodata.*)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r311888 - head/sys/boot/efi/loader/arch/arm

2017-01-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Jan 10 20:08:21 2017
New Revision: 311888
URL: https://svnweb.freebsd.org/changeset/base/311888

Log:
  [efi] Fix off-by-one error in ARM .bss zeroing code in loader's _start
  
  __bss_end should not be included in .bss zeroing code. Otherwise first 4
  bytes of the section that follows .bss (in loader's case it's .sdata) are
  overwritten by zero.
  
  Reviewed by:  andrew
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D9108

Modified:
  head/sys/boot/efi/loader/arch/arm/start.S

Modified: head/sys/boot/efi/loader/arch/arm/start.S
==
--- head/sys/boot/efi/loader/arch/arm/start.S   Tue Jan 10 19:28:40 2017
(r311887)
+++ head/sys/boot/efi/loader/arch/arm/start.S   Tue Jan 10 20:08:21 2017
(r311888)
@@ -161,7 +161,7 @@ _start:
mov r2, #0
 
 1: cmp r0, r1
-   bgt 2f
+   bge 2f
str r2, [r0], #4
b   1b
 2:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310791 - head/sys/arm/arm

2016-12-29 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Dec 29 21:55:23 2016
New Revision: 310791
URL: https://svnweb.freebsd.org/changeset/base/310791

Log:
  [qemu] Fix VERSATILEPB kernel boot in QEMU broken by r300968
  
  QEMU does not implement hardware debug registers so when
  dbg_monitor_is_enabled is called kernel receives "invalid instruction"
  exception. QEMU implements only DIDR register and on read returns all
  zeroes to indicate that it doesn't support other registers. Real
  hardware has Version bits set.
  
  MFC after:1 week

Modified:
  head/sys/arm/arm/debug_monitor.c

Modified: head/sys/arm/arm/debug_monitor.c
==
--- head/sys/arm/arm/debug_monitor.cThu Dec 29 21:36:04 2016
(r310790)
+++ head/sys/arm/arm/debug_monitor.cThu Dec 29 21:55:23 2016
(r310791)
@@ -792,10 +792,21 @@ dbg_get_ossr(void)
 static __inline boolean_t
 dbg_arch_supported(void)
 {
+   uint32_t dbg_didr;
 
switch (dbg_model) {
case ID_DFR0_CP_DEBUG_M_V6:
case ID_DFR0_CP_DEBUG_M_V6_1:
+   dbg_didr = cp14_dbgdidr_get();
+   /*
+* read-all-zeroes is used by QEMU
+* to indicate that ARMv6 debug support
+* is not implemented. Real hardware has at
+* least version bits set
+*/
+   if (dbg_didr == 0)
+   return (FALSE);
+   return (TRUE);
case ID_DFR0_CP_DEBUG_M_V7:
case ID_DFR0_CP_DEBUG_M_V7_1:   /* fall through */
return (TRUE);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310645 - in head/sys: conf dev/intel modules modules/intelspi

2016-12-27 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Dec 27 22:37:24 2016
New Revision: 310645
URL: https://svnweb.freebsd.org/changeset/base/310645

Log:
  [intelspi] Add SPI driver for Intel BayTrail SoC
  
  Add SPI mode (PIO-only) support for Intel Synchronous Serial Port that
  can be found in several Intel's products starting from PXA family.
  Most of implementations have slight differences in behavior and in
  addresses for registers subset. This driver covers only BayTrail SoC
  implementation for it's the only hardware I have to test it on.
  
  Driver attaches to ACPI bus only and does not have PCI or FDT support
  for now due to lack of hardware to test it on.
  
  "intelspi" is the best name I've managed to come up with. Linux driver
  name (spi-pxa2xx) does not make sense because current implementation
  does not support actual PXA2xx SoCs. And as far as I know there is no
  codename assigned to Intel SSP chip.
  
  Reviewed by:  br, manu
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D8896

Added:
  head/sys/dev/intel/
  head/sys/dev/intel/spi.c   (contents, props changed)
  head/sys/modules/intelspi/
  head/sys/modules/intelspi/Makefile   (contents, props changed)
Modified:
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/modules/Makefile

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Tue Dec 27 22:31:06 2016(r310644)
+++ head/sys/conf/files.amd64   Tue Dec 27 22:37:24 2016(r310645)
@@ -228,6 +228,7 @@ dev/if_ndis/if_ndis.c   optionalndis
 dev/if_ndis/if_ndis_pccard.c   optionalndis pccard
 dev/if_ndis/if_ndis_pci.c  optionalndis cardbus | ndis pci
 dev/if_ndis/if_ndis_usb.c  optionalndis usb
+dev/intel/spi.coptionalintelspi
 dev/io/iodev.c optionalio
 dev/ioat/ioat.coptionalioat pci
 dev/ioat/ioat_test.c   optionalioat pci

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Tue Dec 27 22:31:06 2016(r310644)
+++ head/sys/conf/files.i386Tue Dec 27 22:37:24 2016(r310645)
@@ -275,6 +275,7 @@ dev/if_ndis/if_ndis.c   optional ndis
 dev/if_ndis/if_ndis_pccard.c   optional ndis pccard
 dev/if_ndis/if_ndis_pci.c  optional ndis cardbus | ndis pci
 dev/if_ndis/if_ndis_usb.c  optional ndis usb
+dev/intel/spi.coptional intelspi
 dev/io/iodev.c optional io
 dev/ipmi/ipmi.coptional ipmi
 dev/ipmi/ipmi_acpi.c   optional ipmi acpi

Added: head/sys/dev/intel/spi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/intel/spi.cTue Dec 27 22:37:24 2016(r310645)
@@ -0,0 +1,533 @@
+/*-
+ * Copyright (c) 2016 Oleksandr Tymoshenko 
+ * 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$");
+
+#include "opt_acpi.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "spibus_if.h"
+
+/**
+ * Macros for driver mutex locking
+ */
+#defineINTELSPI_LOCK(_sc)  mtx_lock(&(_sc)->sc_mtx)
+#defineINTELSPI_UNLOCK(_sc)mtx_unlock(&(_sc)->sc_mtx)
+#defineINTELSPI_LOCK_INIT(

svn commit: r310636 - head/sys/arm/broadcom/bcm2835

2016-12-27 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Dec 27 19:08:08 2016
New Revision: 310636
URL: https://svnweb.freebsd.org/changeset/base/310636

Log:
  [rpi] Fix bcm2835_audio locking and samples starvation
  
  Rework general approach to locking and working with audio worker thread:
  
  - Use flags to signal requested worker action
  - Fix submitted buffer calculations to avoid samples starvation
  - Protect buffer pointers with locks to fix race condition between callback
and audio worker thread
  - Remove unnecessary vchi_service_use
  - Do not use lock to serialize VCHI requests since only one thread issues 
them now
  - Fix unloading signaling per hselasky@ suggestion
  - Add output to detect inconsistent callback data caused by possible firmware 
bug
https://github.com/raspberrypi/firmware/issues/696
  - Add stats/debug sysctls to troubleshoot possible bugs
  
  PR:   213687, 205979, 215194
  MFC after:1 week

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_audio.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_audio.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_audio.c   Tue Dec 27 18:23:16 
2016(r310635)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_audio.c   Tue Dec 27 19:08:08 
2016(r310636)
@@ -40,13 +40,33 @@
 
 SND_DECLARE_FILE("$FreeBSD$");
 
+/* Audio destination */
 #defineDEST_AUTO   0
 #defineDEST_HEADPHONES 1
 #defineDEST_HDMI   2
 
+/* Playback state */
+#definePLAYBACK_IDLE   0
+#definePLAYBACK_PLAYING1
+#definePLAYBACK_STOPPING   2
+
+/* Worker thread state */
+#defineWORKER_RUNNING  0
+#defineWORKER_STOPPING 1
+#defineWORKER_STOPPED  2
+
+/*
+ * Worker thread flags, set to 1 in flags_pending
+ * when driver requests one or another operation
+ * from worker. Cleared to 0 once worker performs
+ * the operations.
+ */
+#defineAUDIO_PARAMS(1 << 0)
+#defineAUDIO_PLAY  (1 << 1)
+#defineAUDIO_STOP  (1 << 2)
+
 #defineVCHIQ_AUDIO_PACKET_SIZE 4000
-#defineVCHIQ_AUDIO_BUFFER_SIZE 128000
-#defineVCHIQ_AUDIO_PREBUFFER   10 /* Number of pre-buffered audio 
messages */
+#defineVCHIQ_AUDIO_BUFFER_SIZE 10*VCHIQ_AUDIO_PACKET_SIZE
 
 #defineVCHIQ_AUDIO_MAX_VOLUME  
 /* volume in terms of 0.01dB */
@@ -77,22 +97,25 @@ static struct pcmchan_caps bcm2835_audio
 
 struct bcm2835_audio_info;
 
-#definePLAYBACK_IDLE   0
-#definePLAYBACK_STARTING   1
-#definePLAYBACK_PLAYING2
-#definePLAYBACK_STOPPING   3
-
 struct bcm2835_audio_chinfo {
struct bcm2835_audio_info *parent;
struct pcm_channel *channel;
struct snd_dbuf *buffer;
uint32_t fmt, spd, blksz;
 
-   uint32_t complete_pos;
-   uint32_t free_buffer;
-   uint32_t buffered_ptr;
+   /* Pointer to first unsubmitted sample */
+   uint32_t unsubmittedptr;
+   /*
+* Number of bytes in "submitted but not played"
+* pseudo-buffer
+*/
+   int available_space;
int playback_state;
-   int prebuffered;
+   uint64_t callbacks;
+   uint64_t submitted_samples;
+   uint64_t retrieved_samples;
+   uint64_t underruns;
+   int starved;
 };
 
 struct bcm2835_audio_info {
@@ -100,32 +123,25 @@ struct bcm2835_audio_info {
unsigned int bufsz;
struct bcm2835_audio_chinfo pch;
uint32_t dest, volume;
-   struct mtx *lock;
struct intr_config_hook intr_hook;
 
/* VCHI data */
-   struct sx vchi_lock;
-
VCHI_INSTANCE_T vchi_instance;
VCHI_CONNECTION_T *vchi_connection;
VCHI_SERVICE_HANDLE_T vchi_handle;
 
-   struct sx worker_lock;
+   struct mtx lock;
struct cv worker_cv;
 
-   bool parameters_update_pending;
-   bool controls_update_pending;
+   uint32_t flags_pending;
 
-   /* Unloadign module */
-   int unloading;
+   /* Worker thread state */
+   int worker_state;
 };
 
-#define bcm2835_audio_lock(_ess) snd_mtxlock((_ess)->lock)
-#define bcm2835_audio_unlock(_ess) snd_mtxunlock((_ess)->lock)
-#define bcm2835_audio_lock_assert(_ess) snd_mtxassert((_ess)->lock)
-
-#define VCHIQ_VCHI_LOCK(sc)sx_xlock(&(sc)->vchi_lock)
-#define VCHIQ_VCHI_UNLOCK(sc)  sx_xunlock(&(sc)->vchi_lock)
+#define BCM2835_AUDIO_LOCK(sc) mtx_lock(&(sc)->lock)
+#define BCM2835_AUDIO_LOCKED(sc)   mtx_assert(&(sc)->lock, MA_OWNED)
+#define BCM2835_AUDIO_UNLOCK(sc)   mtx_unlock(&(sc)->lock)
 
 static const char *
 dest_description(uint32_t dest)
@@ -149,6 +165,36 @@ dest_description(uint32_t dest)
 }
 
 static void
+bcm2835_worker_update_params(struct bcm2835_audio_info *sc)
+{
+
+   BCM2835_AUDIO_LOCKED(sc);
+
+   sc->flags_pending |= AUDIO_PARAMS

svn commit: r310621 - in head/sys: conf dev/ichiic modules/i2c/controllers/ichiic

2016-12-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Dec 26 22:13:43 2016
New Revision: 310621
URL: https://svnweb.freebsd.org/changeset/base/310621

Log:
  [ig4] Add ACPI platform support for ig4 driver
  
  Add ACPI part for ig4 driver to make it work on Intel BayTrail SoC where
  ig4 device is available only through ACPI
  
  Reviewed by:  avg
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8742

Added:
  head/sys/dev/ichiic/ig4_acpi.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/ichiic/ig4_iic.c
  head/sys/dev/ichiic/ig4_pci.c
  head/sys/dev/ichiic/ig4_var.h
  head/sys/modules/i2c/controllers/ichiic/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Mon Dec 26 21:27:21 2016(r310620)
+++ head/sys/conf/files Mon Dec 26 22:13:43 2016(r310621)
@@ -1730,6 +1730,7 @@ dev/hptiop/hptiop.c   optional hptiop scb
 dev/hwpmc/hwpmc_logging.c  optional hwpmc
 dev/hwpmc/hwpmc_mod.c  optional hwpmc
 dev/hwpmc/hwpmc_soft.c optional hwpmc
+dev/ichiic/ig4_acpi.c  optional ig4 acpi iicbus
 dev/ichiic/ig4_iic.c   optional ig4 iicbus
 dev/ichiic/ig4_pci.c   optional ig4 pci iicbus
 dev/ichsmb/ichsmb.coptional ichsmb

Added: head/sys/dev/ichiic/ig4_acpi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/ichiic/ig4_acpi.c  Mon Dec 26 22:13:43 2016
(r310621)
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (c) 2016 Oleksandr Tymoshenko 
+ * 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$");
+
+#include "opt_acpi.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+static int ig4iic_acpi_probe(device_t dev);
+static int ig4iic_acpi_attach(device_t dev);
+static int ig4iic_acpi_detach(device_t dev);
+
+static char *ig4iic_ids[] = {
+   "INT33C2",
+   "INT33C3",
+   "INT3432",
+   "INT3433",
+   "80860F41",
+   "808622C1",
+   "AMDI0510",
+   "APMC0D0F",
+   NULL
+};
+
+static int
+ig4iic_acpi_probe(device_t dev)
+{
+
+   if (acpi_disabled("ig4iic") ||
+   ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids) == NULL)
+   return (ENXIO);
+
+   device_set_desc(dev, "Designware I2C Controller");
+   return (0);
+}
+
+static int
+ig4iic_acpi_attach(device_t dev)
+{
+   ig4iic_softc_t  *sc;
+   int error;
+
+   sc = device_get_softc(dev);
+
+   sc->dev = dev;
+   sc->regs_rid = 0;
+   sc->regs_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->regs_rid, RF_ACTIVE);
+   if (sc->regs_res == NULL) {
+   device_printf(dev, "unable to map registers\n");
+   ig4iic_acpi_detach(dev);
+   return (ENXIO);
+   }
+   sc->intr_rid = 0;
+   sc->intr_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+ &sc->intr_rid, RF_SHAREABLE | 
RF_ACTIVE);
+   if (sc->intr_res == NULL) {
+   device_printf(dev, "unable to map interrupt\n");
+   ig4iic_acpi_detach(dev);
+   return (ENXIO);
+   }
+   sc->platform_attached = 1;
+
+   error = ig4iic_attach(sc);
+

svn commit: r310612 - head/sys/dev/evdev

2016-12-26 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Dec 26 17:48:13 2016
New Revision: 310612
URL: https://svnweb.freebsd.org/changeset/base/310612

Log:
  [evdev] Fix build for older versions of clang
  
  There was report of stable/11 build failure on older versions of
  FreeBSD. The problem was a reference to static variable in inline
  function. Although fairly recent versions of clang can cope with this
  situation just fine there is no strict requirement to make functions
  in question inline, they're not in any time-critical codepath. So to
  keep HEAD and 11-STABLE buildable on older FreeBSDs some of the util
  functions were converted from inline to normal.
  
  Reported by:  hselasky
  MFC after:3 days

Modified:
  head/sys/dev/evdev/evdev_utils.c

Modified: head/sys/dev/evdev/evdev_utils.c
==
--- head/sys/dev/evdev/evdev_utils.cMon Dec 26 17:34:27 2016
(r310611)
+++ head/sys/dev/evdev/evdev_utils.cMon Dec 26 17:48:13 2016
(r310612)
@@ -206,13 +206,13 @@ static uint16_t evdev_led_codes[] = {
LED_SCROLLL,/* SLKED */
 };
 
-inline uint16_t
+uint16_t
 evdev_hid2key(int scancode)
 {
return evdev_usb_scancodes[scancode];
 }
 
-inline void
+void
 evdev_support_all_known_keys(struct evdev_dev *evdev)
 {
size_t i;
@@ -222,7 +222,7 @@ evdev_support_all_known_keys(struct evde
evdev_support_key(evdev, evdev_at_set1_scancodes[i]);
 }
 
-inline uint16_t
+uint16_t
 evdev_scancode2key(int *state, int scancode)
 {
uint16_t keycode;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310560 - head/sys/contrib/vchiq/interface/vchiq_arm

2016-12-25 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Dec 26 02:51:03 2016
New Revision: 310560
URL: https://svnweb.freebsd.org/changeset/base/310560

Log:
  [vchi] replace non-reproducible __DATE__/__TIME__ with hardcoded string
  
  Although vchiq_build_date and vchiq_build_time are not used in current
  vchi driver at the moment, make sure these value will not leak into
  build later on if at some point they will be refered in some new
  imported code
  
  PR:   215494
  Reported by:  emaste
  MFC after:1 week

Modified:
  head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_version.c

Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_version.c
==
--- head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_version.c  Mon Dec 26 
01:18:07 2016(r310559)
+++ head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_version.c  Mon Dec 26 
02:51:03 2016(r310560)
@@ -35,8 +35,8 @@
 
 VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_hostname, "dc4-arm-01" );
 VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_version, 
"9245b4c35b99b3870e1f7dc598c5692b3c66a6f0 (tainted)" );
-VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_time,__TIME__ );
-VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_date,__DATE__ );
+VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_time,"not available" );
+VC_DEBUG_DECLARE_STRING_VAR( vchiq_build_date,"not available" );
 
 const char *vchiq_get_build_hostname( void )
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310492 - head/sys/dev/spibus

2016-12-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Dec 24 00:30:29 2016
New Revision: 310492
URL: https://svnweb.freebsd.org/changeset/base/310492

Log:
  [spigen] Fix spigen attaching as a driver for SPI devices nodes in FDT
  
  Return BUS_PROBE_NOWILDCARD in probe method to make sure that spigen
  attaches only to the device created in identify method.
  
  Before this change spigen probe method used to return 0 which meant it
  competed with other drivers to be attached to the devices created for
  child nodes of SPI bus node in FDT.
  
  Reported by:  Daniel Braniss
  MFC after:1 week

Modified:
  head/sys/dev/spibus/spigen.c

Modified: head/sys/dev/spibus/spigen.c
==
--- head/sys/dev/spibus/spigen.cFri Dec 23 23:14:53 2016
(r310491)
+++ head/sys/dev/spibus/spigen.cSat Dec 24 00:30:29 2016
(r310492)
@@ -81,8 +81,10 @@ spigen_identify(driver_t *driver, device
 static int
 spigen_probe(device_t dev)
 {
+
device_set_desc(dev, "SPI Generic IO");
-   return (0);
+
+   return (BUS_PROBE_NOWILDCARD);
 }
 
 static int spigen_open(struct cdev *, int, int, struct thread *);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310375 - head/sys/dev/iwn

2016-12-21 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Dec 21 22:35:26 2016
New Revision: 310375
URL: https://svnweb.freebsd.org/changeset/base/310375

Log:
  [iwn] Several fixes for DMA part of iwn(4)
  
  - Perform DMS sync when accessing/initializing ICT table
  - Fix some DMA sync operations to use matching tags
  
  Reviewed by:  avos
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8804

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==
--- head/sys/dev/iwn/if_iwn.c   Wed Dec 21 22:04:44 2016(r310374)
+++ head/sys/dev/iwn/if_iwn.c   Wed Dec 21 22:35:26 2016(r310375)
@@ -2120,6 +2120,9 @@ iwn5000_ict_reset(struct iwn_softc *sc)
memset(sc->ict, 0, IWN_ICT_SIZE);
sc->ict_cur = 0;
 
+   bus_dmamap_sync(sc->ict_dma.tag, sc->ict_dma.map,
+   BUS_DMASYNC_PREWRITE);
+
/* Set physical address of ICT table (4KB aligned). */
DPRINTF(sc, IWN_DEBUG_RESET, "%s: enabling ICT\n", __func__);
IWN_WRITE(sc, IWN_DRAM_INT_TBL, IWN_DRAM_INT_TBL_ENABLE |
@@ -4100,6 +4103,8 @@ iwn_intr(void *arg)
 
/* Read interrupts from ICT (fast) or from registers (slow). */
if (sc->sc_flags & IWN_FLAG_USE_ICT) {
+   bus_dmamap_sync(sc->ict_dma.tag, sc->ict_dma.map,
+   BUS_DMASYNC_POSTREAD);
tmp = 0;
while (sc->ict[sc->ict_cur] != 0) {
tmp |= sc->ict[sc->ict_cur];
@@ -4635,7 +4640,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
}
 
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
-   bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map,
+   bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map,
BUS_DMASYNC_PREWRITE);
bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
BUS_DMASYNC_PREWRITE);
@@ -4828,7 +4833,7 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
}
 
bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
-   bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map,
+   bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map,
BUS_DMASYNC_PREWRITE);
bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
BUS_DMASYNC_PREWRITE);
@@ -5161,7 +5166,7 @@ iwn_cmd(struct iwn_softc *sc, int code, 
bus_dmamap_sync(ring->data_dmat, data->map,
BUS_DMASYNC_PREWRITE);
} else {
-   bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map,
+   bus_dmamap_sync(ring->cmd_dma.tag, ring->cmd_dma.map,
BUS_DMASYNC_PREWRITE);
}
bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310344 - head/sys/arm/freescale/imx

2016-12-20 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Dec 21 01:38:44 2016
New Revision: 310344
URL: https://svnweb.freebsd.org/changeset/base/310344

Log:
  [iMX6] Fix SDMA driver build
  
  - Place const modifiers where required
  - Make sure sdma device is attahched before consumers like SSI
  
  Reviewed by:  br
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8874

Modified:
  head/sys/arm/freescale/imx/imx6_sdma.c
  head/sys/arm/freescale/imx/imx6_sdma.h

Modified: head/sys/arm/freescale/imx/imx6_sdma.c
==
--- head/sys/arm/freescale/imx/imx6_sdma.c  Wed Dec 21 01:32:19 2016
(r310343)
+++ head/sys/arm/freescale/imx/imx6_sdma.c  Wed Dec 21 01:38:44 2016
(r310344)
@@ -351,7 +351,7 @@ sdma_configure(int chn, struct sdma_conf
 static int
 load_firmware(struct sdma_softc *sc)
 {
-   struct sdma_firmware_header *header;
+   const struct sdma_firmware_header *header;
const struct firmware *fp;
 
fp = firmware_get("sdma_fw");
@@ -360,14 +360,14 @@ load_firmware(struct sdma_softc *sc)
return (-1);
}
 
-   header = (struct sdma_firmware_header *)fp->data;
+   header = fp->data;
if (header->magic != FW_HEADER_MAGIC) {
device_printf(sc->dev, "Can't use firmware.\n");
return (-1);
}
 
sc->fw_header = header;
-   sc->fw_scripts = (void *)((char *)header +
+   sc->fw_scripts = (const void *)((const char *)header +
header->script_addrs_start);
 
return (0);
@@ -377,14 +377,14 @@ static int
 boot_firmware(struct sdma_softc *sc)
 {
struct sdma_buffer_descriptor *bd0;
-   uint32_t *ram_code;
+   const uint32_t *ram_code;
int timeout;
int ret;
int chn;
int sz;
int i;
 
-   ram_code = (void *)((char *)sc->fw_header +
+   ram_code = (const void *)((const char *)sc->fw_header +
sc->fw_header->ram_code_start);
 
/* Make sure SDMA has not started yet */
@@ -514,4 +514,5 @@ static driver_t sdma_driver = {
 
 static devclass_t sdma_devclass;
 
-DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0);
+EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0,
+BUS_PASS_RESOURCE);

Modified: head/sys/arm/freescale/imx/imx6_sdma.h
==
--- head/sys/arm/freescale/imx/imx6_sdma.h  Wed Dec 21 01:32:19 2016
(r310343)
+++ head/sys/arm/freescale/imx/imx6_sdma.h  Wed Dec 21 01:38:44 2016
(r310344)
@@ -221,8 +221,8 @@ struct sdma_softc {
uint32_tnum_bd;
uint32_tccb_phys;
uint32_tcontext_phys;
-   struct sdma_firmware_header *fw_header;
-   struct sdma_script_start_addrs  *fw_scripts;
+   const struct sdma_firmware_header   *fw_header;
+   const struct sdma_script_start_addrs*fw_scripts;
 };
 
 struct sdma_conf {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310343 - head/sys/arm/freescale/imx

2016-12-20 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Wed Dec 21 01:32:19 2016
New Revision: 310343
URL: https://svnweb.freebsd.org/changeset/base/310343

Log:
  [iMX6] Fix build for SSI driver and add dependency for SDMA driver
  
  - Pass correct pointer to OF_getencprop
  - Check the size of "dmas" property
  - Add dependency on sdma driver
  
  Reviewed by:  br
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8873

Modified:
  head/sys/arm/freescale/imx/imx6_ssi.c

Modified: head/sys/arm/freescale/imx/imx6_ssi.c
==
--- head/sys/arm/freescale/imx/imx6_ssi.c   Wed Dec 21 00:50:21 2016
(r310342)
+++ head/sys/arm/freescale/imx/imx6_ssi.c   Wed Dec 21 01:32:19 2016
(r310343)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
bus_space_write_4(_sc->bst, _sc->bsh, _reg, _val)
 
 #defineSSI_NCHANNELS   1
+#defineDMAS_TOTAL  8
 
 /* i.MX6 SSI registers */
 
@@ -187,8 +188,8 @@ struct sc_info {
struct sdma_conf*conf;
struct ssi_rate *sr;
struct sdma_softc   *sdma_sc;
-   int sdma_ev_rx;
-   int sdma_ev_tx;
+   uint32_tsdma_ev_rx;
+   uint32_tsdma_ev_tx;
int sdma_channel;
 };
 
@@ -437,7 +438,7 @@ find_sdma_controller(struct sc_info *sc)
struct sdma_softc *sdma_sc;
phandle_t node, sdma_node;
device_t sdma_dev;
-   int dts_value[8];
+   pcell_t dts_value[DMAS_TOTAL];
int len;
 
if ((node = ofw_bus_get_node(sc->dev)) == -1)
@@ -446,7 +447,14 @@ find_sdma_controller(struct sc_info *sc)
if ((len = OF_getproplen(node, "dmas")) <= 0)
return (ENXIO);
 
-   OF_getencprop(node, "dmas", &dts_value, len);
+   if (len != sizeof(dts_value)) {
+   device_printf(sc->dev,
+   "\"dmas\" property length is invalid: %d (expected %d)",
+   len, sizeof(dts_value));
+   return (ENXIO);
+   }
+
+   OF_getencprop(node, "dmas", dts_value, sizeof(dts_value));
 
sc->sdma_ev_rx = dts_value[1];
sc->sdma_ev_tx = dts_value[5];
@@ -850,4 +858,5 @@ static driver_t ssi_pcm_driver = {
 
 DRIVER_MODULE(ssi, simplebus, ssi_pcm_driver, pcm_devclass, 0, 0);
 MODULE_DEPEND(ssi, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
+MODULE_DEPEND(ssi, sdma, 0, 0, 0);
 MODULE_VERSION(ssi, 1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310170 - head/sys/dev/spibus

2016-12-16 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Dec 16 19:09:57 2016
New Revision: 310170
URL: https://svnweb.freebsd.org/changeset/base/310170

Log:
  [spigen] Make "data" part of spigen_transfer optional
  
  Make st_data part of spigen_transfer optional by letting pass zero length
  and NULL pointer. SPI controller drivers handle this case fine.
  
  MFC after:1 week

Modified:
  head/sys/dev/spibus/spigen.c

Modified: head/sys/dev/spibus/spigen.c
==
--- head/sys/dev/spibus/spigen.cFri Dec 16 18:38:31 2016
(r310169)
+++ head/sys/dev/spibus/spigen.cFri Dec 16 19:09:57 2016
(r310170)
@@ -204,7 +204,7 @@ spigen_transfer(struct cdev *cdev, struc
int error = 0;
 
mtx_lock(&sc->sc_mtx);
-   if (st->st_command.iov_len == 0 || st->st_data.iov_len == 0)
+   if (st->st_command.iov_len == 0)
error = EINVAL;
else if (st->st_command.iov_len > sc->sc_command_length_max ||
st->st_data.iov_len > sc->sc_data_length_max)
@@ -221,16 +221,20 @@ spigen_transfer(struct cdev *cdev, struc
M_DEVBUF, M_WAITOK);
if (transfer.tx_cmd == NULL)
return (ENOMEM);
-   transfer.tx_data = transfer.rx_data = malloc(st->st_data.iov_len,
-   M_DEVBUF, M_WAITOK);
-   if (transfer.tx_data == NULL) {
-   free(transfer.tx_cmd, M_DEVBUF);
-   return (ENOMEM);
+   if (st->st_data.iov_len > 0) {
+   transfer.tx_data = transfer.rx_data = 
malloc(st->st_data.iov_len,
+   M_DEVBUF, M_WAITOK);
+   if (transfer.tx_data == NULL) {
+   free(transfer.tx_cmd, M_DEVBUF);
+   return (ENOMEM);
+   }
}
+   else
+   transfer.tx_data = transfer.rx_data = NULL;
 
error = copyin(st->st_command.iov_base, transfer.tx_cmd,
transfer.tx_cmd_sz = transfer.rx_cmd_sz = st->st_command.iov_len);  
-   if (error == 0)
+   if ((error == 0) && (st->st_data.iov_len > 0))
error = copyin(st->st_data.iov_base, transfer.tx_data,
transfer.tx_data_sz = transfer.rx_data_sz =
  st->st_data.iov_len); 
@@ -239,7 +243,7 @@ spigen_transfer(struct cdev *cdev, struc
if (error == 0) {
error = copyout(transfer.rx_cmd, st->st_command.iov_base,
transfer.rx_cmd_sz);
-   if (error == 0)
+   if ((error == 0) && (st->st_data.iov_len > 0))
error = copyout(transfer.rx_data, st->st_data.iov_base,
transfer.rx_data_sz);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r310012 - head/sys/arm/freescale/imx

2016-12-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Dec 13 05:09:49 2016
New Revision: 310012
URL: https://svnweb.freebsd.org/changeset/base/310012

Log:
  [iMX6] Add compatibility string for GPT timer on i.MX6 Dual
  
  Up until r295436 GPT timer in i.MX6 Dual dts used the same compatiblity
  string as i.MX6 Quad. After the sync up with Linux in r295436, GPT timer
  stopped getting attached on the i.MX6 Dual
  
  MFC after:3 days

Modified:
  head/sys/arm/freescale/imx/imx_gpt.c

Modified: head/sys/arm/freescale/imx/imx_gpt.c
==
--- head/sys/arm/freescale/imx/imx_gpt.cTue Dec 13 04:53:25 2016
(r310011)
+++ head/sys/arm/freescale/imx/imx_gpt.cTue Dec 13 05:09:49 2016
(r310012)
@@ -106,6 +106,7 @@ static struct resource_spec imx_gpt_spec
 };
 
 static struct ofw_compat_data compat_data[] = {
+   {"fsl,imx6dl-gpt",  1},
{"fsl,imx6q-gpt",  1},
{"fsl,imx53-gpt",  1},
{"fsl,imx51-gpt",  1},
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309999 - head/sys/arm/freescale/imx

2016-12-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Dec 13 03:26:12 2016
New Revision: 30
URL: https://svnweb.freebsd.org/changeset/base/30

Log:
  [iMX6] Fix platform compatibility string for i.MX6 Dual
  
  i.MX6 Dual boot was broken since r308533 because ofw_bus_node_is_compatible
  is more strict than fdt_is_compatible and does not accept partial matches

Modified:
  head/sys/arm/freescale/imx/imx6_machdep.c

Modified: head/sys/arm/freescale/imx/imx6_machdep.c
==
--- head/sys/arm/freescale/imx/imx6_machdep.c   Tue Dec 13 02:56:52 2016
(r309998)
+++ head/sys/arm/freescale/imx/imx6_machdep.c   Tue Dec 13 03:26:12 2016
(r30)
@@ -352,5 +352,5 @@ static platform_method_t imx6_methods[] 
 };
 
 FDT_PLATFORM_DEF2(imx6, imx6s, "i.MX6 Solo", 0, "fsl,imx6s", 0);
-FDT_PLATFORM_DEF2(imx6, imx6d, "i.MX6 Dual", 0, "fsl,imx6d", 0);
+FDT_PLATFORM_DEF2(imx6, imx6d, "i.MX6 Dual", 0, "fsl,imx6dl", 0);
 FDT_PLATFORM_DEF2(imx6, imx6q, "i.MX6 Quad", 0, "fsl,imx6q", 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309823 - in head/sys/dev: evdev syscons vt

2016-12-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Dec 10 18:07:16 2016
New Revision: 309823
URL: https://svnweb.freebsd.org/changeset/base/309823

Log:
  [evdev] Adds evdev support to sysmouse(4) driver
  
  For horizontal (T-axis) wheel reporting which is not supported by
  sysmouse protocol kern.evdev.sysmouse_t_axis sysctl is introduced.
  It can take following values:
  
  0 - no T-axis events (default)
  1 - T-axis events are originated in ums(4) driver.
  2 - T-axis events are originated in psm(4) driver.
  
  Submitted by: Vladimir Kondratiev 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8597

Modified:
  head/sys/dev/evdev/evdev.c
  head/sys/dev/evdev/evdev.h
  head/sys/dev/syscons/sysmouse.c
  head/sys/dev/vt/vt_sysmouse.c

Modified: head/sys/dev/evdev/evdev.c
==
--- head/sys/dev/evdev/evdev.c  Sat Dec 10 17:59:34 2016(r309822)
+++ head/sys/dev/evdev/evdev.c  Sat Dec 10 18:07:16 2016(r309823)
@@ -63,11 +63,14 @@ enum evdev_sparse_result
 MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory");
 
 int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX;
+int evdev_sysmouse_t_axis = 0;
 
 SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args");
 SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0,
 "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, "
 "bit2 - mouse hardware, bit3 - keyboard hardware");
+SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW,
+&evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm");
 
 static void evdev_start_repeat(struct evdev_dev *, uint16_t);
 static void evdev_stop_repeat(struct evdev_dev *);

Modified: head/sys/dev/evdev/evdev.h
==
--- head/sys/dev/evdev/evdev.h  Sat Dec 10 17:59:34 2016(r309822)
+++ head/sys/dev/evdev/evdev.h  Sat Dec 10 18:07:16 2016(r309823)
@@ -56,6 +56,22 @@ typedef void (evdev_keycode_t)(struct ev
 #defineEVDEV_RCPT_HW_MOUSE (1<<2)
 #defineEVDEV_RCPT_HW_KBD   (1<<3)
 extern int evdev_rcpt_mask;
+/*
+ * Sysmouse protocol does not support horizontal wheel movement reporting.
+ * To overcome this limitation different drivers use different sysmouse proto
+ * extensions. Set kern.evdev.sysmouse_t_axis to tell sysmouse evdev driver
+ * which protocol extension is used.
+ * 0 - do not extract horizontal wheel movement (default).
+ * 1 - ums(4) horizontal wheel encoding. T-axis is mapped to buttons 6 and 7
+ * 2 - psm(4) wheels encoding: z = 1,-1 - vert. wheel, z = 2,-2 - horiz. wheel
+ */
+enum
+{
+   EVDEV_SYSMOUSE_T_AXIS_NONE = 0,
+   EVDEV_SYSMOUSE_T_AXIS_UMS = 1,
+   EVDEV_SYSMOUSE_T_AXIS_PSM = 2,
+};
+extern int evdev_sysmouse_t_axis;
 
 #defineABS_MT_FIRSTABS_MT_TOUCH_MAJOR
 #defineABS_MT_LAST ABS_MT_TOOL_Y

Modified: head/sys/dev/syscons/sysmouse.c
==
--- head/sys/dev/syscons/sysmouse.c Sat Dec 10 17:59:34 2016
(r309822)
+++ head/sys/dev/syscons/sysmouse.c Sat Dec 10 18:07:16 2016
(r309823)
@@ -28,6 +28,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_evdev.h"
 #include "opt_syscons.h"
 
 #include 
@@ -43,6 +44,11 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifdef EVDEV_SUPPORT
+#include 
+#include 
+#endif
+
 #ifndef SC_NO_SYSMOUSE
 
 /* local variables */
@@ -50,6 +56,72 @@ static struct tty*sysmouse_tty;
 static int mouse_level;/* sysmouse protocol level */
 static mousestatus_t   mouse_status;
 
+#ifdef EVDEV_SUPPORT
+static struct evdev_dev*sysmouse_evdev;
+
+static void
+smdev_evdev_init(void)
+{
+   int i;
+
+   sysmouse_evdev = evdev_alloc();
+   evdev_set_name(sysmouse_evdev, "System mouse");
+   evdev_set_phys(sysmouse_evdev, "sysmouse");
+   evdev_set_id(sysmouse_evdev, BUS_VIRTUAL, 0, 0, 0);
+   evdev_support_prop(sysmouse_evdev, INPUT_PROP_POINTER);
+   evdev_support_event(sysmouse_evdev, EV_SYN);
+   evdev_support_event(sysmouse_evdev, EV_REL);
+   evdev_support_event(sysmouse_evdev, EV_KEY);
+   evdev_support_rel(sysmouse_evdev, REL_X);
+   evdev_support_rel(sysmouse_evdev, REL_Y);
+   evdev_support_rel(sysmouse_evdev, REL_WHEEL);
+   evdev_support_rel(sysmouse_evdev, REL_HWHEEL);
+   for (i = 0; i < 8; i++)
+   evdev_support_key(sysmouse_evdev, BTN_MOUSE + i);
+   if (evdev_register(sysmouse_evdev)) {
+   evdev_free(sysmouse_evdev);
+   sysmouse_evdev = NULL;
+   }
+}
+
+static void
+smdev_evdev_write(int x, int y, int z, int buttons)
+{
+
+   if (sysmouse_evdev == NULL || !(evdev_rcpt_mask & EVDEV_RCPT_SYSMOUSE))
+   return;
+
+   evdev_push_event(sysmouse_evdev, EV_REL, REL_X, x);
+   evdev_push_event(sysmouse_evdev, EV_REL, REL_Y, y);
+   

svn commit: r309822 - head/sys/dev/iwn

2016-12-10 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Dec 10 17:59:34 2016
New Revision: 309822
URL: https://svnweb.freebsd.org/changeset/base/309822

Log:
  [iwn] Perform BUS_DMASYNC_PREREAD when initializing RX buffer
  
  BUS_DMASYNC_PREREAD is required when setting up RX buffer, otherwise
  data provided by card can be overwritten by data evicted from cache
  
  Also use proper tag when setting up RX descriptor
  
  Reviewed by:  adrian, avos, ivadasz
  Differential Revision:https://reviews.freebsd.org/D8717

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==
--- head/sys/dev/iwn/if_iwn.c   Sat Dec 10 17:06:55 2016(r309821)
+++ head/sys/dev/iwn/if_iwn.c   Sat Dec 10 17:59:34 2016(r309822)
@@ -1910,6 +1910,9 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
goto fail;
}
 
+   bus_dmamap_sync(ring->data_dmat, data->map,
+   BUS_DMASYNC_PREREAD);
+
/* Set physical address of RX buffer (256-byte aligned). */
ring->desc[i] = htole32(paddr >> 8);
}
@@ -3040,14 +3043,19 @@ iwn_rx_done(struct iwn_softc *sc, struct
if (error != 0 && error != EFBIG) {
panic("%s: could not load old RX mbuf", __func__);
}
+   bus_dmamap_sync(ring->data_dmat, data->map,
+   BUS_DMASYNC_PREREAD);
/* Physical address may have changed. */
ring->desc[ring->cur] = htole32(paddr >> 8);
-   bus_dmamap_sync(ring->data_dmat, ring->desc_dma.map,
+   bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
BUS_DMASYNC_PREWRITE);
counter_u64_add(ic->ic_ierrors, 1);
return;
}
 
+   bus_dmamap_sync(ring->data_dmat, data->map,
+   BUS_DMASYNC_PREREAD);
+
m = data->m;
data->m = m1;
/* Update RX descriptor. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r308942 - in head/sys/modules: . bytgpio

2016-11-24 Thread Oleksandr Tymoshenko

> On Nov 24, 2016, at 11:46 AM, Ed Maste  wrote:
> 
> On 21 November 2016 at 14:47, Oleksandr Tymoshenko  wrote:
>> Author: gonzo
>> Date: Mon Nov 21 19:47:37 2016
>> New Revision: 308942
>> URL: https://svnweb.freebsd.org/changeset/base/308942
>> 
>> Log:
>>  [bytgpio] Add module for bytgpio(4)
> 
> It looks like this breaks tinderbox for PC98:
> 
> In file included from
> /scratch/tmp/emaste/freebsd/sys/modules/bytgpio/../../dev/gpio/bytgpio.c:43:
> In file included from
> /scratch/tmp/emaste/freebsd/sys/contrib/dev/acpica/include/acpi.h:56:
> In file included from
> /scratch/tmp/emaste/freebsd/sys/contrib/dev/acpica/include/platform/acenv.h:194:
> /scratch/tmp/emaste/freebsd/sys/contrib/dev/acpica/include/platform/acfreebsd.h:72:10:
> fatal error: 'machine/acpica_machdep.h' file not found
> #include 
> ^
> 1 error generated.
> *** [bytgpio.o] Error code 1

Should be fixed by r309112 committed earlier today
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309112 - head/sys/modules

2016-11-24 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Nov 24 20:08:17 2016
New Revision: 309112
URL: https://svnweb.freebsd.org/changeset/base/309112

Log:
  [bytgpio] Fix pc98 build by disabling bytgpio module for this platform
  
  Reported by:  dim

Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Thu Nov 24 18:21:48 2016(r309111)
+++ head/sys/modules/Makefile   Thu Nov 24 20:08:17 2016(r309112)
@@ -552,7 +552,6 @@ _an=an
 _aout= aout
 _bktr= bktr
 _bxe=  bxe
-_bytgpio=  bytgpio
 _cardbus=  cardbus
 _cbb=  cbb
 _cpuctl=   cpuctl
@@ -609,6 +608,7 @@ _amdsbwd=   amdsbwd
 _amdtemp=  amdtemp
 _arcmsr=   arcmsr
 _asmc= asmc
+_bytgpio=  bytgpio
 _ciss= ciss
 _chromebook_platform=  chromebook_platform
 _cmx=  cmx
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309076 - head/sys/arm64/conf

2016-11-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Nov 24 00:45:52 2016
New Revision: 309076
URL: https://svnweb.freebsd.org/changeset/base/309076

Log:
  [rpi3] Move SOC_BRCM_BCM2837 from UP config to SMP one
  
  Now that BCM283x source are buildable with SMP option it cam be moved to
  GENERIC SMP config. SMP itself does not work on RPi3 yet due to lack of
  PSCI monitor which is work in progress at the moment

Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/arm64/conf/GENERIC-UP

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Thu Nov 24 00:45:00 2016(r309075)
+++ head/sys/arm64/conf/GENERIC Thu Nov 24 00:45:52 2016(r309076)
@@ -90,6 +90,7 @@ options   MALLOC_DEBUG_MAXZONES=8 # Separ
 optionsSOC_ALLWINNER_A64
 optionsSOC_CAVM_THUNDERX
 optionsSOC_HISI_HI6220
+optionsSOC_BRCM_BCM2837
 
 # Annapurna Alpine drivers
 device al_ccu  # Alpine Cache Coherency Unit

Modified: head/sys/arm64/conf/GENERIC-UP
==
--- head/sys/arm64/conf/GENERIC-UP  Thu Nov 24 00:45:00 2016
(r309075)
+++ head/sys/arm64/conf/GENERIC-UP  Thu Nov 24 00:45:52 2016
(r309076)
@@ -21,5 +21,3 @@
 includeGENERIC
 ident  GENERIC-UP
 nooptions  SMP
-
-optionsSOC_BRCM_BCM2837
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309074 - head/sys/arm/broadcom/bcm2835

2016-11-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Nov 24 00:39:17 2016
New Revision: 309074
URL: https://svnweb.freebsd.org/changeset/base/309074

Log:
  [rpi3] Fix SMP build for FreeBSD/arm64

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2836.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2836.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2836.c Thu Nov 24 00:15:32 2016
(r309073)
+++ head/sys/arm/broadcom/bcm2835/bcm2836.c Thu Nov 24 00:39:17 2016
(r309074)
@@ -362,7 +362,11 @@ bcm_lintc_ipi_dispatch(struct bcm_lintc_
 * and make sure that it's observed by everybody.
 */
bcm_lintc_write_4(sc, BCM_LINTC_MBOX0_CLR_REG(cpu), 1 << ipi);
+#if defined(__aarch64__)
+   dsb(sy);
+#else
dsb();
+#endif
intr_ipi_dispatch(ipi, tf);
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r308944 - head/sys/modules/bytgpio

2016-11-21 Thread Oleksandr Tymoshenko

> On Nov 21, 2016, at 1:07 PM, Hiren Panchasara  wrote:
> 
> Author: hiren
> Date: Mon Nov 21 21:07:43 2016
> New Revision: 308944
> URL: https://svnweb.freebsd.org/changeset/base/308944
> 
> Log:
>  r308942 broke kernel build.
>  Add acpi_if.h to module makefile to fix it.
> 
>  Submitted by:peter

Thanks. Sorry for breaking the build. 

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308941 - head/share/man/man4

2016-11-21 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Nov 21 19:46:10 2016
New Revision: 308941
URL: https://svnweb.freebsd.org/changeset/base/308941

Log:
  [bytgpio] Add bytgpio(4) man page with general description of the driver
  
  MFC after:3 days

Added:
  head/share/man/man4/bytgpio.4   (contents, props changed)
Modified:
  head/share/man/man4/Makefile

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileMon Nov 21 19:43:01 2016
(r308940)
+++ head/share/man/man4/MakefileMon Nov 21 19:46:10 2016
(r308941)
@@ -86,6 +86,7 @@ MAN=  aac.4 \
bt.4 \
bwi.4 \
bwn.4 \
+   ${_bytgpio.4} \
capsicum.4 \
cardbus.4 \
carp.4 \
@@ -774,6 +775,7 @@ _amdsmb.4=  amdsmb.4
 _amdtemp.4=amdtemp.4
 _asmc.4=   asmc.4
 _bxe.4=bxe.4
+_bytgpio.4=bytgpio.4
 _coretemp.4=   coretemp.4
 _cpuctl.4= cpuctl.4
 _dpms.4=   dpms.4

Added: head/share/man/man4/bytgpio.4
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/share/man/man4/bytgpio.4   Mon Nov 21 19:46:10 2016
(r308941)
@@ -0,0 +1,55 @@
+.\" Copyright (c) 2016
+.\"    Oleksandr Tymoshenko .  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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd November 20, 2016
+.Dt BYTGPIO 4
+.Os
+.Sh NAME
+.Nm bytgpio
+.Nd Intel Bay Trail SoC GPIO controller
+.Sh SYNOPSIS
+.Cd "device gpio"
+.Cd "device bytgpio"
+.Sh DESCRIPTION
+The
+.Nm
+is a driver for GPIO controller that can be found in Intel's Bay Trail SoC 
family.
+.Pp
+Bay Trail SoC has three banks of GPIO pins exposed to userland as /dev/gpiocN,
+where N is 0, 1, and 2. Pins in each bank are pre-named to match names
+on boards schematics: GPIO_S0_SCnn, GPIO_S0_NCnn, and GPIO_S5_nn.
+.Sh SEE ALSO
+.Xr gpio 3 ,
+.Xr gpio 4 ,
+.Xr gpioctl 8
+.Sh HISTORY
+The
+.Nm
+manual page first appeared in
+.Fx 12.0 .
+.Sh AUTHORS
+This driver and man page was written by
+.An Oleksandr Tymoshenko Aq Mt go...@freebsd.org .
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308942 - in head/sys/modules: . bytgpio

2016-11-21 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Nov 21 19:47:37 2016
New Revision: 308942
URL: https://svnweb.freebsd.org/changeset/base/308942

Log:
  [bytgpio] Add module for bytgpio(4)
  
  MFC after:3 days

Added:
  head/sys/modules/bytgpio/
  head/sys/modules/bytgpio/Makefile   (contents, props changed)
Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Mon Nov 21 19:46:10 2016(r308941)
+++ head/sys/modules/Makefile   Mon Nov 21 19:47:37 2016(r308942)
@@ -63,6 +63,7 @@ SUBDIR=   \
bwi \
bwn \
bwn_pci \
+   ${_bytgpio} \
cam \
${_canbepm} \
${_canbus} \
@@ -551,6 +552,7 @@ _an=an
 _aout= aout
 _bktr= bktr
 _bxe=  bxe
+_bytgpio=  bytgpio
 _cardbus=  cardbus
 _cbb=  cbb
 _cpuctl=   cpuctl

Added: head/sys/modules/bytgpio/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/modules/bytgpio/Makefile   Mon Nov 21 19:47:37 2016
(r308942)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../dev/gpio
+KMOD=  bytgpio
+SRCS=  bytgpio.c
+SRCS+= device_if.h bus_if.h gpio_if.h
+
+.include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308940 - head/sys/dev/gpio

2016-11-21 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Nov 21 19:43:01 2016
New Revision: 308940
URL: https://svnweb.freebsd.org/changeset/base/308940

Log:
  [bytgpio] prepare bytgpio(4) for modularization
  
  - Add detach method
  - module should depend on gpiobus, not gpio

Modified:
  head/sys/dev/gpio/bytgpio.c

Modified: head/sys/dev/gpio/bytgpio.c
==
--- head/sys/dev/gpio/bytgpio.c Mon Nov 21 19:38:57 2016(r308939)
+++ head/sys/dev/gpio/bytgpio.c Mon Nov 21 19:43:01 2016(r308940)
@@ -86,6 +86,7 @@ struct bytgpio_softc {
 
 static int bytgpio_probe(device_t dev);
 static int bytgpio_attach(device_t dev);
+static int bytgpio_detach(device_t dev);
 
 #defineSCORE_UID   1
 #defineSCORE_BANK_PREFIX   "GPIO_S0_SC"
@@ -567,6 +568,8 @@ bytgpio_attach(device_t dev)
return (ENXIO);
}
 
+   BYTGPIO_LOCK_INIT(sc);
+
switch (uid) {
case SCORE_UID:
sc->sc_npins = SCORE_PINS;
@@ -599,8 +602,6 @@ bytgpio_attach(device_t dev)
goto error;
}
 
-   BYTGPIO_LOCK_INIT(sc);
-
for (pin = 0; pin < sc->sc_npins; pin++) {
reg = BYGPIO_PIN_REGISTER(sc, pin, BYTGPIO_PCONF0);
val = bytgpio_read_4(sc, reg);
@@ -618,13 +619,39 @@ bytgpio_attach(device_t dev)
return (0);
 
 error:
+   BYTGPIO_LOCK_DESTROY(sc);
+
return (ENXIO);
 }
 
+
+static int
+bytgpio_detach(device_t dev)
+{
+   struct bytgpio_softc*sc;
+
+   sc = device_get_softc(dev);
+
+   if (sc->sc_busdev)
+   gpiobus_detach_bus(dev);
+
+   BYTGPIO_LOCK_DESTROY(sc);
+
+   if (sc->sc_pad_funcs)
+   free(sc->sc_pad_funcs, M_DEVBUF);
+
+   if (sc->sc_mem_res != NULL)
+   bus_release_resource(dev, SYS_RES_MEMORY,
+   sc->sc_mem_rid, sc->sc_mem_res);
+
+   return (0);
+}
+
 static device_method_t bytgpio_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bytgpio_probe),
DEVMETHOD(device_attach, bytgpio_attach),
+   DEVMETHOD(device_detach, bytgpio_detach),
 
/* GPIO protocol */
DEVMETHOD(gpio_get_bus, bytgpio_get_bus),
@@ -649,4 +676,4 @@ static driver_t bytgpio_driver = {
 static devclass_t bytgpio_devclass;
 DRIVER_MODULE(bytgpio, acpi, bytgpio_driver, bytgpio_devclass, 0, 0);
 MODULE_DEPEND(bytgpio, acpi, 1, 1, 1);
-MODULE_DEPEND(bytgpio, gpio, 1, 1, 1);
+MODULE_DEPEND(bytgpio, gpiobus, 1, 1, 1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308899 - head/sys/boot/fdt/dts/arm

2016-11-20 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Nov 20 18:56:04 2016
New Revision: 308899
URL: https://svnweb.freebsd.org/changeset/base/308899

Log:
  [FDT] Remove empty wrapper for upstream am335x-evm.dts
  
  Remove empty wrapper for sys/gnu version of am335x-evm.dts located in
  sys/boot/fdt, with current include paths priority it's recursive #include
  and current build system can find file in sys/gnu when generating dtb
  
  Reported by:  Jared McNeill

Deleted:
  head/sys/boot/fdt/dts/arm/am335x-evm.dts
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308898 - head/sys/dev/gpio

2016-11-20 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sun Nov 20 18:38:32 2016
New Revision: 308898
URL: https://svnweb.freebsd.org/changeset/base/308898

Log:
  [bytgpio] Fix USB disconnect event after listsing pins on gpioc2
  
  - Do not set input flag when reading value from GPIO pin, it is not
required and for gpioc2(S5 bank) setting both input and output flags
leads to some kind of electric interference (curren drop?) that
causes USB devices to disconnect
  
  - Check pad configuration when attaching device and provide IN/OUT
capabilities only for pads that are configured as GPIO. Do not let
user code to configure or change value of non-GPIO pads. There is
no information for NC bank in intel's datasheet so for now function
check is ignored for pins in it
  
  Reported by:  Frank H.
  MFC after:3 days

Modified:
  head/sys/dev/gpio/bytgpio.c

Modified: head/sys/dev/gpio/bytgpio.c
==
--- head/sys/dev/gpio/bytgpio.c Sun Nov 20 18:21:42 2016(r308897)
+++ head/sys/dev/gpio/bytgpio.c Sun Nov 20 18:38:32 2016(r308898)
@@ -60,6 +60,16 @@ __FBSDID("$FreeBSD$");
 #defineBYTGPIO_ASSERT_LOCKED(_sc)  mtx_assert(&(_sc)->sc_mtx, 
MA_OWNED)
 #defineBYTGPIO_ASSERT_UNLOCKED(_sc)mtx_assert(&(_sc)->sc_mtx, 
MA_NOTOWNED)
 
+struct pinmap_info {
+int reg;
+int pad_func;
+};
+
+/* Ignore function check, no info is available at the moment */
+#definePADCONF_FUNC_ANY-1
+
+#defineGPIO_PIN_MAP(r, f) { .reg = (r), .pad_func = (f) }
+
 struct bytgpio_softc {
ACPI_HANDLE sc_handle;
device_tsc_dev;
@@ -69,44 +79,211 @@ struct bytgpio_softc {
struct resource *sc_mem_res;
int sc_npins;
const char* sc_bank_prefix;
-   const int   *sc_pinpad_map;
+   const struct pinmap_info*sc_pinpad_map;
+   /* List of current functions for pads shared by GPIO */
+   int *sc_pad_funcs;
 };
 
 static int bytgpio_probe(device_t dev);
 static int bytgpio_attach(device_t dev);
 
-#define SCORE_UID  1
-#define SCORE_BANK_PREFIX  "GPIO_S0_SC"
-const int bytgpio_score_pins[] = {
-   85, 89, 93, 96, 99, 102, 98, 101, 34, 37, 36, 38, 39, 35, 40,
-   84, 62, 61, 64, 59, 54, 56, 60, 55, 63, 57, 51, 50, 53, 47,
-   52, 49, 48, 43, 46, 41, 45, 42, 58, 44, 95, 105, 70, 68, 67,
-   66, 69, 71, 65, 72, 86, 90, 88, 92, 103, 77, 79, 83, 78, 81,
-   80, 82, 13, 12, 15, 14, 17, 18, 19, 16, 2, 1, 0, 4, 6, 7, 9,
-   8, 33, 32, 31, 30, 29, 27, 25, 28, 26, 23, 21, 20, 24, 22, 5,
-   3, 10, 11, 106, 87, 91, 104, 97, 100
+#defineSCORE_UID   1
+#defineSCORE_BANK_PREFIX   "GPIO_S0_SC"
+const struct pinmap_info bytgpio_score_pins[] = {
+   GPIO_PIN_MAP(85, 0),
+   GPIO_PIN_MAP(89, 0),
+   GPIO_PIN_MAP(93, 0),
+   GPIO_PIN_MAP(96, 0),
+   GPIO_PIN_MAP(99, 0),
+   GPIO_PIN_MAP(102, 0),
+   GPIO_PIN_MAP(98, 0),
+   GPIO_PIN_MAP(101, 0),
+   GPIO_PIN_MAP(34, 0),
+   GPIO_PIN_MAP(37, 0),
+   GPIO_PIN_MAP(36, 0),
+   GPIO_PIN_MAP(38, 0),
+   GPIO_PIN_MAP(39, 0),
+   GPIO_PIN_MAP(35, 0),
+   GPIO_PIN_MAP(40, 0),
+   GPIO_PIN_MAP(84, 0),
+   GPIO_PIN_MAP(62, 0),
+   GPIO_PIN_MAP(61, 0),
+   GPIO_PIN_MAP(64, 0),
+   GPIO_PIN_MAP(59, 0),
+   GPIO_PIN_MAP(54, 0),
+   GPIO_PIN_MAP(56, 0),
+   GPIO_PIN_MAP(60, 0),
+   GPIO_PIN_MAP(55, 0),
+   GPIO_PIN_MAP(63, 0),
+   GPIO_PIN_MAP(57, 0),
+   GPIO_PIN_MAP(51, 0),
+   GPIO_PIN_MAP(50, 0),
+   GPIO_PIN_MAP(53, 0),
+   GPIO_PIN_MAP(47, 0),
+   GPIO_PIN_MAP(52, 0),
+   GPIO_PIN_MAP(49, 0),
+   GPIO_PIN_MAP(48, 0),
+   GPIO_PIN_MAP(43, 0),
+   GPIO_PIN_MAP(46, 0),
+   GPIO_PIN_MAP(41, 0),
+   GPIO_PIN_MAP(45, 0),
+   GPIO_PIN_MAP(42, 0),
+   GPIO_PIN_MAP(58, 0),
+   GPIO_PIN_MAP(44, 0),
+   GPIO_PIN_MAP(95, 0),
+   GPIO_PIN_MAP(105, 0),
+   GPIO_PIN_MAP(70, 0),
+   GPIO_PIN_MAP(68, 0),
+   GPIO_PIN_MAP(67, 0),
+   GPIO_PIN_MAP(66, 0),
+   GPIO_PIN_MAP(69, 0),
+   GPIO_PIN_MAP(71, 0),
+   GPIO_PIN_MAP(65, 0),
+   GPIO_PIN_MAP(72, 0),
+   GPIO_PIN_MAP(86, 0),
+   GPIO_PIN_MAP(90, 0),
+   GPIO_PIN_MAP(88, 0),
+   GPIO_PIN_MAP(92, 0),
+   GPIO_PIN_MAP(103, 0),
+   GPIO_PIN_MAP(77, 0),
+   GPIO_PIN_MAP(79, 0),
+   GPIO_PIN_MAP(83, 0),
+   GPIO_PIN_MAP(78, 0),
+   GPIO_PIN_MAP(81, 0),
+   GPIO_PIN_MAP(80, 0),
+   GPIO_PIN_MAP(82, 0),
+   GPIO_PIN_MAP(13, 0),
+   GPIO_PIN_MAP(12, 0),
+   GPIO_PIN_MAP(15, 0),
+   GPIO_PIN_MAP(14, 0),
+   GPIO_PIN_MAP(17, 0),
+   GPIO_PIN_MAP(18, 0),
+   GPIO_PIN_MAP(19, 0),
+   GPIO_PIN_MAP(16, 0),
+   GPIO_PIN_MAP(2, 0),
+   GPIO_PIN_MAP(1, 0),
+ 

svn commit: r308668 - in head/sys: dev/kbdmux modules/kbdmux

2016-11-14 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Nov 15 04:12:19 2016
New Revision: 308668
URL: https://svnweb.freebsd.org/changeset/base/308668

Log:
  [evdev] Add evdev support to kbdmux(4) driver
  
  To enable event sourcing from kbdmux(4) kern.evdev.rcpt_mask value
  should have bit 1 set (this is default)
  
  Submitted by: Vladimir Kondratiev 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D8437

Modified:
  head/sys/dev/kbdmux/kbdmux.c
  head/sys/modules/kbdmux/Makefile

Modified: head/sys/dev/kbdmux/kbdmux.c
==
--- head/sys/dev/kbdmux/kbdmux.cTue Nov 15 03:43:10 2016
(r308667)
+++ head/sys/dev/kbdmux/kbdmux.cTue Nov 15 04:12:19 2016
(r308668)
@@ -32,6 +32,7 @@
  */
 
 #include "opt_compat.h"
+#include "opt_evdev.h"
 #include "opt_kbd.h"
 #include "opt_kbdmux.h"
 
@@ -64,6 +65,11 @@
 
 #include 
 
+#ifdef EVDEV_SUPPORT
+#include 
+#include 
+#endif
+
 #define KEYBOARD_NAME  "kbdmux"
 
 MALLOC_DECLARE(M_KBDMUX);
@@ -159,6 +165,11 @@ struct kbdmux_state
u_intks_composed_char; /* composed char code */
u_char   ks_prefix; /* AT scan code prefix */
 
+#ifdef EVDEV_SUPPORT
+   struct evdev_dev *   ks_evdev;
+   int  ks_evdev_state;
+#endif
+
SLIST_HEAD(, kbdmux_kbd) ks_kbds;   /* keyboards */
 
KBDMUX_LOCK_DECL_GLOBAL;
@@ -371,6 +382,12 @@ static keyboard_switch_t kbdmuxsw = {
.diag = genkbd_diag,
 };
 
+#ifdef EVDEV_SUPPORT
+static const struct evdev_methods kbdmux_evdev_methods = {
+   .ev_event = evdev_ev_kbd_event,
+};
+#endif
+
 /*
  * Return the number of found keyboards
  */
@@ -404,6 +421,10 @@ kbdmux_init(int unit, keyboard_t **kbdp,
 accentmap_t*accmap = NULL;
 fkeytab_t  *fkeymap = NULL;
int  error, needfree, fkeymap_size, delay[2];
+#ifdef EVDEV_SUPPORT
+   struct evdev_dev *evdev;
+   char phys_loc[NAMELEN];
+#endif
 
if (*kbdp == NULL) {
*kbdp = kbd = malloc(sizeof(*kbd), M_KBDMUX, M_NOWAIT | M_ZERO);
@@ -464,6 +485,30 @@ kbdmux_init(int unit, keyboard_t **kbdp,
delay[1] = kbd->kb_delay2;
kbdmux_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
 
+#ifdef EVDEV_SUPPORT
+   /* register as evdev provider */
+   evdev = evdev_alloc();
+   evdev_set_name(evdev, "System keyboard multiplexer");
+   snprintf(phys_loc, NAMELEN, KEYBOARD_NAME"%d", unit);
+   evdev_set_phys(evdev, phys_loc);
+   evdev_set_id(evdev, BUS_VIRTUAL, 0, 0, 0);
+   evdev_set_methods(evdev, kbd, &kbdmux_evdev_methods);
+   evdev_support_event(evdev, EV_SYN);
+   evdev_support_event(evdev, EV_KEY);
+   evdev_support_event(evdev, EV_LED);
+   evdev_support_event(evdev, EV_REP);
+   evdev_support_all_known_keys(evdev);
+   evdev_support_led(evdev, LED_NUML);
+   evdev_support_led(evdev, LED_CAPSL);
+   evdev_support_led(evdev, LED_SCROLLL);
+
+   if (evdev_register(evdev))
+   evdev_free(evdev);
+   else
+   state->ks_evdev = evdev;
+   state->ks_evdev_state = 0;
+#endif
+
KBD_INIT_DONE(kbd);
}
 
@@ -532,6 +577,10 @@ kbdmux_term(keyboard_t *kbd)
 
kbd_unregister(kbd);
 
+#ifdef EVDEV_SUPPORT
+   evdev_free(state->ks_evdev);
+#endif
+
KBDMUX_LOCK_DESTROY(state);
bzero(state, sizeof(*state));
free(state, M_KBDMUX);
@@ -694,6 +743,20 @@ next_code:
 
kbd->kb_count ++;
 
+#ifdef EVDEV_SUPPORT
+   /* push evdev event */
+   if (evdev_rcpt_mask & EVDEV_RCPT_KBDMUX && state->ks_evdev != NULL) {
+   uint16_t key = evdev_scancode2key(&state->ks_evdev_state,
+   scancode);
+
+   if (key != KEY_RESERVED) {
+   evdev_push_event(state->ks_evdev, EV_KEY,
+   key, scancode & 0x80 ? 0 : 1);
+   evdev_sync(state->ks_evdev);
+   }
+   }
+#endif
+
/* return the byte as is for the K_RAW mode */
if (state->ks_mode == K_RAW) {
KBDMUX_UNLOCK(state);
@@ -1120,7 +1183,11 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd
}
 
KBD_LED_VAL(kbd) = *(int *)arg;
-
+#ifdef EVDEV_SUPPORT
+   if (state->ks_evdev != NULL &&
+   evdev_rcpt_mask & EVDEV_RCPT_KBDMUX)
+   evdev_push_leds(state->ks_evdev, *(int *)arg);
+#endif
/* KDSETLED on all slave keyboards */
SLIST_FOREACH(k, &state->ks_kbds, next)
(void)kbdd_ioctl(k->kbd, KDSETLED, arg);
@@ -1197,7 +1264,11 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd
 

svn commit: r308581 - head/sys/modules/rpi_ft5406

2016-11-12 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Nov 12 19:05:41 2016
New Revision: 308581
URL: https://svnweb.freebsd.org/changeset/base/308581

Log:
  [rpi_ft5406] Add missing dependency on mbox_if.h
  
  Submitted by: hselasky
  MFC after:ASAP

Modified:
  head/sys/modules/rpi_ft5406/Makefile

Modified: head/sys/modules/rpi_ft5406/Makefile
==
--- head/sys/modules/rpi_ft5406/MakefileSat Nov 12 19:03:23 2016
(r308580)
+++ head/sys/modules/rpi_ft5406/MakefileSat Nov 12 19:05:41 2016
(r308581)
@@ -5,6 +5,6 @@
 KMOD=  rpi_ft5406
 SRCS=  bcm2835_ft5406.c
 
-SRCS+= bus_if.h device_if.h ofw_bus_if.h
+SRCS+= bus_if.h device_if.h mbox_if.h ofw_bus_if.h
 
 .include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r308428 - in head/sys: conf dev/gpio modules/gpio/gpioled

2016-11-07 Thread Oleksandr Tymoshenko
 state = -1;
-   else {
-   device_printf(dev,
-   "unknown value for default-state in FDT\n");
-   }
-   OF_prop_free(default_state);
-   }
-
-   name = NULL;
-   if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1)
-   OF_getprop_alloc(node, "name", 1, (void **)&name);
-#else
if (resource_string_value(device_get_name(dev), 
device_get_unit(dev), "name", &name))
name = NULL;
resource_int_value(device_get_name(dev),
device_get_unit(dev), "invert", &sc->sc_invert);
-#endif
 
sc->sc_leddev = led_create_state(gpioled_control, sc, name ? name :
device_get_nameunit(dev), state);
-#ifdef FDT
-   if (name != NULL)
-   OF_prop_free(name);
-#endif
 
return (0);
 }
@@ -234,9 +138,6 @@ static devclass_t gpioled_devclass;
 
 static device_method_t gpioled_methods[] = {
/* Device interface */
-#ifdef FDT
-   DEVMETHOD(device_identify,  gpioled_identify),
-#endif
DEVMETHOD(device_probe, gpioled_probe),
DEVMETHOD(device_attach,gpioled_attach),
DEVMETHOD(device_detach,gpioled_detach),

Added: head/sys/dev/gpio/gpioled_fdt.c
======
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/gpio/gpioled_fdt.c Mon Nov  7 21:15:39 2016
(r308428)
@@ -0,0 +1,230 @@
+/*-
+ * Copyright (c) 2009 Oleksandr Tymoshenko 
+ * 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$");
+
+#include "opt_platform.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include "gpiobus_if.h"
+
+struct gpioled
+{
+   struct gpioleds_softc   *parent_sc;
+   gpio_pin_t  pin;
+   struct cdev *leddev;
+};
+
+struct gpioleds_softc
+{
+   device_tsc_dev;
+   device_tsc_busdev;
+   struct gpioled  *sc_leds;
+   int sc_total_leds;
+};
+
+static void gpioled_control(void *, int);
+static int gpioled_probe(device_t);
+static int gpioled_attach(device_t);
+static int gpioled_detach(device_t);
+
+static void
+gpioled_control(void *priv, int onoff)
+{
+   struct gpioled *led;
+
+   led = (struct gpioled *)priv;
+   if (led->pin)
+   gpio_pin_set_active(led->pin, onoff);
+}
+
+static void
+gpioleds_attach_led(struct gpioleds_softc *sc, phandle_t node,
+struct gpioled *led)
+{
+   char *name;
+   int state, err;
+   char *default_state;
+
+   led->parent_sc = sc;
+
+   state = 0;
+   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 {
+   state = -1;
+   device_printf(sc->sc_dev,
+   "unknown value for default-state in FDT\n");
+   }
+   OF_prop_free(default_state);
+   }
+
+   name = NULL;
+   if (OF_getprop_alloc(node, "label&quo

Re: svn commit: r308424 - head/sys/arm/broadcom/bcm2835

2016-11-07 Thread Oleksandr Tymoshenko

> On Nov 7, 2016, at 11:51 AM, Hans Petter Selasky  wrote:
> 
> On 11/07/16 20:32, Hans Petter Selasky wrote:
>> On 11/07/16 20:23, Oleksandr Tymoshenko wrote:
>>> 
>>>> On Nov 7, 2016, at 10:27 AM, Hans Petter Selasky 
>>>> wrote:
>>>> 
>>>> On 11/07/16 18:38, Oleksandr Tymoshenko wrote:
>>>>> +bcm2835_audio_unlock(sc);
>>>>> +cv_signal(&sc->worker_cv);
>>>> 
>>>> 
>>>> Shouldn't cv_signal() be done locked, so that you don't loose any
>>>> transactions? CV's only wakeup the treads that are sleeping right
>>>> there and then.
>>> 
>>> Hi Hans,
>>> 
>>> In this case it doesn’t matter. bcm2835_audio_xxx lock functions are
>>> used to keep channel state consistent. The actual audio hw
>>> reprogramming happens in worker thread which only picks up latest
>>> state of the virtual channel, there is no need to run every
>>> transaction in sequence.
>>> 
>> 
>> Hi,
>> 
>> It is not about running in sequence, but that if the worker thread is
>> not sleeping, but on the way to sleep, it will never get woken up unless
>> you use proper locks here!
>> 
>> --HPS
> 
> Hi,
> 
> Also the teardown sequence for the worker thread looks a bit broken, that it 
> doesn't wait for the thread to exit.
> 
> I've made a patch, attached which I think is the right way to do it.
> 
> Try opening and closing /dev/dsp in a loop with some DSP ioctls and see what 
> happens.

Thanks for patch Hans. Looks good to me.  I’ll test and commit it. 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r308427 - head/sys/cddl/dev/dtrace/arm

2016-11-07 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Nov  7 20:02:18 2016
New Revision: 308427
URL: https://svnweb.freebsd.org/changeset/base/308427

Log:
  Fix include order as required post r308415

Modified:
  head/sys/cddl/dev/dtrace/arm/dtrace_asm.S

Modified: head/sys/cddl/dev/dtrace/arm/dtrace_asm.S
==
--- head/sys/cddl/dev/dtrace/arm/dtrace_asm.S   Mon Nov  7 18:29:21 2016
(r308426)
+++ head/sys/cddl/dev/dtrace/arm/dtrace_asm.S   Mon Nov  7 20:02:18 2016
(r308427)
@@ -32,8 +32,8 @@
 #include 
 #include 
 
-#include 
 #include 
+#include 
 
 #include "assym.s"
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r308424 - head/sys/arm/broadcom/bcm2835

2016-11-07 Thread Oleksandr Tymoshenko

> On Nov 7, 2016, at 10:27 AM, Hans Petter Selasky  wrote:
> 
> On 11/07/16 18:38, Oleksandr Tymoshenko wrote:
>> +bcm2835_audio_unlock(sc);
>> +cv_signal(&sc->worker_cv);
> 
> 
> Shouldn't cv_signal() be done locked, so that you don't loose any 
> transactions? CV's only wakeup the treads that are sleeping right there and 
> then.

Hi Hans, 

In this case it doesn’t matter. bcm2835_audio_xxx lock functions are used to 
keep channel state consistent. The actual audio hw reprogramming happens in 
worker thread which only picks up latest state of the virtual channel, there is 
no need to run every transaction in sequence. 

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r308424 - head/sys/arm/broadcom/bcm2835

2016-11-07 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Nov  7 17:38:39 2016
New Revision: 308424
URL: https://svnweb.freebsd.org/changeset/base/308424

Log:
  Fix locking in bcm2835_audio driver
  
  - Move all VCHI activity to worker thread: channel methods are called with
  non-sleepable lock held and VCHI uses sleepable lock.
  
  - In worker thread use sx(9) lock instead of mutex(9) for the same reason.
  
  PR:   213801, 205979

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_audio.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_audio.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_audio.c   Mon Nov  7 17:34:19 
2016(r308423)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_audio.c   Mon Nov  7 17:38:39 
2016(r308424)
@@ -104,14 +104,17 @@ struct bcm2835_audio_info {
struct intr_config_hook intr_hook;
 
/* VCHI data */
-   struct mtx vchi_lock;
+   struct sx vchi_lock;
 
VCHI_INSTANCE_T vchi_instance;
VCHI_CONNECTION_T *vchi_connection;
VCHI_SERVICE_HANDLE_T vchi_handle;
 
-   struct mtx data_lock;
-   struct cv data_cv;
+   struct sx worker_lock;
+   struct cv worker_cv;
+
+   bool parameters_update_pending;
+   bool controls_update_pending;
 
/* Unloadign module */
int unloading;
@@ -121,8 +124,8 @@ struct bcm2835_audio_info {
 #define bcm2835_audio_unlock(_ess) snd_mtxunlock((_ess)->lock)
 #define bcm2835_audio_lock_assert(_ess) snd_mtxassert((_ess)->lock)
 
-#define VCHIQ_VCHI_LOCK(sc)mtx_lock(&(sc)->vchi_lock)
-#define VCHIQ_VCHI_UNLOCK(sc)  mtx_unlock(&(sc)->vchi_lock)
+#define VCHIQ_VCHI_LOCK(sc)sx_xlock(&(sc)->vchi_lock)
+#define VCHIQ_VCHI_UNLOCK(sc)  sx_xunlock(&(sc)->vchi_lock)
 
 static const char *
 dest_description(uint32_t dest)
@@ -175,7 +178,7 @@ bcm2835_audio_callback(void *param, cons
chn_intr(sc->pch.channel);
 
if (perr || ch->free_buffer >= VCHIQ_AUDIO_PACKET_SIZE)
-   cv_signal(&sc->data_cv);
+   cv_signal(&sc->worker_cv);
} else
printf("%s: unknown m.type: %d\n", __func__, m.type);
 }
@@ -261,8 +264,6 @@ bcm2835_audio_start(struct bcm2835_audio
if (sc->vchi_handle != VCHIQ_SERVICE_HANDLE_INVALID) {
vchi_service_use(sc->vchi_handle);
 
-   bcm2835_audio_reset_channel(ch);
-
m.type = VC_AUDIO_MSG_TYPE_START;
ret = vchi_msg_queue(sc->vchi_handle,
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
@@ -324,7 +325,7 @@ bcm2835_audio_open(struct bcm2835_audio_
 }
 
 static void
-bcm2835_audio_update_controls(struct bcm2835_audio_info *sc)
+bcm2835_audio_update_controls(struct bcm2835_audio_info *sc, uint32_t volume, 
uint32_t dest)
 {
VC_AUDIO_MSG_T m;
int ret, db;
@@ -334,10 +335,10 @@ bcm2835_audio_update_controls(struct bcm
vchi_service_use(sc->vchi_handle);
 
m.type = VC_AUDIO_MSG_TYPE_CONTROL;
-   m.u.control.dest = sc->dest;
-   if (sc->volume > 99)
-   sc->volume = 99;
-   db = db_levels[sc->volume/5];
+   m.u.control.dest = dest;
+   if (volume > 99)
+   volume = 99;
+   db = db_levels[volume/5];
m.u.control.volume = VCHIQ_AUDIO_VOLUME(db);
 
ret = vchi_msg_queue(sc->vchi_handle,
@@ -352,7 +353,7 @@ bcm2835_audio_update_controls(struct bcm
 }
 
 static void
-bcm2835_audio_update_params(struct bcm2835_audio_info *sc, struct 
bcm2835_audio_chinfo *ch)
+bcm2835_audio_update_params(struct bcm2835_audio_info *sc, uint32_t fmt, 
uint32_t speed)
 {
VC_AUDIO_MSG_T m;
int ret;
@@ -362,9 +363,9 @@ bcm2835_audio_update_params(struct bcm28
vchi_service_use(sc->vchi_handle);
 
m.type = VC_AUDIO_MSG_TYPE_CONFIG;
-   m.u.config.channels = AFMT_CHANNEL(ch->fmt);
-   m.u.config.samplerate = ch->spd;
-   m.u.config.bps = AFMT_BIT(ch->fmt);
+   m.u.config.channels = AFMT_CHANNEL(fmt);
+   m.u.config.samplerate = speed;
+   m.u.config.bps = AFMT_BIT(fmt);
 
ret = vchi_msg_queue(sc->vchi_handle,
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
@@ -474,29 +475,61 @@ bcm2835_audio_worker(void *data)
 {
struct bcm2835_audio_info *sc = (struct bcm2835_audio_info *)data;
struct bcm2835_audio_chinfo *ch = &sc->pch;
-   mtx_lock(&sc->data_lock);
+   uint32_t speed, format;
+   uint32_t volume, dest;
+   bool parameters_changed, controls_changed;
+
+   sx_slock(&sc->worker_lock);
while(1) {
 
if (sc->unloading)
break;
 
+   parameters_changed = false;
+   controls_changed

<    1   2   3   4   5   6   7   >