You've already forked beagleconnect-freedom
mirror of
https://github.com/beagleboard/beagleconnect-freedom.git
synced 2026-08-09 22:06:04 +00:00
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>
160 lines
4.5 KiB
Diff
160 lines
4.5 KiB
Diff
From e52e4ccf1de73e51ac5fc27989f376c9725f9582 Mon Sep 17 00:00:00 2001
|
|
From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
|
|
Date: Sun, 18 Oct 2020 05:26:39 +0530
|
|
Subject: [RFC PATCH 1/5] serdev: Add serdev_device_id
|
|
|
|
Currently,a serdev device driver can only be used with devices that are
|
|
nodes of a device tree, or are part of the ACPI table.id_table will be
|
|
used for devices that are not part of the device tree nor the ACPI table
|
|
(example: device on greybus gbphy created uart).
|
|
|
|
corresponding modalias field is introduced to name the driver to be
|
|
used with the device, required device(s) that are neither described
|
|
by device tree nor ACPI table.
|
|
|
|
serdev_device_uevent is also extended for modalias devices.
|
|
|
|
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
|
|
---
|
|
drivers/tty/serdev/core.c | 41 ++++++++++++++++++++++++++++-----
|
|
include/linux/mod_devicetable.h | 10 ++++++++
|
|
include/linux/serdev.h | 3 +++
|
|
3 files changed, 48 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
|
|
index c5f0d936b003..01b248fdc264 100644
|
|
--- a/drivers/tty/serdev/core.c
|
|
+++ b/drivers/tty/serdev/core.c
|
|
@@ -27,12 +27,17 @@ static ssize_t modalias_show(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
int len;
|
|
+ struct serdev_device *serdev = to_serdev_device(dev);
|
|
|
|
len = acpi_device_modalias(dev, buf, PAGE_SIZE - 1);
|
|
if (len != -ENODEV)
|
|
return len;
|
|
|
|
- return of_device_modalias(dev, buf, PAGE_SIZE);
|
|
+ len = of_device_modalias(dev, buf, PAGE_SIZE);
|
|
+ if (len != -ENODEV)
|
|
+ return len;
|
|
+
|
|
+ return sprintf(buf, "%s%s\n", SERDEV_MODULE_PREFIX, serdev->modalias);
|
|
}
|
|
static DEVICE_ATTR_RO(modalias);
|
|
|
|
@@ -45,14 +50,18 @@ ATTRIBUTE_GROUPS(serdev_device);
|
|
static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|
{
|
|
int rc;
|
|
-
|
|
- /* TODO: platform modalias */
|
|
+ struct serdev_device *serdev = to_serdev_device(dev);
|
|
|
|
rc = acpi_device_uevent_modalias(dev, env);
|
|
if (rc != -ENODEV)
|
|
return rc;
|
|
|
|
- return of_device_uevent_modalias(dev, env);
|
|
+ rc = of_device_uevent_modalias(dev, env);
|
|
+ if (rc != -ENODEV)
|
|
+ return rc;
|
|
+
|
|
+ return add_uevent_var(env, "MODALIAS=%s%s", SERDEV_MODULE_PREFIX,
|
|
+ serdev->modalias);
|
|
}
|
|
|
|
static void serdev_device_release(struct device *dev)
|
|
@@ -83,16 +92,36 @@ static const struct device_type serdev_ctrl_type = {
|
|
.release = serdev_ctrl_release,
|
|
};
|
|
|
|
+static int serdev_match_id(const struct serdev_device_id *id,
|
|
+ const struct serdev_device *sdev)
|
|
+{
|
|
+ while (id->name[0]) {
|
|
+ if (!strcmp(sdev->modalias, id->name))
|
|
+ return 1;
|
|
+ id++;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int serdev_device_match(struct device *dev, struct device_driver *drv)
|
|
{
|
|
+ const struct serdev_device *sdev = to_serdev_device(dev);
|
|
+ const struct serdev_device_driver *sdrv = to_serdev_device_driver(drv);
|
|
+
|
|
if (!is_serdev_device(dev))
|
|
return 0;
|
|
|
|
- /* TODO: platform matching */
|
|
if (acpi_driver_match_device(dev, drv))
|
|
return 1;
|
|
|
|
- return of_driver_match_device(dev, drv);
|
|
+ if (of_driver_match_device(dev, drv))
|
|
+ return 1;
|
|
+
|
|
+ if (sdrv->id_table)
|
|
+ return serdev_match_id(sdrv->id_table, sdev);
|
|
+
|
|
+ return strcmp(sdev->modalias, drv->name) == 0;
|
|
}
|
|
|
|
/**
|
|
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
|
|
index 5b08a473cdba..656353952da2 100644
|
|
--- a/include/linux/mod_devicetable.h
|
|
+++ b/include/linux/mod_devicetable.h
|
|
@@ -486,6 +486,16 @@ struct i3c_device_id {
|
|
const void *data;
|
|
};
|
|
|
|
+/* serdev */
|
|
+
|
|
+#define SERDEV_NAME_SIZE 32
|
|
+#define SERDEV_MODULE_PREFIX "serdev:"
|
|
+
|
|
+struct serdev_device_id {
|
|
+ char name[SERDEV_NAME_SIZE];
|
|
+ kernel_ulong_t driver_data;
|
|
+};
|
|
+
|
|
/* spi */
|
|
|
|
#define SPI_NAME_SIZE 32
|
|
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
|
|
index 9f14f9c12ec4..0d9c90a250b0 100644
|
|
--- a/include/linux/serdev.h
|
|
+++ b/include/linux/serdev.h
|
|
@@ -7,6 +7,7 @@
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/device.h>
|
|
+#include <linux/mod_devicetable.h>
|
|
#include <linux/termios.h>
|
|
#include <linux/delay.h>
|
|
|
|
@@ -45,6 +46,7 @@ struct serdev_device {
|
|
const struct serdev_device_ops *ops;
|
|
struct completion write_comp;
|
|
struct mutex write_lock;
|
|
+ char modalias[SERDEV_NAME_SIZE];
|
|
};
|
|
|
|
static inline struct serdev_device *to_serdev_device(struct device *d)
|
|
@@ -63,6 +65,7 @@ struct serdev_device_driver {
|
|
struct device_driver driver;
|
|
int (*probe)(struct serdev_device *);
|
|
void (*remove)(struct serdev_device *);
|
|
+ const struct serdev_device_id *id_table;
|
|
};
|
|
|
|
static inline struct serdev_device_driver *to_serdev_device_driver(struct device_driver *d)
|
|
--
|
|
2.25.1
|
|
|