Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1509500 > unrolled thread
| Started by | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| First post | 2016-10-26 17:00 +0200 |
| Last post | 2016-10-27 23:00 +0200 |
| Articles | 13 — 6 participants |
Back to article view | Back to linux.kernel
[RFC PATCH 0/5] Add an overlay manager to handle board capes Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-26 17:00 +0200
[RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-26 17:00 +0200
Re: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-27 16:00 +0200
Re: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 Matthias Brugger <mbrugger@suse.com> - 2016-10-27 16:30 +0200
Re: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 Matthias Brugger <matthias.bgg@gmail.com> - 2016-10-27 17:50 +0200
[RFC PATCH 3/5] w1: report errors returned by w1_family_notify Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-26 17:00 +0200
Re: [RFC PATCH 3/5] w1: report errors returned by w1_family_notify Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-10-26 18:40 +0200
[RFC PATCH 2/5] of: overlay-mgr: add the CHIP format Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-26 17:00 +0200
Re: [RFC PATCH 0/5] Add an overlay manager to handle board capes Rob Herring <robh@kernel.org> - 2016-10-27 16:00 +0200
Re: [RFC PATCH 0/5] Add an overlay manager to handle board capes Antoine Tenart <antoine.tenart@free-electrons.com> - 2016-10-27 16:30 +0200
Re: [RFC PATCH 0/5] Add an overlay manager to handle board capes Hans de Goede <hdegoede@redhat.com> - 2016-10-27 17:20 +0200
Re: [RFC PATCH 0/5] Add an overlay manager to handle board capes Rob Herring <robh@kernel.org> - 2016-10-27 19:40 +0200
Re: [RFC PATCH 0/5] Add an overlay manager to handle board capes Hans de Goede <hdegoede@redhat.com> - 2016-10-27 23:00 +0200
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-26 17:00 +0200 |
| Subject | [RFC PATCH 0/5] Add an overlay manager to handle board capes |
| Message-ID | <swxQl-57S-5@gated-at.bofh.it> |
Hi all,
Many boards now come with dips and compatible capes; among others the
C.H.I.P, or Beaglebones. All these boards have a kernel implementing an
out-of-tree "cape manager" which is used to detected capes, retrieve
their description and apply a corresponding overlay. This series is an
attempt to start a discussion, with an implementation of such a manager
which is somehow generic (i.e. formats or cape detectors can be added).
Other use cases could make use of this manager to dynamically load dt
overlays based on some input / hw presence.
The proposed design is a library which can be used by detector drivers
to parse headers and load the corresponding overlay. Helpers are
provided for this purpose. The whole thing is divided into 3 entities:
- The parser which is project-specific (to allow supporting headers
already into the wild). It registers a function parsing an header's
data and filling one or more strings which will be used to find
matching dtbo on the fs.
- The overlay manager helpers allowing to parse a header to retrieve
the previously mentioned strings and to load a compatible overlay.
- The detectors which are used to detect capes and get their description
(to be parsed).
An example of parser and detector is given, compatible with what's done
for the C.H.I.P. As the w1 framework is really bad (and we should
probably do something about that) the detector code is far from being
perfect; but that's not related to what we try to achieve here.
The actual implementation has a limitation: the detectors cannot be
built-in the kernel image as they would likely detect capes at boot time
but will fail to get their corresponding dt overlays as the fs isn't
mounted yet. The only case this can work is when dt overlays are
built-in firmwares. This isn't an issue for the C.H.I.P. use case right
now. There was a discussion about making an helper to wait for the
rootfs to be mount but the answer was "this is the driver's problem".
I'd like to get comments, specifically from people using custom cape
managers, to see if this could fill their needs (with I guess some
modifications).
Thanks!
Antoine
Antoine Tenart (5):
of: introduce the overlay manager
of: overlay-mgr: add the CHIP format
w1: report errors returned by w1_family_notify
w1: add a callback to call slave when a new device is connected
of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom
over w1
drivers/of/Kconfig | 2 +
drivers/of/Makefile | 1 +
drivers/of/overlay-manager/Kconfig | 29 ++++
drivers/of/overlay-manager/Makefile | 2 +
drivers/of/overlay-manager/format-chip.c | 72 ++++++++++
drivers/of/overlay-manager/overlay-manager.c | 199 +++++++++++++++++++++++++++
drivers/w1/slaves/w1_ds2431.c | 39 ++++++
drivers/w1/w1.c | 14 +-
drivers/w1/w1_family.h | 2 +
include/linux/overlay-manager.h | 51 +++++++
10 files changed, 410 insertions(+), 1 deletion(-)
create mode 100644 drivers/of/overlay-manager/Kconfig
create mode 100644 drivers/of/overlay-manager/Makefile
create mode 100644 drivers/of/overlay-manager/format-chip.c
create mode 100644 drivers/of/overlay-manager/overlay-manager.c
create mode 100644 include/linux/overlay-manager.h
--
2.10.1
[toc] | [next] | [standalone]
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-26 17:00 +0200 |
| Subject | [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 |
| Message-ID | <swxQm-57S-17@gated-at.bofh.it> |
| In reply to | #1509500 |
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
drivers/of/overlay-manager/Kconfig | 10 ++++++++++
drivers/w1/slaves/w1_ds2431.c | 39 ++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/drivers/of/overlay-manager/Kconfig b/drivers/of/overlay-manager/Kconfig
index 1a36613c0c53..ad0a5b8e9e5e 100644
--- a/drivers/of/overlay-manager/Kconfig
+++ b/drivers/of/overlay-manager/Kconfig
@@ -16,4 +16,14 @@ config OF_OVERLAY_MGR_FORMAT_CHIP
endmenu
+menu "Overlay Manager detectors"
+
+config OF_OVERLAY_MGR_DETECTOR_DS2431
+ bool "Dip header on a DS2431 EEPROM"
+ depends on W1_SLAVE_DS2431
+ help
+ Enable dip header DS2431 EEPROM support.
+
+endmenu
+
endif
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
index 80572cb63ba8..760325f9a2bd 100644
--- a/drivers/w1/slaves/w1_ds2431.c
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -15,6 +15,9 @@
#include <linux/device.h>
#include <linux/types.h>
#include <linux/delay.h>
+#include <linux/slab.h>
+
+#include <linux/overlay-manager.h>
#include "../w1.h"
#include "../w1_int.h"
@@ -280,7 +283,43 @@ static const struct attribute_group *w1_f2d_groups[] = {
NULL,
};
+#if IS_ENABLED(CONFIG_OF_OVERLAY_MGR_DETECTOR_DS2431)
+static int chip_dip_callback(struct w1_slave *sl)
+{
+ char **candidates = NULL;
+ int i, n, err = 0;
+ u8 *data;
+
+ data = kzalloc(OVERLAY_MGR_DIP_MAX_SZ, GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ /* sizeof(struct chip_header) is a mulitple of 8 */
+ for (i = 0; i < OVERLAY_MGR_DIP_MAX_SZ; i += 8) {
+ if (w1_f2d_readblock(sl, i, 8, &data[i])) {
+ err = -EIO;
+ goto end;
+ }
+ }
+
+ overlay_mgr_parse(&sl->dev, data, &candidates, &n);
+ if (!n) {
+ err = -EINVAL;
+ goto end;
+ }
+
+ err = overlay_mgr_apply(&sl->dev, candidates, n);
+
+end:
+ kfree(data);
+ return err;
+}
+#endif
+
static struct w1_family_ops w1_f2d_fops = {
+#if IS_ENABLED(CONFIG_OF_OVERLAY_MGR_DETECTOR_DS2431)
+ .callback = chip_dip_callback,
+#endif
.groups = w1_f2d_groups,
};
--
2.10.1
[toc] | [prev] | [next] | [standalone]
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-27 16:00 +0200 |
| Subject | Re: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 |
| Message-ID | <swTnQ-2Bn-37@gated-at.bofh.it> |
| In reply to | #1509502 |
[Multipart message — attachments visible in raw view] — view raw
Hello Matthias, On Thu, Oct 27, 2016 at 11:19:14AM +0200, Matthias Brugger wrote: > On 10/26/2016 04:57 PM, Antoine Tenart wrote: > > Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> > > --- > > Please provide a commit message. Sure. There are other modifications I'd like to do in the series if it happens to be an use case for people. This patch is given as an example of how we could implement this. Antoine -- Antoine Ténart, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Matthias Brugger <mbrugger@suse.com> |
|---|---|
| Date | 2016-10-27 16:30 +0200 |
| Subject | Re: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 |
| Message-ID | <swTnQ-2Bn-39@gated-at.bofh.it> |
| In reply to | #1509502 |
On 10/26/2016 04:57 PM, Antoine Tenart wrote: > Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> > --- Please provide a commit message. Thanks, Matthias
[toc] | [prev] | [next] | [standalone]
| From | Matthias Brugger <matthias.bgg@gmail.com> |
|---|---|
| Date | 2016-10-27 17:50 +0200 |
| Subject | Re: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 |
| Message-ID | <swV6i-3LE-7@gated-at.bofh.it> |
| In reply to | #1509502 |
On 10/26/2016 04:57 PM, Antoine Tenart wrote:
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
Please provide a commit message.
> drivers/of/overlay-manager/Kconfig | 10 ++++++++++
> drivers/w1/slaves/w1_ds2431.c | 39 ++++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/drivers/of/overlay-manager/Kconfig b/drivers/of/overlay-manager/Kconfig
> index 1a36613c0c53..ad0a5b8e9e5e 100644
> --- a/drivers/of/overlay-manager/Kconfig
> +++ b/drivers/of/overlay-manager/Kconfig
> @@ -16,4 +16,14 @@ config OF_OVERLAY_MGR_FORMAT_CHIP
>
> endmenu
>
> +menu "Overlay Manager detectors"
> +
> +config OF_OVERLAY_MGR_DETECTOR_DS2431
> + bool "Dip header on a DS2431 EEPROM"
> + depends on W1_SLAVE_DS2431
> + help
> + Enable dip header DS2431 EEPROM support.
> +
> +endmenu
> +
> endif
> diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
> index 80572cb63ba8..760325f9a2bd 100644
> --- a/drivers/w1/slaves/w1_ds2431.c
> +++ b/drivers/w1/slaves/w1_ds2431.c
> @@ -15,6 +15,9 @@
> #include <linux/device.h>
> #include <linux/types.h>
> #include <linux/delay.h>
> +#include <linux/slab.h>
> +
> +#include <linux/overlay-manager.h>
>
> #include "../w1.h"
> #include "../w1_int.h"
> @@ -280,7 +283,43 @@ static const struct attribute_group *w1_f2d_groups[] = {
> NULL,
> };
>
> +#if IS_ENABLED(CONFIG_OF_OVERLAY_MGR_DETECTOR_DS2431)
> +static int chip_dip_callback(struct w1_slave *sl)
> +{
> + char **candidates = NULL;
> + int i, n, err = 0;
> + u8 *data;
> +
> + data = kzalloc(OVERLAY_MGR_DIP_MAX_SZ, GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + /* sizeof(struct chip_header) is a mulitple of 8 */
> + for (i = 0; i < OVERLAY_MGR_DIP_MAX_SZ; i += 8) {
> + if (w1_f2d_readblock(sl, i, 8, &data[i])) {
> + err = -EIO;
> + goto end;
> + }
> + }
> +
> + overlay_mgr_parse(&sl->dev, data, &candidates, &n);
> + if (!n) {
> + err = -EINVAL;
> + goto end;
> + }
> +
> + err = overlay_mgr_apply(&sl->dev, candidates, n);
> +
> +end:
> + kfree(data);
> + return err;
> +}
> +#endif
> +
> static struct w1_family_ops w1_f2d_fops = {
> +#if IS_ENABLED(CONFIG_OF_OVERLAY_MGR_DETECTOR_DS2431)
> + .callback = chip_dip_callback,
> +#endif
> .groups = w1_f2d_groups,
> };
>
>
[toc] | [prev] | [next] | [standalone]
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-26 17:00 +0200 |
| Subject | [RFC PATCH 3/5] w1: report errors returned by w1_family_notify |
| Message-ID | <swxQm-57S-25@gated-at.bofh.it> |
| In reply to | #1509500 |
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> --- drivers/w1/w1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index bb34362e930a..80d0cc4e6e7f 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -702,7 +702,9 @@ static int __w1_attach_slave_device(struct w1_slave *sl) dev_name(&sl->dev), err); return err; } - w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); + err = w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); + if (err) + return err; dev_set_uevent_suppress(&sl->dev, false); kobject_uevent(&sl->dev.kobj, KOBJ_ADD); -- 2.10.1
[toc] | [prev] | [next] | [standalone]
| From | Mathieu Poirier <mathieu.poirier@linaro.org> |
|---|---|
| Date | 2016-10-26 18:40 +0200 |
| Subject | Re: [RFC PATCH 3/5] w1: report errors returned by w1_family_notify |
| Message-ID | <swzp7-6mF-1@gated-at.bofh.it> |
| In reply to | #1509505 |
On 26 October 2016 at 08:57, Antoine Tenart <antoine.tenart@free-electrons.com> wrote: GKH won't accept an empty commit log. > Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> > --- > drivers/w1/w1.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c > index bb34362e930a..80d0cc4e6e7f 100644 > --- a/drivers/w1/w1.c > +++ b/drivers/w1/w1.c > @@ -702,7 +702,9 @@ static int __w1_attach_slave_device(struct w1_slave *sl) > dev_name(&sl->dev), err); > return err; > } > - w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); > + err = w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); > + if (err) > + return err; > > dev_set_uevent_suppress(&sl->dev, false); > kobject_uevent(&sl->dev.kobj, KOBJ_ADD); > -- > 2.10.1 > > -- > To unsubscribe from this list: send the line "unsubscribe devicetree" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html
[toc] | [prev] | [next] | [standalone]
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-26 17:00 +0200 |
| Subject | [RFC PATCH 2/5] of: overlay-mgr: add the CHIP format |
| Message-ID | <swxQm-57S-23@gated-at.bofh.it> |
| In reply to | #1509500 |
Support parsing the header used by capes compatible with Nextthing's
C.H.I.P.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
---
drivers/of/overlay-manager/Kconfig | 13 ++++++
drivers/of/overlay-manager/Makefile | 1 +
drivers/of/overlay-manager/format-chip.c | 72 ++++++++++++++++++++++++++++++++
include/linux/overlay-manager.h | 13 ++++++
4 files changed, 99 insertions(+)
create mode 100644 drivers/of/overlay-manager/format-chip.c
diff --git a/drivers/of/overlay-manager/Kconfig b/drivers/of/overlay-manager/Kconfig
index eeb76054dcb8..1a36613c0c53 100644
--- a/drivers/of/overlay-manager/Kconfig
+++ b/drivers/of/overlay-manager/Kconfig
@@ -4,3 +4,16 @@ config OF_OVERLAY_MGR
help
Enable the overlay manager to handle automatic overlay loading when
devices are detected.
+
+if OF_OVERLAY_MGR
+
+menu "Dips header formats"
+
+config OF_OVERLAY_MGR_FORMAT_CHIP
+ bool "Nextthing's C.H.I.P. dip header format"
+ help
+ Enable Nextthing's C.H.I.P. dip header format support.
+
+endmenu
+
+endif
diff --git a/drivers/of/overlay-manager/Makefile b/drivers/of/overlay-manager/Makefile
index 86d2b53950e7..637cc7ba20c2 100644
--- a/drivers/of/overlay-manager/Makefile
+++ b/drivers/of/overlay-manager/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_OF_OVERLAY_MGR) += overlay-manager.o
+obj-$(CONFIG_OF_OVERLAY_MGR_FORMAT_CHIP) += format-chip.o
diff --git a/drivers/of/overlay-manager/format-chip.c b/drivers/of/overlay-manager/format-chip.c
new file mode 100644
index 000000000000..3a3d315dcb5c
--- /dev/null
+++ b/drivers/of/overlay-manager/format-chip.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2016 - Antoine Tenart <antoine.tenart@free-electrons.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/device.h>
+#include <linux/overlay-manager.h>
+#include <linux/slab.h>
+
+#define CAPE_CHIP_MAGIC 0x43484950
+#define CAPE_CHIP_VERSION 1
+#define CAPE_CHIP_CANDIDATES 2
+
+static int cape_chip_parse(struct device *dev, void *data, char ***candidates,
+ unsigned *n)
+{
+ struct chip_header *header = (struct chip_header *)data;
+ char **tmp;
+ int err;
+
+ if (dip_convert(header->magic) != CAPE_CHIP_MAGIC)
+ return -EINVAL;
+
+ if (dip_convert(header->version) > CAPE_CHIP_VERSION)
+ return -EINVAL;
+
+ tmp = devm_kzalloc(dev, CAPE_CHIP_CANDIDATES * sizeof(char *), GFP_KERNEL);
+ if (!tmp)
+ return -ENOMEM;
+
+ tmp[0] = devm_kasprintf(dev, GFP_KERNEL, "%x-%x-%x",
+ dip_convert(header->vendor_id),
+ dip_convert(header->product_id),
+ dip_convert(header->product_version));
+ if (!tmp[0]) {
+ err = -ENOMEM;
+ goto err_free_list;
+ }
+
+ tmp[1] = devm_kasprintf(dev, GFP_KERNEL, "%x-%x",
+ dip_convert(header->vendor_id),
+ dip_convert(header->product_id));
+ if (!tmp[1]) {
+ err = -ENOMEM;
+ goto err_free_0;
+ }
+
+ *candidates = tmp;
+ *n = CAPE_CHIP_CANDIDATES;
+
+ return 0;
+
+err_free_0:
+ devm_kfree(dev, tmp[0]);
+err_free_list:
+ devm_kfree(dev, tmp);
+ return err;
+}
+
+static struct overlay_mgr_format format_chip = {
+ .name = "Nextthing C.H.I.P. dip header format",
+ .parse = &cape_chip_parse,
+};
+
+static int __init cape_chip_init(void)
+{
+ return overlay_mgr_register_format(&format_chip);
+}
+device_initcall(cape_chip_init);
diff --git a/include/linux/overlay-manager.h b/include/linux/overlay-manager.h
index 8adcc4f5ddf6..d76c3c9fd863 100644
--- a/include/linux/overlay-manager.h
+++ b/include/linux/overlay-manager.h
@@ -35,4 +35,17 @@ int overlay_mgr_apply(struct device *dev, char **candidates, unsigned n);
-1 \
)
+/* Nextthing's C.H.I.P. dip header */
+struct chip_header {
+ u32 magic; /* rsvd */
+ u8 version; /* spec version */
+ u32 vendor_id;
+ u16 product_id;
+ u8 product_version;
+ char vendor_name[32];
+ char product_name[32];
+ u8 rsvd[36]; /* rsvd for futre spec versions */
+ u8 data[16]; /* user data, per-cape specific */
+} __packed;
+
#endif /* __OVERLAY_MGR_H__ */
--
2.10.1
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2016-10-27 16:00 +0200 |
| Message-ID | <swTnQ-2Bn-61@gated-at.bofh.it> |
| In reply to | #1509500 |
Please Cc the maintainers of drivers/of/. + Frank R, Hans, Dmitry S On Wed, Oct 26, 2016 at 9:57 AM, Antoine Tenart <antoine.tenart@free-electrons.com> wrote: > Hi all, > > Many boards now come with dips and compatible capes; among others the > C.H.I.P, or Beaglebones. All these boards have a kernel implementing an > out-of-tree "cape manager" which is used to detected capes, retrieve > their description and apply a corresponding overlay. This series is an > attempt to start a discussion, with an implementation of such a manager > which is somehow generic (i.e. formats or cape detectors can be added). > Other use cases could make use of this manager to dynamically load dt > overlays based on some input / hw presence. I'd like to see an input source be the kernel command line and/or a DT chosen property. Another overlay manager was proposed not to long ago[1] as well. There's also the Allwinner tablet use case from Hans where i2c devices are probed and detected. That's not using overlays currently, but maybe could. Another thing to consider is different sources of overlays. Besides in the filesystem, overlays could be built into the kernel (already supported), embedded in the dtb (as the other overlay mgr did) or we could extend FDT format to append them. > The proposed design is a library which can be used by detector drivers > to parse headers and load the corresponding overlay. Helpers are > provided for this purpose. The whole thing is divided into 3 entities: > > - The parser which is project-specific (to allow supporting headers > already into the wild). It registers a function parsing an header's > data and filling one or more strings which will be used to find > matching dtbo on the fs. > > - The overlay manager helpers allowing to parse a header to retrieve > the previously mentioned strings and to load a compatible overlay. > > - The detectors which are used to detect capes and get their description > (to be parsed). What about things like power has to be turned on first to detect boards and read their ID? I think this needs to be tied into the driver model. Though, don't go sticking cape mgr nodes into DT. Maybe a driver gets bound to a connector node, but we've got to sort out connector bindings first. > An example of parser and detector is given, compatible with what's done > for the C.H.I.P. As the w1 framework is really bad (and we should > probably do something about that) the detector code is far from being > perfect; but that's not related to what we try to achieve here. > > The actual implementation has a limitation: the detectors cannot be > built-in the kernel image as they would likely detect capes at boot time > but will fail to get their corresponding dt overlays as the fs isn't > mounted yet. The only case this can work is when dt overlays are > built-in firmwares. This isn't an issue for the C.H.I.P. use case right > now. There was a discussion about making an helper to wait for the > rootfs to be mount but the answer was "this is the driver's problem". I thought there are firmware loading calls that will wait. I think this all needs to work asynchronously both for firmware loading and because w1 is really slow. > I'd like to get comments, specifically from people using custom cape > managers, to see if this could fill their needs (with I guess some > modifications). Having 2 would certainly give a better sense this is generic. Rob [1] https://patchwork.ozlabs.org/patch/667805/
[toc] | [prev] | [next] | [standalone]
| From | Antoine Tenart <antoine.tenart@free-electrons.com> |
|---|---|
| Date | 2016-10-27 16:30 +0200 |
| Message-ID | <swTQR-355-15@gated-at.bofh.it> |
| In reply to | #1510168 |
[Multipart message — attachments visible in raw view] — view raw
Hi Rob, On Thu, Oct 27, 2016 at 08:41:56AM -0500, Rob Herring wrote: > Please Cc the maintainers of drivers/of/. > > + Frank R, Hans, Dmitry S Yes, sorry for that. > On Wed, Oct 26, 2016 at 9:57 AM, Antoine Tenart > <antoine.tenart@free-electrons.com> wrote: > > > > Many boards now come with dips and compatible capes; among others the > > C.H.I.P, or Beaglebones. All these boards have a kernel implementing an > > out-of-tree "cape manager" which is used to detected capes, retrieve > > their description and apply a corresponding overlay. This series is an > > attempt to start a discussion, with an implementation of such a manager > > which is somehow generic (i.e. formats or cape detectors can be added). > > Other use cases could make use of this manager to dynamically load dt > > overlays based on some input / hw presence. > > I'd like to see an input source be the kernel command line and/or a DT > chosen property. We now have overlay support in U-Boot so we could modify the device tree from the bootloader and not use the command line. But you can argue the boot loader can't always be upgraded (to support overlays, or to improve it). So I guess we can think of using the command line as a input source. > Another overlay manager was proposed not to long ago[1] as well. Thanks for the hint. > Another thing to consider is different sources of overlays. Besides in > the filesystem, overlays could be built into the kernel (already > supported), embedded in the dtb (as the other overlay mgr did) or we > could extend FDT format to append them. Sure. Using this series it should be quite easy to support other sources. We would need to improve the function loading the overlay, to try other sources. This could even comes in following up patches. > > The proposed design is a library which can be used by detector drivers > > to parse headers and load the corresponding overlay. Helpers are > > provided for this purpose. The whole thing is divided into 3 entities: > > > > - The parser which is project-specific (to allow supporting headers > > already into the wild). It registers a function parsing an header's > > data and filling one or more strings which will be used to find > > matching dtbo on the fs. > > > > - The overlay manager helpers allowing to parse a header to retrieve > > the previously mentioned strings and to load a compatible overlay. > > > > - The detectors which are used to detect capes and get their description > > (to be parsed). > > What about things like power has to be turned on first to detect > boards and read their ID? I think this needs to be tied into the > driver model. Though, don't go sticking cape mgr nodes into DT. Maybe > a driver gets bound to a connector node, but we've got to sort out > connector bindings first. Right. I don't know yet how to handle this. Do you have an existing example in mind of such a power requirement? > > An example of parser and detector is given, compatible with what's done > > for the C.H.I.P. As the w1 framework is really bad (and we should > > probably do something about that) the detector code is far from being > > perfect; but that's not related to what we try to achieve here. > > > > The actual implementation has a limitation: the detectors cannot be > > built-in the kernel image as they would likely detect capes at boot time > > but will fail to get their corresponding dt overlays as the fs isn't > > mounted yet. The only case this can work is when dt overlays are > > built-in firmwares. This isn't an issue for the C.H.I.P. use case right > > now. There was a discussion about making an helper to wait for the > > rootfs to be mount but the answer was "this is the driver's problem". > > I thought there are firmware loading calls that will wait. I think > this all needs to work asynchronously both for firmware loading and > because w1 is really slow. There is an asynchronous one, but it will also fail if the rootfs isn't mounted yet. Thanks! Antoine -- Antoine Ténart, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | Hans de Goede <hdegoede@redhat.com> |
|---|---|
| Date | 2016-10-27 17:20 +0200 |
| Message-ID | <swUDg-3BS-5@gated-at.bofh.it> |
| In reply to | #1510168 |
Hi,
On 27-10-16 15:41, Rob Herring wrote:
> Please Cc the maintainers of drivers/of/.
>
> + Frank R, Hans, Dmitry S
>
> On Wed, Oct 26, 2016 at 9:57 AM, Antoine Tenart
> <antoine.tenart@free-electrons.com> wrote:
>> Hi all,
>>
>> Many boards now come with dips and compatible capes; among others the
>> C.H.I.P, or Beaglebones. All these boards have a kernel implementing an
>> out-of-tree "cape manager" which is used to detected capes, retrieve
>> their description and apply a corresponding overlay. This series is an
>> attempt to start a discussion, with an implementation of such a manager
>> which is somehow generic (i.e. formats or cape detectors can be added).
>> Other use cases could make use of this manager to dynamically load dt
>> overlays based on some input / hw presence.
>
> I'd like to see an input source be the kernel command line and/or a DT
> chosen property. Another overlay manager was proposed not to long
> ago[1] as well. There's also the Allwinner tablet use case from Hans
> where i2c devices are probed and detected. That's not using overlays
> currently, but maybe could.
Actually I'm currently thinking in a different direction, which I
think will be good for the boards where some ICs are frequently
replaced by 2nd (and 3th and 4th) sources, rather then that we're
dealing with an extension connector with capes / daughter boards.
Although there is some overlap I'm starting to think that we need to
treat these 2 cases differently. Let me quickly copy and paste
the basic idea I've for the 2nd source touchscreen / accelerometer
chip case:
"""
The kernel actually already has a detect() method in struct i2c_driver,
we could use that (we would need to implement it in drivers which do not
have it yet). Note on second thought it seems it may be better to use
probe() for this, see below.
Then we could have something like this in dt:
&i2c0 {
touchscreen1: gsl1680@40 {
reg = <0x40>;
compatible = "silead,gsl1680";
enable-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
status = "disabled";
};
touchscreen2: ektf2127@15 {
reg = <0x15>;
compatible = "elan,ektf2127";
enable-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
status = "disabled";
};
i2c-probe-stop-at-first-match-0 = <&touchscreen1>, <&touchscreen2>;
i2c-probe-stop-at-first-match-1 = <&accelerometer1>, <&accelerometer2>;
}
Which would make the i2c subsys call detect (*) on each device, until
a device is found. Likewise we could have a "i2c-probe-all" property
which also walks a list of phandles but does not stop on the first
match.
...
*) Yes this sounds Linux specific, but it really is just "execute to-be-probed
device compatible specific detection method"
"""
This does not 100% solve all q8 issues (see the "Add Allwinner Q8 tablets
hardware manager" thread), but does solve quite a bit of the use-case
and this matches what many vendor os-images (typically android) are
actually doing for these kind of boards.
As for the bits this does not solve, those are mostly board specific details
which cannot be probed at all, and on x86 are typically solved in the device
driver by doing a dmi check to identify the board and then apply a board
specific workaround in the driver.
I've come to believe that we should similarly delegate dealing this to device
drivers in the devicetree case. Note that dt should still of course fully
describe the hardware for normal hardware, the driver would just need to care
about weird board quirks in certain exceptions.
A more interesting problem here is that dt does not have something like
DMI, there is the machine compatible, but that typically does not contain
board revision info (where as DMI often does). I believe that this is
actually something which should be fixed at the bootloader level
have it prepend a new machine compatible which contains revision info.
Hmm, if we make the bootloader prepend a new machine compatible which contains
revision info, we could then trigger quirks on this and in some cases avoid
the need for dealing with board quirks in the driver ...
Note this is all very specific to dealing with board (revision) variants,
for add-ons having the bootloader add info to the machine compatible does
not seem the right solution.
Regards,
Hans
>
> Another thing to consider is different sources of overlays. Besides in
> the filesystem, overlays could be built into the kernel (already
> supported), embedded in the dtb (as the other overlay mgr did) or we
> could extend FDT format to append them.
>
>> The proposed design is a library which can be used by detector drivers
>> to parse headers and load the corresponding overlay. Helpers are
>> provided for this purpose. The whole thing is divided into 3 entities:
>>
>> - The parser which is project-specific (to allow supporting headers
>> already into the wild). It registers a function parsing an header's
>> data and filling one or more strings which will be used to find
>> matching dtbo on the fs.
>>
>> - The overlay manager helpers allowing to parse a header to retrieve
>> the previously mentioned strings and to load a compatible overlay.
>>
>> - The detectors which are used to detect capes and get their description
>> (to be parsed).
>
> What about things like power has to be turned on first to detect
> boards and read their ID? I think this needs to be tied into the
> driver model. Though, don't go sticking cape mgr nodes into DT. Maybe
> a driver gets bound to a connector node, but we've got to sort out
> connector bindings first.
>
>> An example of parser and detector is given, compatible with what's done
>> for the C.H.I.P. As the w1 framework is really bad (and we should
>> probably do something about that) the detector code is far from being
>> perfect; but that's not related to what we try to achieve here.
>>
>> The actual implementation has a limitation: the detectors cannot be
>> built-in the kernel image as they would likely detect capes at boot time
>> but will fail to get their corresponding dt overlays as the fs isn't
>> mounted yet. The only case this can work is when dt overlays are
>> built-in firmwares. This isn't an issue for the C.H.I.P. use case right
>> now. There was a discussion about making an helper to wait for the
>> rootfs to be mount but the answer was "this is the driver's problem".
>
> I thought there are firmware loading calls that will wait. I think
> this all needs to work asynchronously both for firmware loading and
> because w1 is really slow.
>
>> I'd like to get comments, specifically from people using custom cape
>> managers, to see if this could fill their needs (with I guess some
>> modifications).
>
> Having 2 would certainly give a better sense this is generic.
>
> Rob
>
> [1] https://patchwork.ozlabs.org/patch/667805/
>
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2016-10-27 19:40 +0200 |
| Message-ID | <swWOK-4Ur-5@gated-at.bofh.it> |
| In reply to | #1510380 |
On Thu, Oct 27, 2016 at 10:13 AM, Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 27-10-16 15:41, Rob Herring wrote:
>>
>> Please Cc the maintainers of drivers/of/.
>>
>> + Frank R, Hans, Dmitry S
>>
>> On Wed, Oct 26, 2016 at 9:57 AM, Antoine Tenart
>> <antoine.tenart@free-electrons.com> wrote:
>>>
>>> Hi all,
>>>
>>> Many boards now come with dips and compatible capes; among others the
>>> C.H.I.P, or Beaglebones. All these boards have a kernel implementing an
>>> out-of-tree "cape manager" which is used to detected capes, retrieve
>>> their description and apply a corresponding overlay. This series is an
>>> attempt to start a discussion, with an implementation of such a manager
>>> which is somehow generic (i.e. formats or cape detectors can be added).
>>> Other use cases could make use of this manager to dynamically load dt
>>> overlays based on some input / hw presence.
>>
>>
>> I'd like to see an input source be the kernel command line and/or a DT
>> chosen property. Another overlay manager was proposed not to long
>> ago[1] as well. There's also the Allwinner tablet use case from Hans
>> where i2c devices are probed and detected. That's not using overlays
>> currently, but maybe could.
>
>
> Actually I'm currently thinking in a different direction, which I
> think will be good for the boards where some ICs are frequently
> replaced by 2nd (and 3th and 4th) sources, rather then that we're
> dealing with an extension connector with capes / daughter boards.
>
> Although there is some overlap I'm starting to think that we need to
> treat these 2 cases differently. Let me quickly copy and paste
> the basic idea I've for the 2nd source touchscreen / accelerometer
> chip case:
>
> """
> The kernel actually already has a detect() method in struct i2c_driver,
> we could use that (we would need to implement it in drivers which do not
> have it yet). Note on second thought it seems it may be better to use
> probe() for this, see below.
>
> Then we could have something like this in dt:
>
> &i2c0 {
> touchscreen1: gsl1680@40 {
> reg = <0x40>;
> compatible = "silead,gsl1680";
> enable-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
> status = "disabled";
> };
>
> touchscreen2: ektf2127@15 {
> reg = <0x15>;
Do you ever have different devices with the same address? That would
be somewhat problematic as really these should be
"touchscreen@<addr>".
> compatible = "elan,ektf2127";
> enable-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
> status = "disabled";
> };
>
> i2c-probe-stop-at-first-match-0 = <&touchscreen1>, <&touchscreen2>;
> i2c-probe-stop-at-first-match-1 = <&accelerometer1>, <&accelerometer2>;
> }
>
> Which would make the i2c subsys call detect (*) on each device, until
> a device is found. Likewise we could have a "i2c-probe-all" property
> which also walks a list of phandles but does not stop on the first
> match.
>
> ...
>
> *) Yes this sounds Linux specific, but it really is just "execute
> to-be-probed
> device compatible specific detection method"
> """
Yeah, not a fan of these properties at first glance. Why can't you
just fail probe on the non-existent devices?
> This does not 100% solve all q8 issues (see the "Add Allwinner Q8 tablets
> hardware manager" thread), but does solve quite a bit of the use-case
> and this matches what many vendor os-images (typically android) are
> actually doing for these kind of boards.
BTW, I've been meaning to ask you if you are looking at the Android
side of things as well?
> As for the bits this does not solve, those are mostly board specific details
> which cannot be probed at all, and on x86 are typically solved in the device
> driver by doing a dmi check to identify the board and then apply a board
> specific workaround in the driver.
>
> I've come to believe that we should similarly delegate dealing this to
> device
> drivers in the devicetree case. Note that dt should still of course fully
> describe the hardware for normal hardware, the driver would just need to
> care
> about weird board quirks in certain exceptions.
Which is fine IMO, though I do think we should look at those cases
carefully to ensure they stay the exception.
> A more interesting problem here is that dt does not have something like
> DMI, there is the machine compatible, but that typically does not contain
> board revision info (where as DMI often does). I believe that this is
> actually something which should be fixed at the bootloader level
> have it prepend a new machine compatible which contains revision info.
>
> Hmm, if we make the bootloader prepend a new machine compatible which
> contains
> revision info, we could then trigger quirks on this and in some cases avoid
> the need for dealing with board quirks in the driver ...
That would work. Board and chip versions both need better handling in
kernel IMO.
QCom has a whole scheme around version numbering in compatible
strings. (Unfortunately, bootloaders only support their previous way
of doing things.)
> Note this is all very specific to dealing with board (revision) variants,
> for add-ons having the bootloader add info to the machine compatible does
> not seem the right solution.
Agreed.
Rob
[toc] | [prev] | [next] | [standalone]
| From | Hans de Goede <hdegoede@redhat.com> |
|---|---|
| Date | 2016-10-27 23:00 +0200 |
| Message-ID | <swZWh-6QA-3@gated-at.bofh.it> |
| In reply to | #1510516 |
Hi,
On 27-10-16 19:30, Rob Herring wrote:
> On Thu, Oct 27, 2016 at 10:13 AM, Hans de Goede <hdegoede@redhat.com> wrote:
>> Hi,
>>
>> On 27-10-16 15:41, Rob Herring wrote:
>>>
>>> Please Cc the maintainers of drivers/of/.
>>>
>>> + Frank R, Hans, Dmitry S
>>>
>>> On Wed, Oct 26, 2016 at 9:57 AM, Antoine Tenart
>>> <antoine.tenart@free-electrons.com> wrote:
>>>>
>>>> Hi all,
>>>>
>>>> Many boards now come with dips and compatible capes; among others the
>>>> C.H.I.P, or Beaglebones. All these boards have a kernel implementing an
>>>> out-of-tree "cape manager" which is used to detected capes, retrieve
>>>> their description and apply a corresponding overlay. This series is an
>>>> attempt to start a discussion, with an implementation of such a manager
>>>> which is somehow generic (i.e. formats or cape detectors can be added).
>>>> Other use cases could make use of this manager to dynamically load dt
>>>> overlays based on some input / hw presence.
>>>
>>>
>>> I'd like to see an input source be the kernel command line and/or a DT
>>> chosen property. Another overlay manager was proposed not to long
>>> ago[1] as well. There's also the Allwinner tablet use case from Hans
>>> where i2c devices are probed and detected. That's not using overlays
>>> currently, but maybe could.
>>
>>
>> Actually I'm currently thinking in a different direction, which I
>> think will be good for the boards where some ICs are frequently
>> replaced by 2nd (and 3th and 4th) sources, rather then that we're
>> dealing with an extension connector with capes / daughter boards.
>>
>> Although there is some overlap I'm starting to think that we need to
>> treat these 2 cases differently. Let me quickly copy and paste
>> the basic idea I've for the 2nd source touchscreen / accelerometer
>> chip case:
>>
>> """
>> The kernel actually already has a detect() method in struct i2c_driver,
>> we could use that (we would need to implement it in drivers which do not
>> have it yet). Note on second thought it seems it may be better to use
>> probe() for this, see below.
>>
>> Then we could have something like this in dt:
>>
>> &i2c0 {
>> touchscreen1: gsl1680@40 {
>> reg = <0x40>;
>> compatible = "silead,gsl1680";
>> enable-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
>> status = "disabled";
>> };
>>
>> touchscreen2: ektf2127@15 {
>> reg = <0x15>;
>
> Do you ever have different devices with the same address? That would
> be somewhat problematic as really these should be
> "touchscreen@<addr>".
Yes that happens (sometimes).
>
>> compatible = "elan,ektf2127";
>> enable-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
>> status = "disabled";
>> };
>>
>> i2c-probe-stop-at-first-match-0 = <&touchscreen1>, <&touchscreen2>;
>> i2c-probe-stop-at-first-match-1 = <&accelerometer1>, <&accelerometer2>;
>> }
>>
>> Which would make the i2c subsys call detect (*) on each device, until
>> a device is found. Likewise we could have a "i2c-probe-all" property
>> which also walks a list of phandles but does not stop on the first
>> match.
>>
>> ...
>>
>> *) Yes this sounds Linux specific, but it really is just "execute
>> to-be-probed
>> device compatible specific detection method"
>> """
>
> Yeah, not a fan of these properties at first glance. Why can't you
> just fail probe on the non-existent devices?
That is possible and in the other thread on this there are some
links to some boards which actually already do this, but from a dt
pov it feels wrong. If we know only one of a set of options will
ever be there we ought to describe things like this in the dt.
Functionality wise this has 2 advantages:
1) We stop probing needlessly once a device is found, in some
cases the majority of the board variants has dev a, and some
have dev b / c. Then putting a first in the to-probe list will
save probing b / c on most boards.
2) Not all i2c chips are easily identifiable, so in some cases
one may want to put dev x as last to probe, because the
probe solely consists of: "Does something ack i2c transfers
at this address".
>> This does not 100% solve all q8 issues (see the "Add Allwinner Q8 tablets
>> hardware manager" thread), but does solve quite a bit of the use-case
>> and this matches what many vendor os-images (typically android) are
>> actually doing for these kind of boards.
>
> BTW, I've been meaning to ask you if you are looking at the Android
> side of things as well?
No, I purely use android os images / SDKs as a source of how the
hw works, I do not have any intentions to try and get android up
and running with mainline on these boards.
>> As for the bits this does not solve, those are mostly board specific details
>> which cannot be probed at all, and on x86 are typically solved in the device
>> driver by doing a dmi check to identify the board and then apply a board
>> specific workaround in the driver.
>>
>> I've come to believe that we should similarly delegate dealing this to
>> device
>> drivers in the devicetree case. Note that dt should still of course fully
>> describe the hardware for normal hardware, the driver would just need to
>> care
>> about weird board quirks in certain exceptions.
>
> Which is fine IMO, though I do think we should look at those cases
> carefully to ensure they stay the exception.
Ack.
>> A more interesting problem here is that dt does not have something like
>> DMI, there is the machine compatible, but that typically does not contain
>> board revision info (where as DMI often does). I believe that this is
>> actually something which should be fixed at the bootloader level
>> have it prepend a new machine compatible which contains revision info.
>>
>> Hmm, if we make the bootloader prepend a new machine compatible which
>> contains
>> revision info, we could then trigger quirks on this and in some cases avoid
>> the need for dealing with board quirks in the driver ...
>
> That would work. Board and chip versions both need better handling in
> kernel IMO.
>
> QCom has a whole scheme around version numbering in compatible
> strings. (Unfortunately, bootloaders only support their previous way
> of doing things.)
>
>> Note this is all very specific to dealing with board (revision) variants,
>> for add-ons having the bootloader add info to the machine compatible does
>> not seem the right solution.
>
> Agreed.
Regards,
Hans
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web