Files
beagleconnect-freedom/sw/linux/0003-serdev-add-of_-helper-to-get-serdev-controller.patch
Vaishnav M A 853d3461e1 sw: linux: add mikrobus driver update patches
mikrobus driver works within buildroot but the click
device drivers are not being probed correctly:
in host /opt/gbridge.sh a hack for continously blinking the
led on the SensorTag/Launchpad is added(this background
transaction happening continously prevents some of the greybus
pm suspend events happening, which might have been the cause
for the kernel panic, with this continous background transfer
the kernel panic is not seen and qemu machine does not crash)

changes were tested using ATUSB, CC1352R SensorTag

Welcome to Buildroot
buildroot login: root
Password:
IFLP=`ifconfig | grep lowpan`
ip link set wpan0 down
iwpan phy phy0 set channel 0 26
iwpan dev wpan0 set pan_id 0xabcd
  ip link add link wpan0 name lowpan0 type lowpan
  ip link set lowpan0 up
ip link set wpan0 up
ip -6 addr add 2001:db8::2/64 dev lowpan0
sleep 1

killall -9 gbridge
sleep 1

sleep 5

gbridge > /dev/null 2&1 &
sleep 5
for i in `seq 1 100000`; do gpioset 0 6=1; gpioset 0 6=0; \
                         sleep 1; done

greybus 1-2.2: GMP VID=0x00000126, PID=0x00000126
greybus 1-2.2: DDBL1 Manufacturer=0x00000126, Product=0x00000126
greybus 1-2.2: excess descriptors in interface manifest
mikrobus:mikrobus_port_gb_register: mikrobus gb_probe , num cports= 3, manifest_size 252
mikrobus:mikrobus_port_gb_register: protocol added 11
mikrobus:mikrobus_port_gb_register: protocol added 3
mikrobus:mikrobus_port_gb_register: protocol added 2
mikrobus:mikrobus_port_register: registering port mikrobus-0
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 1, driver=bme280, protocol=3, reg=76
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 2, driver=opt3001, protocol=3, reg=44
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 3, driver=ams-iaq-core, protocol=3, reg=5a
mikrobus_manifest:mikrobus_manifest_parse:  Greybus Service Sample Application manifest parsed with 3 devices
mikrobus mikrobus-0: registering device : bme280
mikrobus mikrobus-0: registering device : opt3001
mikrobus mikrobus-0: registering device : ams-iaq-core

0-0044  0-005a  0-0076  i2c-0

Mem: 29624K used, 471572K free, 84K shrd, 624K buff, 5152K cached
CPU:   7% usr   4% sys   0% nic  86% idle   0% io   0% irq   1% sirq
Load average: 0.22 0.10 0.03 1/56 378
  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
  193   178 root     S    16060   3%   1% gbridge 2
  178   174 root     S     3744   1%   1% {gbridge.sh} /bin/sh -xv /opt/gbridge.
  312   174 root     R     1532   0%   1% top
   47     2 root     IW       0   0%   1% [kworker/0:3-eve]
   10     2 root     IW       0   0%   0% [rcu_sched]
    9     2 root     SW       0   0%   0% [ksoftirqd/0]
  173     1 root     S     3744   1%   0% /usr/sbin/iiod -D
  165     1 avahi    S     1924   0%   0% avahi-daemon: running [buildroot.local
  174     1 root     S     1548   0%   0% -sh
    1     0 root     S     1532   0%   0% init
  175     1 root     S     1528   0%   0% /sbin/getty -L tty1 0 vt100
  150     1 root     S     1528   0%   0% udhcpc -R -n -O search -p /var/run/udh
   64     1 root     S     1524   0%   0% /sbin/syslogd -n
   68     1 root     S     1520   0%   0% /sbin/klogd -n
  378   178 root     S     1520   0%   0% sleep 1
  115     1 dbus     S     1492   0%   0% dbus-daemon --system
  169     1 root     S     1080   0%   0% /usr/sbin/dropbear -R
   29     2 root     IW       0   0%   0% [kworker/u2:1-fl]
    7     2 root     IW       0   0%   0% [kworker/u2:0-gr]
   13     2 root     SW       0   0%   0% [kdevtmpfs]

Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
2021-01-13 13:33:35 +05:30

71 lines
2.3 KiB
Diff

From 5a117e6146ac68b67a563a931c11664b52b0a158 Mon Sep 17 00:00:00 2001
From: Vaishnav M A <vaishnav@beagleboard.org>
Date: Sun, 18 Oct 2020 06:28:30 +0530
Subject: [RFC PATCH 3/5] serdev: add of_ helper to get serdev controller
add of_find_serdev_controller_by_node to obtain a
serdev_controller from the device_node, which
can help if the serdev_device is not described
over device tree and instantiation of the device
happens from a different driver, for the same purpose
an option to not delete an empty serdev controller
is added.
Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
---
drivers/tty/serdev/core.c | 17 +++++++++++++++++
include/linux/serdev.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 01b248fdc264..85977b36ed7f 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -582,6 +582,17 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
return 0;
}
+struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node)
+{
+ struct device *dev = bus_find_device_by_of_node(&serdev_bus_type, node);
+
+ if (!dev)
+ return NULL;
+
+ return (dev->type == &serdev_ctrl_type) ? to_serdev_controller(dev) : NULL;
+}
+EXPORT_SYMBOL_GPL(of_find_serdev_controller_by_node);
+
#ifdef CONFIG_ACPI
#define SERDEV_ACPI_MAX_SCAN_DEPTH 32
@@ -779,6 +790,12 @@ int serdev_controller_add(struct serdev_controller *ctrl)
pm_runtime_enable(&ctrl->dev);
+ /* provide option to not delete a serdev controller without devices
+ * if property is present
+ */
+ if (device_property_present(&ctrl->dev, "force-empty-serdev-controller"))
+ return 0;
+
ret_of = of_serdev_register_devices(ctrl);
ret_acpi = acpi_serdev_register_devices(ctrl);
if (ret_of && ret_acpi) {
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 0d9c90a250b0..2e1eb4d17e1b 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -115,6 +115,8 @@ static inline struct serdev_controller *to_serdev_controller(struct device *d)
return container_of(d, struct serdev_controller, dev);
}
+struct serdev_controller *of_find_serdev_controller_by_node(struct device_node *node);
+
static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev)
{
return dev_get_drvdata(&serdev->dev);
--
2.25.1