Linux-Devicetree Archive on lore.kernel.org
 help / color / Atom feed
From: Michael Walle <michael@walle.cc>
To: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Subject: MFD and device tree modeling
Date: Sat, 28 Mar 2020 22:53:56 +0100
Message-ID: <e55d59a68f497c8f2eb406d40ae878b9@walle.cc> (raw)

Hi Rob, Hi Lee,

The MFD subsystem can match a mfd_cell to a device tree node. The
current matching just looks at the compatible string. But this
falls short when there are multiple sub devices with the same
compatible string.

In my first try (see [1]), I tried to match the reg property to
the cell id. But this will result in a warning if there are two
subdevices with the same cell id but different compatible string.
For example:

mfd-device {
   gpio@0 {
     compatible = "vendor,gpio";
     reg = <0>;
   };

   gpio@1 {
     compatible = "vendor,gpio";
     reg = <1>;
   };

   pwm@0 {
     compatible = "vendor,pwm";
     reg = <0>;
   };
};

So, my next idea was to have a "linux,mfd-cell-id" property, but
this will have the same warning because apparently it is not
allowed to have a unit-address in the node name without a reg
property, correct?
Example:

mfd-device {
   gpio@0 {
     compatible = "vendor,gpio";
     linux,mfd-cell-id = <0>;
   };

   gpio@1 {
     compatible = "vendor,gpio";
     linux,mfd-cell-id = <1>;
   };

   pwm@0 {
     compatible = "vendor,pwm";
     linux,mfd-cell-id = <0>;
   };
};

So the third idea was to not have the node names with an
unit-address but just named gpio0, gpio1, etc. But this falls
short for the $nodename restriction in pwm.yaml, which has to
be pwm@N. So I guess the only one is to use artificial
unit-addresses and linux,mfd-cell-id.
Example:

mfd-device {
   gpio@0 {
     compatible = "vendor,gpio";
     reg = <0>;
     linux,mfd-cell-id = <0>;
   };

   gpio@1 {
     compatible = "vendor,gpio";
     reg = <1>;
     linux,mfd-cell-id = <1>;
   };

   pwm@2 {
     compatible = "vendor,pwm";
     reg = <2>;
     linux,mfd-cell-id = <0>;
   };
};

What do you think?

Please note that I cannot use some kind of register offset for
the unit-address, because that will be given by the mfd core
driver. That is because the register layout might be updated
in the future and I want to keep the register offsets just
in the mfd core driver.

-michael


[1] 
https://lore.kernel.org/linux-devicetree/20200317205017.28280-4-michael@walle.cc/

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=e55d59a68f497c8f2eb406d40ae878b9@walle.cc \
    --to=michael@walle.cc \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.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

Linux-Devicetree Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-devicetree/0 linux-devicetree/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-devicetree linux-devicetree/ https://lore.kernel.org/linux-devicetree \
		devicetree@vger.kernel.org
	public-inbox-index linux-devicetree

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-devicetree


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git