Thread (1 message) 1 message, 1 author, 2011-09-08

Re: [PATCH v2] dtc: Add support for named integer constants

From: Simon Glass <hidden>
Date: 2011-09-08 13:18:21

Hi Stephen,

On Thu, Sep 8, 2011 at 6:09 AM, Simon Glass [off-list ref] wrote:
Hi Stephen,

On Fri, Sep 2, 2011 at 11:34 AM, Stephen Warren [off-list ref] wrote:
quoted
Stephen Warren wrote at Tuesday, August 30, 2011 3:30 PM:
quoted
You may define constants as follows:

/define/ TWO 2;
/define/ FOUR 4;
/define/ OTHER FOUR;

And properties may use these values as follows:

foo = <1 TWO 3 FOUR 5>;

Signed-off-by: Stephen Warren <redacted>
David, Jon,

Does this seem reasonable?

I think the syntax is simple enough it wouldn't interfere with any more
advanced expression/function/... support in the future, and it could be
easily extended to allow e.g.:

/define/ FOO "BAR";
/define/ BAX [0af8dacb0];
...
This seems very reasonable to me, and very useful. From the syntax it
looks like lower case symbols are allowed also, which is fine with me.

I hope that this can go into dtc as we would definitely use it.

Regards,
Simon
quoted
And even arbitrary expressions on the RHS as/when/if support is added
for those more generally:

/define/ A (B | (C << 2));
[in a separate email since I don't want to pollute my comments on
Stephen's nice patch with separate ravings]

Thinking of bitfields, we already have a problem with the way GPIOs
are specified. Typically we do something like:

something = <&gpio 46 5>

and define the third parameter to be three bits (direction, initial
value, polarity). It would be nice to be able to do something like:

something = <&gpio 46 INPUT,ACTIVE_LOW>
something-else = <&gpio 46 OUTPUT,HIGH>

instead. That would avoid having to explicitly have expressions
containing | or define all combinations like this:

/define/ INPUT 0
/define/ OUTPUT_LOW 2
/define/ OUTPUT_HIGH 3
/define/ INPUT_INVERT 4
/define/ OUTPUT_LOW_INVERT 6
/define/ OUTPUT_HIGH_INVERT 7

which seems more confusing to me. Some hardware has options for
pull-ups also, which I haven't yet addressed in code.

So how about an easy way to combine bit masks into a single integer?

Regards,
Simon
quoted
--
nvpublic

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help