All of lore.kernel.org
 help / color / mirror / Atom feed
* How to inject fwnode/oftree/acpi data by platform driver ?
@ 2019-06-01 14:14 Enrico Weigelt, metux IT consult
  2019-06-11 18:44 ` Andy Shevchenko
  2019-06-11 21:31 ` Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-01 14:14 UTC (permalink / raw)
  To: LKML, linux-acpi, devicetree, Platform Driver

Hi folks,


I'm looking for a way to inject fwnode data from a platform driver,
in order to initialize generic drivers w/ board specific configuration.
The idea is getting rid of passing driver specific pdata structs
(which, IIRC, seem to be deprecated).

An example usecase is the APUv2/3 board, which have things like gpios
wired to buttons and LEDs. The board can only be detected via DMI
string, no way to probe the platform devices - have to be initialized
explicitly (that's how I'm already doing it now).

The nicest way, IMHO, would be if I could just write some piece of DTS
and some fancy magic all the rest under the hood. Such thing doesn't
seem to exist yet. Does it make sense to implement that ? How could
we do it ?

Which other options do we have ?

Or should we just leave everything as it is and stick w/ pdata structs ?


thx
--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to inject fwnode/oftree/acpi data by platform driver ?
  2019-06-01 14:14 How to inject fwnode/oftree/acpi data by platform driver ? Enrico Weigelt, metux IT consult
@ 2019-06-11 18:44 ` Andy Shevchenko
  2019-06-12  8:01   ` Heikki Krogerus
  2019-06-11 21:31 ` Rob Herring
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2019-06-11 18:44 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, Krogerus, Heikki
  Cc: LKML, ACPI Devel Maling List, devicetree, Platform Driver

+Cc: Heikki.
Heikki, can you help here with swnodes?

On Sat, Jun 1, 2019 at 5:17 PM Enrico Weigelt, metux IT consult
<lkml@metux.net> wrote:
>
> Hi folks,
>
>
> I'm looking for a way to inject fwnode data from a platform driver,
> in order to initialize generic drivers w/ board specific configuration.
> The idea is getting rid of passing driver specific pdata structs
> (which, IIRC, seem to be deprecated).
>
> An example usecase is the APUv2/3 board, which have things like gpios
> wired to buttons and LEDs. The board can only be detected via DMI
> string, no way to probe the platform devices - have to be initialized
> explicitly (that's how I'm already doing it now).
>
> The nicest way, IMHO, would be if I could just write some piece of DTS
> and some fancy magic all the rest under the hood. Such thing doesn't
> seem to exist yet. Does it make sense to implement that ? How could
> we do it ?
>
> Which other options do we have ?
>
> Or should we just leave everything as it is and stick w/ pdata structs ?
>
>
> thx
> --mtx
>
> --
> Enrico Weigelt, metux IT consult
> Free software and Linux embedded engineering
> info@metux.net -- +49-151-27565287



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to inject fwnode/oftree/acpi data by platform driver ?
  2019-06-01 14:14 How to inject fwnode/oftree/acpi data by platform driver ? Enrico Weigelt, metux IT consult
  2019-06-11 18:44 ` Andy Shevchenko
@ 2019-06-11 21:31 ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2019-06-11 21:31 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: LKML, linux-acpi, devicetree, Platform Driver

On Sat, Jun 1, 2019 at 8:14 AM Enrico Weigelt, metux IT consult <lkml@metux.net> wrote:
>
> Hi folks,
>
>
> I'm looking for a way to inject fwnode data from a platform driver,
> in order to initialize generic drivers w/ board specific configuration.
> The idea is getting rid of passing driver specific pdata structs
> (which, IIRC, seem to be deprecated).
>
> An example usecase is the APUv2/3 board, which have things like gpios

No idea what an APU board is...

> wired to buttons and LEDs. The board can only be detected via DMI
> string, no way to probe the platform devices - have to be initialized
> explicitly (that's how I'm already doing it now).

Detecting a board or attachment of some set of devices is a separate problem from how we describe the devices.

> The nicest way, IMHO, would be if I could just write some piece of DTS
> and some fancy magic all the rest under the hood. Such thing doesn't
> seem to exist yet. Does it make sense to implement that ? How could
> we do it ?

Not the first time this has come up. The general idea is to use DT overlays, but support is not complete. There's at least 2 scenarios. A DT based platform and you are applying overlays to the base DT. The second scenario which probably matches your use case is ov


>
> Which other options do we have ?
>
> Or should we just leave everything as it is and stick w/ pdata structs ?
>
>
> thx
> --mtx
>
> --
> Enrico Weigelt, metux IT consult
> Free software and Linux embedded engineering
> info@metux.net -- +49-151-27565287

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to inject fwnode/oftree/acpi data by platform driver ?
  2019-06-11 18:44 ` Andy Shevchenko
@ 2019-06-12  8:01   ` Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2019-06-12  8:01 UTC (permalink / raw)
  To: Andy Shevchenko, Enrico Weigelt, metux IT consult
  Cc: LKML, ACPI Devel Maling List, devicetree, Platform Driver

Hi,

On Tue, Jun 11, 2019 at 09:44:23PM +0300, Andy Shevchenko wrote:
> +Cc: Heikki.
> Heikki, can you help here with swnodes?
> 
> On Sat, Jun 1, 2019 at 5:17 PM Enrico Weigelt, metux IT consult
> <lkml@metux.net> wrote:
> >
> > Hi folks,
> >
> >
> > I'm looking for a way to inject fwnode data from a platform driver,
> > in order to initialize generic drivers w/ board specific configuration.
> > The idea is getting rid of passing driver specific pdata structs
> > (which, IIRC, seem to be deprecated).
> >
> > An example usecase is the APUv2/3 board, which have things like gpios
> > wired to buttons and LEDs. The board can only be detected via DMI
> > string, no way to probe the platform devices - have to be initialized
> > explicitly (that's how I'm already doing it now).
> >
> > The nicest way, IMHO, would be if I could just write some piece of DTS
> > and some fancy magic all the rest under the hood. Such thing doesn't
> > seem to exist yet. Does it make sense to implement that ? How could
> > we do it ?
> >
> > Which other options do we have ?
> >
> > Or should we just leave everything as it is and stick w/ pdata structs ?

The software nodes (drivers/base/swnode.c) were designed to supply
fwnodes that describe devices in the same way DT does. The goal I had
with the software nodes was exaclty to get rid of pdata, so they do
sound like the thing you are looking for. If you check Rafael's latest
linux-next branch [1], drivers/platform/x86/intel_cht_int33fe.c can be
used as an example how to use the software nodes.

I think it's time to add documentation for the software nodes to the
kernel, but I'll list here the features the software nodes have:

- The software nodes are created independently from device entries.
- Software nodes support hierarchy. Every software node has a pointer
  to a parent software node.
- Software nodes can have device properties.
- Software nodes can have reference pointers to other software nodes
  (outside of the hierarchy).

Creating the software nodes from static description (struct
software_node - available from Linux kernel v5.3 onwards) is
straightforward. Once you have them, when you create your device
entries (struct device), you can associate a software node with a
device just like like any other fwnode:

        device_initialize(&my_dev);
        my_dev.parent = parent;
        my_dev.fwnode = software_node_fwnode(&my_node);
        ...
        device_add(&my_device);

After that, you can access all the information the software nodes
supply to the device by using fwnode_* APIs from your driver, just
like with ACPI or DT. Basically the entire fwnode_* API is now
supported with softwarw nodes, except the device graph (fwnode_graph*)
API.

One final note. The hardware description must always primarily come
from the system firmware. You only use software nodes if it's too
late to influence what goes to the ACPI tables, or if using DTS is not
an option.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/log/?h=linux-next

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-12  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-01 14:14 How to inject fwnode/oftree/acpi data by platform driver ? Enrico Weigelt, metux IT consult
2019-06-11 18:44 ` Andy Shevchenko
2019-06-12  8:01   ` Heikki Krogerus
2019-06-11 21:31 ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.