linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Enrico Weigelt, metux IT consult" <lkml@metux.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Enrico Weigelt, metux IT consult" <info@metux.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>
Subject: Re: RFC: oftree based setup of composite board devices
Date: Thu, 11 Feb 2021 18:01:11 +0100	[thread overview]
Message-ID: <f9c0af52-2930-7227-7ccb-4780fb1bb159@metux.net> (raw)
In-Reply-To: <CAHp75Vd39OaGkgi5mSH+o39Js8gDW77fP8LUBx73EAH_mZ-scg@mail.gmail.com>

On 11.02.21 12:41, Andy Shevchenko wrote:

Hi,

> On Thu, Feb 11, 2021 at 1:15 PM Enrico Weigelt, metux IT consult
> <lkml@metux.net> wrote:
>> On 10.02.21 11:30, Andy Shevchenko wrote:
> 
>>>> Use cases are boards with non-oftree firmware (ACPI, etc) where certain
>>>> platform devices can't be directly enumerated via firmware. Traditionally
>>>> we had to write board specific drivers that check for board identification
>>>> (DMI strings, etc), then initialize the actual devices and their links
>>>> (eg. gpio<->leds/buttons, ...). Often this can be expressed just by DT.
>>>
>>> In ACPI we support DT compatible strings, and we support overlays for
>>> a long time. Would it work for you?
>>
>> please tell me more, how ACPI and DT can already work together ?
> 
> It's all in documentation.
> 
> https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html#device-tree-namespace-link-device-id

Thanks, but I'm still unsure how this helps me. I'm not intending to
touch any firmware (and expect people in the field flashing new fw).
I have to live with what we find in the field (otherwise I'd just write
omplete DTs for the corresponding boards and throw out ACPI :p)

> https://www.kernel.org/doc/html/latest/admin-guide/acpi/ssdt-overlays.html

Are you suggesting I should load SSDT overlays at runtime (from
userland ?) instead of using DT ?

> Please, please, read documentation beforehand!

I actually did read that documentation, but unfortunately it doesn't
tell me how to use additional DTs on ACPI systems.

>> You already know my apu board driver - that's my first example usecase.
> 
> Sorry, but I forgot about it. Can you summarize what is your use case
> that really needs so intrusive and hard work?

The current APU2/3/4 driver is pretty much fine (except that possibly
some more bios-version specific quirks might be needed). It basically
just instantiates a bunch of other devices (gpio, led, input, ...)
and connects them.

All of that (except for the DMI match table) already can be easily
expressed in DT, so this calls for a generalization. At that point I
tried to achieve the following goals:

* a generic mechanism for detecting boards (and later pci cards, usb
   dongles, etc) and probing the devices from the corresponding DT
* have everything that makes up an individual board in one DT(S)
* ability to blacklist (kick out) specific devices already probed via
   ACPI, so they don't conflict. (*1)

>> * match rules shall be inside the DTS
>> * future match rules shall also check for bios versions etc
>> * adding new boards shall be possible by just adding another DTS to
>>     the tree (not a whole module)
>> * supporting several board variants (w/ small differences) by one DTS
>> * sometimes existing devices (eg. enumerated by acpi) need to be kicked
>>     out (buggy firmware, ...)
>> * can't rely on any special userland tweaks
> 
> Show an example why either of the above is needed in your case and
> tell what is the exact issue.

In the specific APU case (note that my proposal is a generic mechanism
for a whole class of similar usecases), *some* bios versions already
enumerate *some* gpios, later versions already enumerate some LEDs but
different naming than the driver's, etc., etc. (at time of writing the
driver, apu bios didn't support any of that). For preventing conflicts
and consistency between all bios versions, it's IMHO better to just
remove the conflicting devices if they're enumerated by bios.

> Yes, that driver represents hardware. MFD already has some support for
> composite devices. We have the auxiliary bus for some other
> interesting cases, etc. Depending on the hardware in question you have
> to choose a proper bus and locking (access synchronisation) schema.

Yes, but similar to the apu case, I'd like to be able describe those
devices just by a DT (instead of lots of C code).

>> Those things could be expressed via DTS, so we don't need to write
>> individual drivers anymore.
> 
> It seems you are trying to create something like "universal quirk".
> Brave idea, but from my experience a fiasco is what will be out of it.
> The hardware has a lot of different issues and levels of issues and it
> is close to impossible to describe everything possible and predict the
> future... Good luck!

Dont worry, I don't try create some one-fits-all-solution. It's just for
a specific class of use cases, where we need additional devices that
can't be (reliably) enumerated via firmware or buses.

>> * need to split the information into several places (instead of having
>>     all in one DTS)
>> * need to have one separate module board, or merge the dmi tables.
> 
> Have no idea what you are talking about here, sorry.

Well, for now I have the matching criteria (DMI strings) within the DT -
don't need any additional code per board. For using the existing
mechanisms, I would need to move that out into a separate .c file,
something I'd like to avoid.

>> My goal is having everything that describes a board into one DTS
>> (source) file.
> 
> I'm confused, you are talking about non-DT platforms in the
> cover-letter and now you are talking about DTS. AFAIK DTS allows you
> to put everything in one source.

Nope, I'm using DT *in addition* to firmware data (ACPI), for things
that arent't properly described by firmware. The idea goes like this:

* walk through all available board descriptions (builtin dtbs)
   * check whether board matches critiera given in the DT
   * if match:
     * kick out blacklisted devices
     * populate devices from the DT

The idea is just not having to write lots of C code for cases like the
apu boards anymore, but reuse existing DT infrastructure for that and
also heavily reduce code size this way (for apu case, the dtb is around
2kb, while the existing driver is around 17kb)


--mtx

-- 
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

      reply	other threads:[~2021-02-11 17:47 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 22:21 RFC: oftree based setup of composite board devices Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 01/12] of: base: improve error message in of_phandle_iterator_next() Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 02/12] of: base: introduce of_find_node_by_phandle_from() Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 03/12] of: base: record root node in interator and use it for phandle lookup Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 04/12] of: base: introduce of_match_string() Enrico Weigelt, metux IT consult
2021-02-08 23:52   ` Rob Herring
2021-02-08 22:21 ` [RFC PATCH 05/12] of: kobj: __of_attach_node_sysfs(): add optional basename parameter Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 06/12] of: kobj: introduce of_attach_tree_sysfs() Enrico Weigelt, metux IT consult
2021-02-08 22:21 ` [RFC PATCH 07/12] gpio: amd-fch: add oftree probing support Enrico Weigelt, metux IT consult
2021-02-11  9:57   ` Bartosz Golaszewski
2021-03-01 14:51   ` Linus Walleij
2021-03-11 10:17     ` Enrico Weigelt, metux IT consult
2021-03-11 10:42       ` Andy Shevchenko
2021-03-18  8:00         ` Enrico Weigelt, metux IT consult
2021-03-25  9:09           ` Linus Walleij
2021-02-08 22:21 ` [RFC PATCH 08/12] drivers: base: introduce bus_remove_device_by_name() Enrico Weigelt, metux IT consult
2021-02-08 22:22 ` [RFC PATCH 09/12] drivers: base: reintroduce find_bus() Enrico Weigelt, metux IT consult
2021-02-13 10:20   ` Greg KH
2021-02-23 20:13     ` Enrico Weigelt, metux IT consult
2021-02-24  8:00       ` Greg KH
2021-02-24 15:30         ` Enrico Weigelt, metux IT consult
2021-02-24 16:28           ` Greg KH
2021-02-08 22:22 ` [RFC PATCH 10/12] export bus_get() / bus_put() Enrico Weigelt, metux IT consult
2021-02-08 22:22 ` [RFC PATCH 11/12] platform/x86: skeleton for oftree based board device initialization Enrico Weigelt, metux IT consult
2021-02-10 10:32   ` Andy Shevchenko
2021-02-12  9:58   ` Linus Walleij
2021-02-12 11:54     ` Enrico Weigelt, metux IT consult
2021-02-15  1:18       ` Frank Rowand
2021-02-23 20:41         ` Enrico Weigelt, metux IT consult
2021-03-02 13:33       ` Linus Walleij
2021-02-08 22:22 ` [RFC PATCH 12/12] platform/x86/of: add support for PC Engines APU v2/3/4 boards Enrico Weigelt, metux IT consult
2021-02-09  0:06   ` Rob Herring
2021-02-11 13:15     ` Enrico Weigelt, metux IT consult
2021-03-01 14:55   ` Linus Walleij
2021-02-08 23:48 ` RFC: oftree based setup of composite board devices Rob Herring
2021-02-10 22:13   ` Enrico Weigelt, metux IT consult
2021-02-15  1:12   ` Frank Rowand
2021-02-15 15:35     ` Andy Shevchenko
2021-02-24 13:00     ` Enrico Weigelt, metux IT consult
2021-02-24 23:14       ` Frank Rowand
2021-03-05 18:29         ` Rob Herring
2021-02-10 10:30 ` Andy Shevchenko
2021-02-11 11:08   ` Enrico Weigelt, metux IT consult
2021-02-11 11:41     ` Andy Shevchenko
2021-02-11 17:01       ` Enrico Weigelt, metux IT consult [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f9c0af52-2930-7227-7ccb-4780fb1bb159@metux.net \
    --to=lkml@metux.net \
    --cc=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=info@metux.net \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).