[1/2] dt-bindings: Add syscon-names support
diff mbox series

Message ID 20191114114525.12675-2-orson.zhai@unisoc.com
State Changes Requested
Headers show
Series
  • [1/2] dt-bindings: Add syscon-names support
Related show

Checks

Context Check Description
robh/checkpatch success

Commit Message

Orson Zhai Nov. 14, 2019, 11:45 a.m. UTC
Make life easier when syscon consumer want to access multiple syscon
nodes.
Add syscon-names and relative properties to help manage complicated
cases when accessing more one syscon node.

Signed-off-by: Orson Zhai <orson.zhai@unisoc.com>
---
 .../devicetree/bindings/mfd/syscon.txt        | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

Comments

Arnd Bergmann Nov. 15, 2019, 9:33 a.m. UTC | #1
On Thu, Nov 14, 2019 at 12:48 PM Orson Zhai <orson.zhai@unisoc.com> wrote:
>
>
> Make life easier when syscon consumer want to access multiple syscon
> nodes.
> Add syscon-names and relative properties to help manage complicated
> cases when accessing more one syscon node.
>
> Signed-off-by: Orson Zhai <orson.zhai@unisoc.com>

Hi Orson,

Can you explain why the number of cells in this binding is specific
to the syscon node rather than the node referencing it?

In most other bindings that follow the same scheme, the additional
arguments are interpreted by the subsystem that is being referenced,
but the syscon driver is just a simple driver with no subsystem and no
code to interpret those arguments.

The way would otherwise handle the example from your binding
would be with two separate properties in the display node, like

syscon-enable = <&ap_apb_regs 0x4 0xf00>;
syscon-power = <&aon_regs 0x8>;

in which case, the syscon driver does not need to know anything
about how it's being used, and the display driver is the one making
sense of the arguments according to its own binding.

I assume you have some good reason for introducing the other
approach, but I don't understand it from your submission.

       Arnd
Orson Zhai Nov. 18, 2019, 8:39 a.m. UTC | #2
Hi Arnd,

On Fri, Nov 15, 2019 at 10:33:30AM +0100, Arnd Bergmann wrote:
> On Thu, Nov 14, 2019 at 12:48 PM Orson Zhai <orson.zhai@unisoc.com> wrote:
> >
> >
> > Make life easier when syscon consumer want to access multiple syscon
> > nodes.
> > Add syscon-names and relative properties to help manage complicated
> > cases when accessing more one syscon node.
> >
> > Signed-off-by: Orson Zhai <orson.zhai@unisoc.com>
>
> Hi Orson,
>
> Can you explain why the number of cells in this binding is specific
> to the syscon node rather than the node referencing it?

The story is like this. I found there are too many global registers in
Unisoc(former Spreadtrum) chips. Dozens of offset with dozens of modules
were needed to be specified. So I thought the dts files would seem "horrible"
with a big chunk of syscon-xxx (say more than 20 lines)

I learned from reg-names way which might look clean to hold all these mess things.
But to implement this, the users need to konw the cell-size if we add arguments to syscon node.
I thought to add cell-size into every syscon consumer node is a duplicated work and
I wanted to take advantage of of_parse_phandle_with_args.
So the bindings were created then.


>
> In most other bindings that follow the same scheme, the additional
> arguments are interpreted by the subsystem that is being referenced,
> but the syscon driver is just a simple driver with no subsystem and no
> code to interpret those arguments.

You're correct. I've realized it is narraw to pass here.

>
> The way would otherwise handle the example from your binding
> would be with two separate properties in the display node, like
>
> syscon-enable = <&ap_apb_regs 0x4 0xf00>;
> syscon-power = <&aon_regs 0x8>;

This is an option for consumers all the time.
Acturally my patches are not going to replace this.
I'd like to provide another option to save people like desperate engineers in Spreadtrum :)

>
> in which case, the syscon driver does not need to know anything

Whould it be better if I add syscon-cells into consumer's node?
Then I could read the cell size and use "of_parse_phandle_with_fixed_args()" instead.
This will not involve syscon node itself at all.

Best Regards,
-Orson
> about how it's being used, and the display driver is the one making
> sense of the arguments according to its own binding.
>
> I assume you have some good reason for introducing the other
> approach, but I don't understand it from your submission.
>
>        Arnd
Arnd Bergmann Nov. 19, 2019, 2:20 p.m. UTC | #3
On Mon, Nov 18, 2019 at 9:42 AM Orson Zhai <orson.zhai@spreadtrum.com> wrote:
>
> Hi Arnd,
>
> On Fri, Nov 15, 2019 at 10:33:30AM +0100, Arnd Bergmann wrote:
> > On Thu, Nov 14, 2019 at 12:48 PM Orson Zhai <orson.zhai@unisoc.com> wrote:
> > >
> > >
> > > Make life easier when syscon consumer want to access multiple syscon
> > > nodes.
> > > Add syscon-names and relative properties to help manage complicated
> > > cases when accessing more one syscon node.
> > >
> > > Signed-off-by: Orson Zhai <orson.zhai@unisoc.com>
> >
> > Hi Orson,
> >
> > Can you explain why the number of cells in this binding is specific
> > to the syscon node rather than the node referencing it?
>
> The story is like this. I found there are too many global registers in
> Unisoc(former Spreadtrum) chips. Dozens of offset with dozens of modules
> were needed to be specified. So I thought the dts files would seem "horrible"
> with a big chunk of syscon-xxx (say more than 20 lines)
>
> I learned from reg-names way which might look clean to hold all these mess things.
> But to implement this, the users need to konw the cell-size if we add arguments to syscon node.
> I thought to add cell-size into every syscon consumer node is a duplicated work and
> I wanted to take advantage of of_parse_phandle_with_args.
> So the bindings were created then.

Ok, that makes sense.

> > The way would otherwise handle the example from your binding
> > would be with two separate properties in the display node, like
> >
> > syscon-enable = <&ap_apb_regs 0x4 0xf00>;
> > syscon-power = <&aon_regs 0x8>;
>
> This is an option for consumers all the time.
> Acturally my patches are not going to replace this.
> I'd like to provide another option to save people like desperate engineers in Spreadtrum :)
>
> >
> > in which case, the syscon driver does not need to know anything
>
> Whould it be better if I add syscon-cells into consumer's node?

As I see it, there is no reason to put the syscon-cells property into any node,
as this is implied by the driver binding using the syscon reference.  I would
only use the #xyz-cells style property if there are multiple interpretations
that all make sense for the same binding.

> Then I could read the cell size and use "of_parse_phandle_with_fixed_args()" instead.
> This will not involve syscon node itself at all.

This sounds better to me, yes. I had not even remembered this function
exists, but I think this is a good idea.

I can also see a point in favor of adding more infrastructure around this,
possibly naming the entries in a syscon-names property as you suggested,
combining of_parse_phandle_with_fixed_args() with a name, or
combining with syscon_regmap_lookup_by_phandle() for convenience.

This should all be possible without adding complexity to the syscon
DT binding itself, and it would give more structure to the way it
is used by drivers.

       Arnd
Arnd Bergmann Nov. 19, 2019, 2:46 p.m. UTC | #4
On Mon, Nov 18, 2019 at 9:42 AM Orson Zhai <orson.zhai@spreadtrum.com> wrote:
>
> Hi Arnd,
>
> On Fri, Nov 15, 2019 at 10:33:30AM +0100, Arnd Bergmann wrote:
> > On Thu, Nov 14, 2019 at 12:48 PM Orson Zhai <orson.zhai@unisoc.com> wrote:
> > >
> > >
> > > Make life easier when syscon consumer want to access multiple syscon
> > > nodes.
> > > Add syscon-names and relative properties to help manage complicated
> > > cases when accessing more one syscon node.
> > >
> > > Signed-off-by: Orson Zhai <orson.zhai@unisoc.com>
> >
> > Hi Orson,
> >
> > Can you explain why the number of cells in this binding is specific
> > to the syscon node rather than the node referencing it?
>
> The story is like this. I found there are too many global registers in
> Unisoc(former Spreadtrum) chips. Dozens of offset with dozens of modules
> were needed to be specified. So I thought the dts files would seem "horrible"
> with a big chunk of syscon-xxx (say more than 20 lines)
>
> I learned from reg-names way which might look clean to hold all these mess things.
> But to implement this, the users need to konw the cell-size if we add arguments to syscon node.
> I thought to add cell-size into every syscon consumer node is a duplicated work and
> I wanted to take advantage of of_parse_phandle_with_args.
> So the bindings were created then.

Ok, that makes sense.

> > The way would otherwise handle the example from your binding
> > would be with two separate properties in the display node, like
> >
> > syscon-enable = <&ap_apb_regs 0x4 0xf00>;
> > syscon-power = <&aon_regs 0x8>;
>
> This is an option for consumers all the time.
> Acturally my patches are not going to replace this.
> I'd like to provide another option to save people like desperate engineers in Spreadtrum :)
>
> >
> > in which case, the syscon driver does not need to know anything
>
> Whould it be better if I add syscon-cells into consumer's node?

As I see it, there is no reason to put the syscon-cells property into any node,
as this is implied by the driver binding using the syscon reference.  I would
only use the #xyz-cells style property if there are multiple interpretations
that all make sense for the same binding.

> Then I could read the cell size and use "of_parse_phandle_with_fixed_args()" instead.
> This will not involve syscon node itself at all.

This sounds better to me, yes. I had not even remembered this function
exists, but I think this is a good idea.

I can also see a point in favor of adding more infrastructure around this,
possibly naming the entries in a syscon-names property as you suggested,
combining of_parse_phandle_with_fixed_args() with a name, or
combining with syscon_regmap_lookup_by_phandle() for convenience.

This should all be possible without adding complexity to the syscon
DT binding itself, and it would give more structure to the way it
is used by drivers.

       Arnd
Orson Zhai Nov. 20, 2019, 3:49 p.m. UTC | #5
Hi Arnd,

On Tue, Nov 19, 2019 at 03:46:09PM +0100, Arnd Bergmann wrote:
> On Mon, Nov 18, 2019 at 9:42 AM Orson Zhai <orson.zhai@spreadtrum.com> wrote:
> >
> > Hi Arnd,
> >
> > On Fri, Nov 15, 2019 at 10:33:30AM +0100, Arnd Bergmann wrote:
> > > On Thu, Nov 14, 2019 at 12:48 PM Orson Zhai <orson.zhai@unisoc.com> wrote:
> > > >
> > > >
> > > > Make life easier when syscon consumer want to access multiple syscon
> > > > nodes.
> > > > Add syscon-names and relative properties to help manage complicated
> > > > cases when accessing more one syscon node.
> > > >
> > > > Signed-off-by: Orson Zhai <orson.zhai@unisoc.com>
> > >
> > > Hi Orson,
> > >
> > > Can you explain why the number of cells in this binding is specific
> > > to the syscon node rather than the node referencing it?
> >
> > The story is like this. I found there are too many global registers in
> > Unisoc(former Spreadtrum) chips. Dozens of offset with dozens of modules
> > were needed to be specified. So I thought the dts files would seem "horrible"
> > with a big chunk of syscon-xxx (say more than 20 lines)
> >
> > I learned from reg-names way which might look clean to hold all these mess things.
> > But to implement this, the users need to konw the cell-size if we add arguments to syscon node.
> > I thought to add cell-size into every syscon consumer node is a duplicated work and
> > I wanted to take advantage of of_parse_phandle_with_args.
> > So the bindings were created then.
>
> Ok, that makes sense.
>
> > > The way would otherwise handle the example from your binding
> > > would be with two separate properties in the display node, like
> > >
> > > syscon-enable = <&ap_apb_regs 0x4 0xf00>;
> > > syscon-power = <&aon_regs 0x8>;
> >
> > This is an option for consumers all the time.
> > Acturally my patches are not going to replace this.
> > I'd like to provide another option to save people like desperate engineers in Spreadtrum :)
> >
> > >
> > > in which case, the syscon driver does not need to know anything
> >
> > Whould it be better if I add syscon-cells into consumer's node?
>
> As I see it, there is no reason to put the syscon-cells property into any node,
> as this is implied by the driver binding using the syscon reference.  I would
> only use the #xyz-cells style property if there are multiple interpretations
> that all make sense for the same binding.
>
> > Then I could read the cell size and use "of_parse_phandle_with_fixed_args()" instead.
> > This will not involve syscon node itself at all.
>
> This sounds better to me, yes. I had not even remembered this function
> exists, but I think this is a good idea.
>
> I can also see a point in favor of adding more infrastructure around this,
> possibly naming the entries in a syscon-names property as you suggested,
> combining of_parse_phandle_with_fixed_args() with a name, or
> combining with syscon_regmap_lookup_by_phandle() for convenience.
>
> This should all be possible without adding complexity to the syscon
> DT binding itself, and it would give more structure to the way it
> is used by drivers.

V2 has been sent out per as you suggested.

Free free to review please.

Best Regards,
-Orson
>
>        Arnd

Patch
diff mbox series

diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt b/Documentation/devicetree/bindings/mfd/syscon.txt
index 25d9e9c2fd53..ca7bc7608c15 100644
--- a/Documentation/devicetree/bindings/mfd/syscon.txt
+++ b/Documentation/devicetree/bindings/mfd/syscon.txt
@@ -17,6 +17,8 @@  Optional property:
 - reg-io-width: the size (in bytes) of the IO accesses that should be
   performed on the device.
 - hwlocks: reference to a phandle of a hardware spinlock provider node.
+- #syscon-cells: represents the number of args. Used when syscon-names
+  is going to be used. The value is vendor specific.
 
 Examples:
 gpr: iomuxc-gpr@20e0000 {
@@ -30,3 +32,37 @@  hwlock1: hwspinlock@40500000 {
 	reg = <0x40500000 0x1000>;
 	#hwlock-cells = <1>;
 };
+
+
+==Syscon names==
+
+Refer to syscon node by names with phandle args in syscon consumer node.
+
+Required properties:
+- syscons:	List of phandle and any number of args. Args is specific to
+		differnet vendor. For example: In Unisoc SoCs, the 1st arg
+		will be treated as register address offset and the 2nd is bit
+		mask as default.
+
+- syscon-names:	List of syscon node name strings sorted in the same
+		order as the syscons property.
+
+Examples:
+
+apb_regs: syscon@20008000 {
+	compatible = "sprd,apb-glb", "syscon";
+	#syscon-cells = <2>;
+	reg = <0x20008000 0x100>;
+};
+
+aon_regs: syscon@40008000 {
+	compatible = "sprd,aon-glb", "syscon";
+	#syscon-cells = <1>;
+	reg = <0x40008000 0x100>;
+};
+
+display@40500000 {
+	...
+	syscons = <&ap_apb_regs 0x4 0xf00>, <&aon_regs 0x8>;
+	syscon-names = "enable", "power";
+};