Skip to contentSkip to conversation

Clock binding

RFC Benjamin Herrenschmidt 11 participants 25 messages Aug 18, 2009 – Aug 31, 2009 8 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

So here's a followup to my discussion about the clock API.

I'm cooking up a patch that replace our current primitive implementation in arch/powerpc/kernel/clock.c with something along the lines of what I described. However, I want a bit more churn here on the device-tree related bits.

So, basically, the goal here is to define a binding so that we can link a device clock inputs to a clock provider clock outputs.

In general, in a system, there's actually 3 "names" involved. The clock provider output name, the clock signal name, and the clock input name on the device. However, I want to avoid involving the clock signal name as it's a "global" name and it will just end up being a mess if we start exposing that.

So basically, it boils down to a device having some clock inputs, referenced by names, that need to be linked to another node which is a clock provider, which has outputs, references either by number or names, see discussion below.

First, why names, and not numbers ? IE. It's the OF "tradition" for resources to just be an array, like interrupts, or address ranges in "reg" properties, and one has to know what the Nth interrupt correspond too.

My answer here is that maybe the tradition but it's crap :-) Names are much better in the long run, besides it makes it easier to represent if not all inputs have been wired. Also, to some extent, things like PCI do encode a "name" with "reg" or "assigned-addresses" properties as part of the config space offset in the top part of the address, and that has proved very useful.

Thus I think using names is the way to go, and we should even generalize that and add a new "interrupt-names" property to name the members of an "interrupts" :-)

So back to the subject at hand. That leaves us with having to populate the driver with some kind of map (I call it clock-map). Ideally, if everything is named, which is the best approach imho, that map would bind a list of:

- clock input name
- clock provider phandle
- clock output name on provider

However, it's a bit nasty to mix strings and numbers (phandles) in a single property. It's possible, but would likely lead to the phandle not being aligned and tools such as lsprop to fail miserably to display those properties in any kind of readable form.

My earlier emails proposed an approach like this:

- clock input names go into a "clock-names" property (which I suggest naming instead "clock-input-names" btw)

- the map goes into a "clock-map" property and for each input provides a phandle and a one cell numerical ID that identifies the clock on the source.

However, I really dislike that numerical clock ID. Magic numbers suck. It should be a string. But I don't want to add a 3rd property in there.

Hence my idea below. It's not perfect but it's the less sucky i've come up with so far. And then we can do some small refinements.

* Device has:

- "clock-input-names" as above
- "clock-map" contains list of phandle,index

* Clock source has:

- "clock-output-names" list of strings

The "index" in the clock map thus would reference the "clock-output-names" array in the clock provider. That means that the "magic number" here is entirely local to a given device-tree, doesn't leak into driver code, which continues using names.

In addition, we can even have some smooth "upgrade" path from existing "clock-frequency" properties by assuming that if "clock-output-names" is absent, but "clock-frequency" exist, then index 0 references a fixed frequency clock source without a driver. This could be generally handy anyway to represent crystals of fixed bus clocks without having to write a clock source driver for them.

Any comments ?

I'll post a patch, maybe later today, implementing the above (I may or may not have time to also convert the existing 512x code to it, we'll see).

Cheers,
Ben.

#1 lore raw

[RFC/PATCH] Clock binding prototype implementation

powerpc: New implementation of the "clk" API with device-tree binding

This replaces the struct clk_interface, as far as I know only ever used by the mpc512x platforms, with a new scheme:

struct clk is now an object containing function pointers for all the base API routines. The implementation of those routines call into those pointers. struct clk is meant to be embedded in the "real" structure for a given clock type.

clk_get is hooked via ppc_md. A default implementation is provided that uses the device-tree binding (still being discussed, a patch to Documentation/* will come when it's final). It can also create simple objects (no control, working get_rate()) based on nodes that have a "clock-frequency" property.

Finally, the mpc512x code is adapted. The adaptation is minimal as I don't have test gear, so I'm not using nor touching the device-tree on this one, but instead hooking ppc_md.get_clk() and keeping the old code mostly intact (just some type changes to embed the new struct clk into the mpc512x specific variants which gets renamed to struct mpc512x_clk).

No S-O-B yet as this is totally untested and the binding isn't final yet neither, but gives an idea of where I'm going.

Ben.

arch/powerpc/include/asm/clk_interface.h deleted +0 -20
Index: linux-work/arch/powerpc/include/asm/clk_interface.h
===================================================================
@@ -1,20 +0,0 @@
-#ifndef __ASM_POWERPC_CLK_INTERFACE_H
-#define __ASM_POWERPC_CLK_INTERFACE_H
-
-#include <linux/clk.h>
-
-struct clk_interface {
-	struct clk*	(*clk_get)	(struct device *dev, const char *id);
-	int		(*clk_enable)	(struct clk *clk);
-	void		(*clk_disable)	(struct clk *clk);
-	unsigned long	(*clk_get_rate)	(struct clk *clk);
-	void		(*clk_put)	(struct clk *clk);
-	long		(*clk_round_rate) (struct clk *clk, unsigned long rate);
-	int 		(*clk_set_rate)	(struct clk *clk, unsigned long rate);
-	int		(*clk_set_parent) (struct clk *clk, struct clk *parent);
-	struct clk*	(*clk_get_parent) (struct clk *clk);
-};
-
-extern struct clk_interface clk_functions;
-
-#endif /* __ASM_POWERPC_CLK_INTERFACE_H */
arch/powerpc/kernel/clock.c +234 -34

316 lines not on this page · raw message

arch/powerpc/include/asm/clk.h new file +61 -0

61 lines not on this page · raw message

arch/powerpc/include/asm/machdep.h +7 -1
Index: linux-work/arch/powerpc/include/asm/machdep.h
===================================================================
@@ -27,6 +27,8 @@ struct iommu_table;
 struct rtc_time;
 struct file;
 struct pci_controller;
+struct clk;
+struct device;
 #ifdef CONFIG_KEXEC
 struct kimage;
 #endif
@@ -266,7 +268,11 @@ struct machdep_calls {
 	 */
 	void (*suspend_disable_irqs)(void);
 	void (*suspend_enable_irqs)(void);
-#endif
+#endif /* CONFIG_SUSPEND */
+
+#ifdef CONFIG_PPC_CLOCK
+	struct clk *(*clk_get)(struct device *dev, const char *id);
+#endif /* CONFIG_PPC_CLOCK */
 };
 
 extern void e500_idle(void);
arch/powerpc/platforms/512x/clock.c +83 -76

478 lines not on this page · raw message

#2 lore raw
In reply to Benjamin Herrenschmidt
Quoted 1 line · Benjamin Herrenschmidt

So here's a followup to my discussion about the clock API.

Really nobody has a comment here ? :-) Not even Mitch ?

Cheers,
Ben.

Quoted 102 lines

I'm cooking up a patch that replace our current primitive implementation in arch/powerpc/kernel/clock.c with something along the lines of what I described. However, I want a bit more churn here on the device-tree related bits.

So, basically, the goal here is to define a binding so that we can link a device clock inputs to a clock provider clock outputs.

In general, in a system, there's actually 3 "names" involved. The clock provider output name, the clock signal name, and the clock input name on the device. However, I want to avoid involving the clock signal name as it's a "global" name and it will just end up being a mess if we start exposing that.

So basically, it boils down to a device having some clock inputs, referenced by names, that need to be linked to another node which is a clock provider, which has outputs, references either by number or names, see discussion below.

First, why names, and not numbers ? IE. It's the OF "tradition" for resources to just be an array, like interrupts, or address ranges in "reg" properties, and one has to know what the Nth interrupt correspond too.

My answer here is that maybe the tradition but it's crap :-) Names are much better in the long run, besides it makes it easier to represent if not all inputs have been wired. Also, to some extent, things like PCI do encode a "name" with "reg" or "assigned-addresses" properties as part of the config space offset in the top part of the address, and that has proved very useful.

Thus I think using names is the way to go, and we should even generalize that and add a new "interrupt-names" property to name the members of an "interrupts" :-)

So back to the subject at hand. That leaves us with having to populate the driver with some kind of map (I call it clock-map). Ideally, if everything is named, which is the best approach imho, that map would bind a list of:

- clock input name
- clock provider phandle
- clock output name on provider

However, it's a bit nasty to mix strings and numbers (phandles) in a single property. It's possible, but would likely lead to the phandle not being aligned and tools such as lsprop to fail miserably to display those properties in any kind of readable form.

My earlier emails proposed an approach like this:

- clock input names go into a "clock-names" property (which I suggest naming instead "clock-input-names" btw)

- the map goes into a "clock-map" property and for each input provides a phandle and a one cell numerical ID that identifies the clock on the source.

However, I really dislike that numerical clock ID. Magic numbers suck. It should be a string. But I don't want to add a 3rd property in there.

Hence my idea below. It's not perfect but it's the less sucky i've come up with so far. And then we can do some small refinements.

* Device has:

- "clock-input-names" as above
- "clock-map" contains list of phandle,index

* Clock source has:

- "clock-output-names" list of strings

The "index" in the clock map thus would reference the "clock-output-names" array in the clock provider. That means that the "magic number" here is entirely local to a given device-tree, doesn't leak into driver code, which continues using names.

In addition, we can even have some smooth "upgrade" path from existing "clock-frequency" properties by assuming that if "clock-output-names" is absent, but "clock-frequency" exist, then index 0 references a fixed frequency clock source without a driver. This could be generally handy anyway to represent crystals of fixed bus clocks without having to write a clock source driver for them.

Any comments ?

I'll post a patch, maybe later today, implementing the above (I may or may not have time to also convert the existing 512x code to it, we'll see).

Cheers,
Ben.

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#3 lore raw
Quoted 4 lines · Benjamin Herrenschmidt
Quoted 1 line · Benjamin Herrenschmidt

So here's a followup to my discussion about the clock API.

Really nobody has a comment here ? :-) Not even Mitch ?

Been wanting too.. a little swamped with kids going back to school tomorrow. Hopefully I'll be able to dig in before the end of the week.

g.

#4 lore raw
In reply to Benjamin Herrenschmidt
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 3 lines
Quoted 2 lines

So here's a followup to my discussion about the clock API.

Really nobody has a comment here ? :-) Not even Mitch ?

I refrained from commenting as I didn't want to get involved in an endless argument about "goodness".

Indexed arrays are appropriate for some cases and names are better for others. Names are especially good for large spaces that are sparse or weakly-structured. The same is true for subroutine arguments. It's nice to be able to write setup_uart(baud=115200, flow_control=rts_cts), but you would go crazy (or become a COBOL programmer) if you had to name every argument to every subroutine.

Open Firmware often avoids indexed structures. Cases in point include the use of named properties instead of fixed structures and named methods instead of function pointer arrays. Open Firmware's use of arrays for reg properties seems like the right choice for that particular case, but shouldn't be construed to suggest that arrays are good for everything.

One problem you run into with names is the "registration authority" problem. Who maintains the list of valid names to avoid collisions and to ensure consistent spelling? It's a solvable problem, but one that must be considered. Of course, a related problem exists with indices - what is the meaning of index value "N", and how do you manage the addition of new fields and deletion of others? Names are easier to manage in some cases and indices easier in others.

In the particular case of a clock binding, I don't have enough experience with the problem details to have formed a strong opinion.

Are there well-known clock names that will be used in common code that is shared among different vendors (e.g. "primary-clock")? If so, the binding should "preregister" a list of common names.

Will implementors of new hardware have to scratch their heads to decide what to name their clock inputs? The binding should offer some guidance about good name choices and spelling rules, to avoid an eventuall mess as new people come on board and pull names out of the air, with different conventions for capitalization and punctuation and abbreviation.

One advantage of indices is that they avoid endless arguments about the exact name (and spelling) of things. In my current project, there are several different hardware manuals for the same that must all be consulted to get the full picture, and they often use different names or inconsistent spellings for the same thing. It makes finding things very challenging.

With a name-based interface, it pays to keep in mind that lots of people will ultimately be involved. Many of them will be new so they won't know the conventions well, and few will be careful and precise in their use of language (i.e. names). Provide a lot of guidance about how to choose a set of names.

Suppose there were a conventional set of names like "clock0", "clock1", ..., essentially boiling down to verbosely-spelled indices. I expect that a lot of people would choose to use it just to avoid having to thing of better names and having "bike shed" arguments with coworkers.

So there you have it - my incoherent rambling commentary with no particular conclusion.

Quoted 109 lines

Cheers,
Ben.

Quoted 103 lines
Quoted 102 lines

I'm cooking up a patch that replace our current primitive implementation in arch/powerpc/kernel/clock.c with something along the lines of what I described. However, I want a bit more churn here on the device-tree related bits.

So, basically, the goal here is to define a binding so that we can link a device clock inputs to a clock provider clock outputs.

In general, in a system, there's actually 3 "names" involved. The clock provider output name, the clock signal name, and the clock input name on the device. However, I want to avoid involving the clock signal name as it's a "global" name and it will just end up being a mess if we start exposing that.

So basically, it boils down to a device having some clock inputs, referenced by names, that need to be linked to another node which is a clock provider, which has outputs, references either by number or names, see discussion below.

First, why names, and not numbers ? IE. It's the OF "tradition" for resources to just be an array, like interrupts, or address ranges in "reg" properties, and one has to know what the Nth interrupt correspond too.

My answer here is that maybe the tradition but it's crap :-) Names are much better in the long run, besides it makes it easier to represent if not all inputs have been wired. Also, to some extent, things like PCI do encode a "name" with "reg" or "assigned-addresses" properties as part of the config space offset in the top part of the address, and that has proved very useful.

Thus I think using names is the way to go, and we should even generalize that and add a new "interrupt-names" property to name the members of an "interrupts" :-)

So back to the subject at hand. That leaves us with having to populate the driver with some kind of map (I call it clock-map). Ideally, if everything is named, which is the best approach imho, that map would bind a list of:

- clock input name
- clock provider phandle
- clock output name on provider

However, it's a bit nasty to mix strings and numbers (phandles) in a single property. It's possible, but would likely lead to the phandle not being aligned and tools such as lsprop to fail miserably to display those properties in any kind of readable form.

My earlier emails proposed an approach like this:

- clock input names go into a "clock-names" property (which I suggest naming instead "clock-input-names" btw)

- the map goes into a "clock-map" property and for each input provides a phandle and a one cell numerical ID that identifies the clock on the source.

However, I really dislike that numerical clock ID. Magic numbers suck. It should be a string. But I don't want to add a 3rd property in there.

Hence my idea below. It's not perfect but it's the less sucky i've come up with so far. And then we can do some small refinements.

* Device has:

- "clock-input-names" as above
- "clock-map" contains list of phandle,index

* Clock source has:

- "clock-output-names" list of strings

The "index" in the clock map thus would reference the "clock-output-names" array in the clock provider. That means that the "magic number" here is entirely local to a given device-tree, doesn't leak into driver code, which continues using names.

In addition, we can even have some smooth "upgrade" path from existing "clock-frequency" properties by assuming that if "clock-output-names" is absent, but "clock-frequency" exist, then index 0 references a fixed frequency clock source without a driver. This could be generally handy anyway to represent crystals of fixed bus clocks without having to write a clock source driver for them.

Any comments ?

I'll post a patch, maybe later today, implementing the above (I may or may not have time to also convert the existing 512x code to it, we'll see).

Cheers,
Ben.

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#6 lore raw
In reply to a message not in the archive
Quoted 2 lines · Mitch Bradley

I refrained from commenting as I didn't want to get involved in an endless argument about "goodness".

Oh well, I asked for it, didn't it ? :-)

Quoted 6 lines

Indexed arrays are appropriate for some cases and names are better for others. Names are especially good for large spaces that are sparse or weakly-structured. The same is true for subroutine arguments. It's nice to be able to write setup_uart(baud=115200, flow_control=rts_cts), but you would go crazy (or become a COBOL programmer) if you had to name every argument to every subroutine.

Agreed.

Quoted 6 lines

Open Firmware often avoids indexed structures. Cases in point include the use of named properties instead of fixed structures and named methods instead of function pointer arrays. Open Firmware's use of arrays for reg properties seems like the right choice for that particular case, but shouldn't be construed to suggest that arrays are good for everything.

Well, the "reg" property is fine for the common cases of devices with one IO (or MMIO) range, no confusion possible, or PCI since it encodes the BAR number. For other cases, especially random embedded stuff that maps several regions of memory, it's a bit harder since we go back to the need of having "somebody" define which region is which.

Quoted 2 lines

One problem you run into with names is the "registration authority" problem.

Right.

Quoted 6 lines

Who maintains the list of valid names to avoid collisions and
to ensure consistent spelling? It's a solvable problem, but one that must be considered. Of course, a related problem exists with indices - what is the meaning of index value "N", and how do you manage the addition of new fields and deletion of others? Names are easier to manage in some cases and indices easier in others.

Maybe to some extent. I tend to prefer names whenever possible, but I agree that the "central authority" problem is always around.

Quoted 2 lines

In the particular case of a clock binding, I don't have enough experience with the problem details to have formed a strong opinion.

I'm in a similar situation, hence my request for comment. From my observations though, clock inputs are generally named on a given chip, IO core, SoC, etc... hence, I would suggest using a case insensitive matching with a recommendation to use the name of the clock pin or clock input signal in the case of IP cores as per the spec of the chip. This sounds better than an arbitrary number. So at least for the naming of clock inputs on a device, I do have a warm feeling with using names.

It has the added advantage from my selfish point of view which is that I have to deal in Linux with an existing name based API and existing drivers using it :-) Though the common case for 1 clock per device is to pass NULL, which makes the problem go away.

In the same idea of simplifying the easy cases, you'll note that I made it legit to have a clock provider simply have a "clock-frequency" property and as such "fit" within existing practices for fixed frequency non-programable clock sources.

Now, where I'm less comfortable is the naming on the clock provider side. IE. My initial proposal was calling for binding named inputs to indexed outputs on the provider. My new proposal makes that index a simple convention in a given tree by having the provider also map those to names since I didn't like the discrepancy here.

I suppose we could go roughly with the same idea, which is that the name is case insensitive and matched on the part manufacturer's output pin/signal name.

In any case, I'm sure what we do won't be absolutely perfect but it's that or doing nothing and at this stage I believe we are in a situation where even an imperfect solution will be greatly beneficial. In any case, driver and architecture code can always work around problems such as a device-tree providing a different name than what the driver expects.

Quoted 3 lines

Are there well-known clock names that will be used in common code that is shared among different vendors (e.g. "primary-clock")? If so, the binding should "preregister" a list of common names.

Well... I was more thinking about the signal name on the part. I want to avoid using global clock names. IE. I want to avoid having to put in the picture the name of the clock wires in the SoC or chip (SYSCLK, PCICLK, ...) because typically those do vary from board to board and vendor to vendor. But the name of the clock input on a device chip and the name of the clock output on a PLL chip tend to be defined by the datasheet of the said chip :-) Of course there are going to be interesting variations such as compatible chips from different manufacturers but, mostly we should cope better than magic indices.

Quoted 5 lines

Will implementors of new hardware have to scratch their heads to decide what to name their clock inputs? The binding should offer some guidance about good name choices and spelling rules, to avoid an eventuall mess as new people come on board and pull names out of the air, with different conventions for capitalization and punctuation and abbreviation.

Should they ? IE. If the names come from the part datasheet, and we make the matching case insensitive, I don't see that much need of the chip vendors or board designers caring that much about rules for naming the clocks.

Quoted 2 lines

One advantage of indices is that they avoid endless arguments about the exact name (and spelling) of things.

Right, though in that case, nobody gets to have to decide on the name, it comes from the chip manufacturer pin naming or data sheet.

Quoted 5 lines

In my current project, there are
several different hardware manuals for the same that must all be consulted to get the full picture, and they often use different names or inconsistent spellings for the same thing. It makes finding things very challenging.

Agreed about the general problem area.

Quoted 5 lines

With a name-based interface, it pays to keep in mind that lots of people will ultimately be involved. Many of them will be new so they won't know the conventions well, and few will be careful and precise in their use of language (i.e. names). Provide a lot of guidance about how to choose a set of names.

And the easier the problem appears to be, the more people without a clue about what they are talking about will feel compelled to intervene in the discussion :-)

Quoted 7 lines

Suppose there were a conventional set of names like "clock0", "clock1", ..., essentially boiling down to verbosely-spelled indices. I expect that a lot of people would choose to use it just to avoid having to thing of better names and having "bike shed" arguments with coworkers.

So there you have it - my incoherent rambling commentary with no particular conclusion.

Nah, it's interesting, it also forces me to write down my thought with better details.

Cheers,
Ben.

Quoted 109 lines
Quoted 109 lines

Cheers,
Ben.

Quoted 103 lines
Quoted 102 lines

I'm cooking up a patch that replace our current primitive implementation in arch/powerpc/kernel/clock.c with something along the lines of what I described. However, I want a bit more churn here on the device-tree related bits.

So, basically, the goal here is to define a binding so that we can link a device clock inputs to a clock provider clock outputs.

In general, in a system, there's actually 3 "names" involved. The clock provider output name, the clock signal name, and the clock input name on the device. However, I want to avoid involving the clock signal name as it's a "global" name and it will just end up being a mess if we start exposing that.

So basically, it boils down to a device having some clock inputs, referenced by names, that need to be linked to another node which is a clock provider, which has outputs, references either by number or names, see discussion below.

First, why names, and not numbers ? IE. It's the OF "tradition" for resources to just be an array, like interrupts, or address ranges in "reg" properties, and one has to know what the Nth interrupt correspond too.

My answer here is that maybe the tradition but it's crap :-) Names are much better in the long run, besides it makes it easier to represent if not all inputs have been wired. Also, to some extent, things like PCI do encode a "name" with "reg" or "assigned-addresses" properties as part of the config space offset in the top part of the address, and that has proved very useful.

Thus I think using names is the way to go, and we should even generalize that and add a new "interrupt-names" property to name the members of an "interrupts" :-)

So back to the subject at hand. That leaves us with having to populate the driver with some kind of map (I call it clock-map). Ideally, if everything is named, which is the best approach imho, that map would bind a list of:

- clock input name
- clock provider phandle
- clock output name on provider

However, it's a bit nasty to mix strings and numbers (phandles) in a single property. It's possible, but would likely lead to the phandle not being aligned and tools such as lsprop to fail miserably to display those properties in any kind of readable form.

My earlier emails proposed an approach like this:

- clock input names go into a "clock-names" property (which I suggest naming instead "clock-input-names" btw)

- the map goes into a "clock-map" property and for each input provides a phandle and a one cell numerical ID that identifies the clock on the source.

However, I really dislike that numerical clock ID. Magic numbers suck. It should be a string. But I don't want to add a 3rd property in there.

Hence my idea below. It's not perfect but it's the less sucky i've come up with so far. And then we can do some small refinements.

* Device has:

- "clock-input-names" as above
- "clock-map" contains list of phandle,index

* Clock source has:

- "clock-output-names" list of strings

The "index" in the clock map thus would reference the "clock-output-names" array in the clock provider. That means that the "magic number" here is entirely local to a given device-tree, doesn't leak into driver code, which continues using names.

In addition, we can even have some smooth "upgrade" path from existing "clock-frequency" properties by assuming that if "clock-output-names" is absent, but "clock-frequency" exist, then index 0 references a fixed frequency clock source without a driver. This could be generally handy anyway to represent crystals of fixed bus clocks without having to write a clock source driver for them.

Any comments ?

I'll post a patch, maybe later today, implementing the above (I may or may not have time to also convert the existing 512x code to it, we'll see).

Cheers,
Ben.

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#7 lore raw
Quoted 13 lines
Quoted 4 lines
Quoted 3 lines

Open Firmware often avoids indexed structures. Cases in point include the use of named properties instead of fixed structures and named methods instead of function pointer arrays. Open Firmware's use of arrays for reg properties seems like the right choice for that particular case, but shouldn't be construed to suggest that arrays are good for everything.

Well, the "reg" property is fine for the common cases of devices with one IO (or MMIO) range, no confusion possible, or PCI since it encodes the BAR number. For other cases, especially random embedded stuff that maps several regions of memory, it's a bit harder since we go back to the need of having "somebody" define which region is which.

Indeed. You choose based on the common case and eventually there will be some case that stretches the boundaries.

I suppose that, if the problem became severe enough, one could invent a new "reg-names" property, a list of strings naming the reg entries.

#8 lore raw
In reply to Benjamin Herrenschmidt
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

One advantage of indices is that they avoid endless arguments about the exact name (and spelling) of things.

Right, though in that case, nobody gets to have to decide on the name, it comes from the chip manufacturer pin naming or data sheet.

I agree in general. It has long been a convention of mine to follow the vendor's names as exactly as possible. But that often presents difficulties. Many of them have been touched on in our previous discussion but I'll list some here just to emphasize the problem we face:

a) Inconsistent naming within a vendor's documentation set - datasheet spells it one way, programmer's manual another, appnotes/porting guide still another, reference schematic spells it two different ways (pin name on part versus net name of signal wire).

b) Sometimes the name is abbreviated and sometimes spelled out. SMBALRT vs. SMbus Alert.

c) Different tools (CAD programs, word processors) have different conventions leading to existence of ambiguously-representable name components - particular cases in point are overbars for active low signals and embedded spaces/underscores/hyphens in names.

d) Compatible part from different vendors leads to confusion about which vendor's names are canonical. Or leading vendor goes out of business or gets bought.

These problems are getting worse rapidly as more devices are being sourced from Asia, where the linguistic connection to the Roman alphabet is tenuous.

You need a Pope to decide what is canonical.

#10 lore raw
In reply to a message not in the archive
Quoted 10 lines

I agree in general. It has long been a convention of mine to follow the vendor's names as exactly as possible. But that often presents difficulties. Many of them have been touched on in our previous discussion but I'll list some here just to emphasize the problem we face:

a) Inconsistent naming within a vendor's documentation set - datasheet spells it one way, programmer's manual another, appnotes/porting guide still another, reference schematic spells it two different ways (pin name on part versus net name of signal wire).

Right. I should emphasis that what the device-tree should contain is the pin name on part and -not- the net name of the wire. Of course, bogus datasheet and inconsistent spelling will still hurt, nothing much we can do about it, other than having the first to write a driver become a de-facto "guide" to other implementors :-)

Maybe we could have a Wiki where the first time a given chip is used for a binding, we put down the names used to encourage people to use the same. To some extent it's going to be the responsibility of the person writing the .dts to pick up names that will work with existing drivers.

In fact that problem is no different than picking up "compatible" names, and that Wiki thing might help in both cases.

Quoted 2 lines

b) Sometimes the name is abbreviated and sometimes spelled out. SMBALRT vs. SMbus Alert.

Right. Still better than a magic number where you simply have no reference whatsoever to what it is.

Quoted 4 lines

c) Different tools (CAD programs, word processors) have different conventions leading to existence of ambiguously-representable name components - particular cases in point are overbars for active low signals and embedded spaces/underscores/hyphens in names.

Yes, that can be an issue, though overbar is less common for clocks.

Quoted 3 lines

d) Compatible part from different vendors leads to confusion about which vendor's names are canonical. Or leading vendor goes out of business or gets bought.

Sure, same problem with "compatible" properties. There's no silver bullet here. But we could try the Wiki approach to provide an unofficial "reference" of canonical names for common devices. For -very- common ones such as 8250-compatible UARTs, a full blown binding is probably the way to go.

Quoted 3 lines

These problems are getting worse rapidly as more devices are being sourced from Asia, where the linguistic connection to the Roman alphabet is tenuous.

True.

Quoted 1 line

You need a Pope to decide what is canonical.

Perhaps. But we can try our best with something like a wiki in the meantime and see how it works out.

Cheers,
Ben.

Quoted 4 lines

_______________________________________________
Linuxppc-dev mailing list Linuxppc-dev-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#11 lore raw

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

#13 lore raw
In reply to a message not in the archive
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

Cheers,
Ben.

#14 lore raw
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

There are a bunch on kernel.org, not sure what the story is with setting one up / maintenance etc.

cheers

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#15 lore raw
In reply to Benjamin Herrenschmidt
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

This is about the 3rd or 4th time this idea has come up over the past couple of years. Maybe this time it will stick?

Btw, you probably want some kind of contributor agreement so that whatever is posted under the wiki is freely usable by others.

josh

#17 lore raw
In reply to a message not in the archive
Quoted 7 lines · Josh Boyer
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Quoted 7 lines
Quoted 4 lines

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

This is about the 3rd or 4th time this idea has come up over the past couple of years. Maybe this time it will stick?

There actually was one set up on power.org, for epapr bindings. I'm still digging around to try to relocate the address, though.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#20 lore raw
In reply to Benjamin Herrenschmidt
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

There was an ePAPR wiki on power.org, that I had started developing, but it seems to have disappeared. I'm looking into what happened.

Stuart

#21 lore raw
Quoted 8 lines · Stuart Yoder
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Quoted 7 lines
Quoted 4 lines

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

There was an ePAPR wiki on power.org, that I had started developing, but it seems to have disappeared.  I'm looking into what happened.

Lets *not* do it on power.org. I'd like to see the bindings used by more than just powerpc people, and power.org might become a bit of a mental barrier for non-powerpc folks. kernel.org would be a good host. So would ozlabs or infradead. Or I'd be happy to maintain one on secretlab.

What about openfirmware.info? I don't know anything about Core Systems who maintains that site though.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#32 lore raw
In reply to Benjamin Herrenschmidt
Quoted 4 lines · Benjamin Herrenschmidt

However, it's a bit nasty to mix strings and numbers (phandles) in a single property. It's possible, but would likely lead to the phandle not being aligned and tools such as lsprop to fail miserably to display those properties in any kind of readable form.

[...]

Quoted 2 lines

However, I really dislike that numerical clock ID. Magic numbers suck. It should be a string.

Agreed.

Quoted 11 lines

Hence my idea below. It's not perfect but it's the less sucky i've come up with so far. And then we can do some small refinements.

       * Device has:

               - "clock-input-names" as above
               - "clock-map" contains list of phandle,index

       * Clock source has:

               - "clock-output-names" list of strings

The big problem as you say is the referencing of both phandles and strings in the same property, but it's not particularly pretty to disperse the data across multiple properties. Changes to the two properties must be kept in sync, and if order changes in one and not the other then badness occurs... Actually, I don't *dislike* you're proposed binding, but in the interest of generating and endless goodness argument, what about the following?

As above, clock source has:
- "clock-output-names" list of strings. All possible inputs
must be in this list in the interest of clarity and sanity checking, but drivers must not depend on the order of the list. Drivers must always resolve clocks by name.

Clock consumer has:
- "clock-inputs" property. Array of string 'tuples' in the
form: "input-name","clock-source-path","output-name".

This sidesteps the phandle issue by using the path string instead. It's not as efficient space wise, but (at least when using dtc) the syntax stays pretty sane, and the output remains mere-mortal parsable:
ie: clock-inputs = "sysclk", &clocksource, "clkout_orange";

Quoted 11 lines

The "index" in the clock map thus would reference the "clock-output-names" array in the clock provider. That means that the "magic number" here is entirely local to a given device-tree, doesn't leak into driver code, which continues using names.

In addition, we can even have some smooth "upgrade" path from existing "clock-frequency" properties by assuming that if "clock-output-names" is absent, but "clock-frequency" exist, then index 0 references a fixed frequency clock source without a driver. This could be generally handy anyway to represent crystals of fixed bus clocks without having to write a clock source driver for them.

The analog of this could be:

clock-inputs = "sysclk", &clocksource, "0";

Otherwise, I think the approach is sound and I agree fully that referencing names makes sense.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#23 lore raw
In reply to a message not in the archive
Quoted 5 lines

Lets *not* do it on power.org.  I'd like to see the bindings used by more than just powerpc people, and power.org might become a bit of a mental barrier for non-powerpc folks.  kernel.org would be a good host.  So would ozlabs or infradead.  Or I'd be happy to maintain one on secretlab.

I think broadening it beyond power.org is good. Along those lines I'd prefer not having this on kernel.org, as device trees are not Linux-centric. There are other OS vendors I've interacted with that I'd like to see use device trees and separating it from Linux may be better IMO.

We could also create a new domain like "devicetree.org" (?)..but it still would nee a host.

Stuart

#28 lore raw
In reply to a message not in the archive
Quoted 4 lines

What about openfirmware.info? I don't know anything about Core Systems who maintains that site though.

Stefan Reinauer is the main guy there. He has been very helpful in hosting the Open Firmware source tree. I expect that he would be willing to host the wiki, since he has been interested in Open Firmware for many years.

#24 lore raw
In reply to Stuart Yoder

In message: <[email protected]>
Stuart Yoder <[email protected]> writes:
: > Lets *not* do it on power.org.  I'd like to see the bindings used by : > more than just powerpc people, and power.org might become a bit of a : > mental barrier for non-powerpc folks.  kernel.org would be a good : > host.  So would ozlabs or infradead.  Or I'd be happy to maintain one : > on secretlab.
:
: I think broadening it beyond power.org is good. Along those lines I'd prefer : not having this on kernel.org, as device trees are not Linux-centric. There : are other OS vendors I've interacted with that I'd like to see use device trees : and separating it from Linux may be better IMO.

I know of at least one other free OS that will be migrating to device trees for enumeration of devices in the embedded space...

Warner

#29 lore raw
In reply to Grant Likely
Quoted 17 lines · Grant Likely
Quoted 8 lines · Stuart Yoder
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 2 lines · Mitch Bradley

The idea of a wiki as a registration authority is a good one, but I'm not volunteering to maintain it :-)

here goes my hope :-)

Quoted 7 lines
Quoted 4 lines

Do we have wiki's we could use on power.org or should we aim for a community place ? Anybody has suggestions ? I wouldn't even try to maintain a web site myself, that would be irresponsible of anybody to let me do so !

There was an ePAPR wiki on power.org, that I had started developing, but it seems to have disappeared. I'm looking into what happened.

Quoted 8 lines

Lets *not* do it on power.org. I'd like to see the bindings used by more than just powerpc people, and power.org might become a bit of a mental barrier for non-powerpc folks. kernel.org would be a good host. So would ozlabs or infradead. Or I'd be happy to maintain one on secretlab.

What about openfirmware.info? I don't know anything about Core Systems who maintains that site though.

Grant,
When choosing the best location for the bindings page please consider it uniform enough so that various OSes can use it as a reference. We are very much interested in bringing FDT support for embedded FreeBSD (arm, powerpc), and one of the uncertainties is how to deal with existing Linux bindings definitions: at the moment they are maintained as part of kernel source tree, and there are doubts whether we should come up with our own set (most likely *very* similar), which we'd like to avoid.

Rafal

#26 lore raw
In reply to a message not in the archive
Quoted 6 lines · Stuart Yoder
Quoted 5 lines

Lets *not* do it on power.org.  I'd like to see the bindings used by more than just powerpc people, and power.org might become a bit of a mental barrier for non-powerpc folks.  kernel.org would be a good host.  So would ozlabs or infradead.  Or I'd be happy to maintain one on secretlab.

Quoted 7 lines

I think broadening it beyond power.org is good.  Along those lines I'd prefer not having this on kernel.org, as device trees are not Linux-centric.  There are other OS vendors I've interacted with that I'd like to see use device trees and separating it from Linux may be better IMO.

We could also create a new domain like "devicetree.org" (?)..but it still would nee a host.

How about right here: http://fdt.secretlab.ca/

I've only just created the site. I'll fill in some documentation and structure in the next few days. Feel free to create an account and start adding stuff.

We'll need to talk about how best to manage bindings and have some form of review/agreement before a binding is marked as "stable". And the site URL could change as well. But in the meantime we've got a sandbox to start playing in.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#19 lore raw
In reply to a message not in the archive
Quoted 6 lines
Quoted 3 lines

This is about the 3rd or 4th time this idea has come up over the past couple of years. Maybe this time it will stick?

There actually was one set up on power.org, for epapr bindings. I'm still digging around to try to relocate the address, though.

We need to double check that indeed the content is freely licenced, especially if, in the future, for some reasons, power.org goes down, that we are legally allowed to take that content and put it elsewhere.

Cheers,
Ben.

#31 lore raw
In reply to a message not in the archive
Quoted 9 lines · Rafal Jaworowski

Grant,
When choosing the best location for the bindings page please consider it uniform enough so that various OSes can use it as a reference. We are very much interested in bringing FDT support for embedded FreeBSD (arm, powerpc), and one of the uncertainties is how to deal with existing Linux bindings definitions: at the moment they are maintained as part of kernel source tree, and there are doubts whether we should come up with our own set (most likely *very* similar), which we'd like to avoid.

I agree. We need to be OS neutral.

In fact, one of the main issue right now with the core binding is the phandles, which are put into "linux,phandle" properties. That must change and we need to make the kernel aware of the change.

We will still keep linux-specific properties around, I suppose, mostly for linux-specific things exchanged between the boot wrapper and the kernel, but the base tree should generally be devoid of a "linux," property.

Cheers,
Ben.

#27 lore raw
In reply to Grant Likely
Quoted 10 lines

How about right here:  http://fdt.secretlab.ca/

I've only just created the site.  I'll fill in some documentation and structure in the next few days.  Feel free to create an account and start adding stuff.

We'll need to talk about how best to manage bindings and have some form of review/agreement before a binding is marked as "stable".  And the site URL could change as well.  But in the meantime we've got a sandbox to start playing in.

Unless there are better suggestions, your site is fine with me.

One other thing-- we need to clarify how the content of the wiki is licensed.

I assume (and hope) that the intent is for the content to be freely usable in the most flexible way. But, this has to be explicit.

An issue we ran into with the ePAPR was that on the IEEE 1275 working group site (http://playground.sun.com/1275/home.html)
that there were bindings that we wanted to include in the ePAPR, but the stuff on 1275 site was not copyrighted and no license
was specified. This meant that we were in a legally murky
situation if we cut and pasted anything from one of those document.

My suggestion is to specify that all content of this wiki are released to the public domain. How to do this is a bit tricky but Creative Commons has a license called CC0 that does this by waving your copyright rights.

Your wiki currently has the following statement above the commit message:

Please note that all contributions to FDTWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see FDTWiki:Copyrights for details). Do not submit copyrighted work without permission!

I would suggest appending the following statement to the above text:

You irrevocably agree to release your contribution to the public domain. To the extent possible under law, you waive all copyright or neighboring rights to your contribution. See [CC0|link-to-CC0].

The above language comes from generated text of the CC0 tool from Creative Commons.

Stuart