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@xxxxxxxx/