* Device Tree Child Node Parsing Question
@ 2014-12-23 16:34 Thor Thayer
[not found] ` <549999A7.2010608-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Thor Thayer @ 2014-12-23 16:34 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Hi,
What is the best way to queue devicetree child nodes so the node is
passed in the platform_device pointer to the probe() function?
Documentation/devicetree/usage-model.txt has the following:
"For Linux DT support, the generic behaviour is for child devices to be
registered by the parent's device driver at driver .probe() time."
"Actually, it turns out that registering children of some
platform_devices as more platform_devices is a common pattern, and the
device tree support code reflects that and makes the above example
simpler. The second argument to of_platform_populate() is an
of_device_id table, and any node that matches an entry in that table
will also get its child nodes registered."
I tried calling of_platform_populate() in the probe of the a10_sysctl
node but it doesn't appear to setup the platform device data properly
for the sub-child nodes.
The top child node (a10_sysctl) is probed properly and has a valid
of_node passed in. However, the sub-child nodes such as gpio4 have null
passed in for pdev->dev.of_node (gpio4 probe prototype is int
a10sycon_gpio_probe(struct platform_device *pdev).
My current solution is to call of_find_matching_node() in
a10sycon_gpio_probe() to get a valid node pointer but other examples
tend to dereference pdev->dev.of_node.
Thank you in advance for your insight.
Thor
My device tree looks like this:
/ {
soc {
spi0: spi@fff00000 {
compatible = "snps,dw-spi-mmio";
#address-cells = <1>;
#size-cells = <0>;
reg = <0xfff00000 0x1000>;
interrupts = <0 154 4>;
num-chipselect = <4>;
clocks = <&per_base_clk>;
status = "okay";
a10_sysctl: a10_sysctl@0 {
compatible = "altr,a10sycon";
reg = <0>;
interrupt-parent = <&gpio2>;
/* low-level active IRQ at GPIO2_24 */
interrupts = <24 0x8>;
interrupt-controller;
#interrupt-cells = <2>;
spi-max-frequency = <100000>;
gpio4: gpio-controller {
compatible = "altr,a10sycon-gpio";
gpio-controller;
#gpio-cells = <2>;
ngpios = <16>;
};
a10rst: a10rst {
compatible = "altr,a10sycon-reset";
#reset-cells = <1>;
};
};
};
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Device Tree Child Node Parsing Question
[not found] ` <549999A7.2010608-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
@ 2014-12-26 19:40 ` Rob Herring
[not found] ` <CAL_JsqLzbEuQgNZoBbzr4R=Nj9_Qs=60uLhzENbZzTaaTgxnZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-27 4:15 ` He YunLei
1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2014-12-26 19:40 UTC (permalink / raw)
To: Thor Thayer
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
On Tue, Dec 23, 2014 at 10:34 AM, Thor Thayer
<tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org> wrote:
> Hi,
>
> What is the best way to queue devicetree child nodes so the node is passed
> in the platform_device pointer to the probe() function?
>
> Documentation/devicetree/usage-model.txt has the following:
>
> "For Linux DT support, the generic behaviour is for child devices to be
> registered by the parent's device driver at driver .probe() time."
>
> "Actually, it turns out that registering children of some platform_devices
> as more platform_devices is a common pattern, and the
> device tree support code reflects that and makes the above example
> simpler. The second argument to of_platform_populate() is an
> of_device_id table, and any node that matches an entry in that table
> will also get its child nodes registered."
>
>
> I tried calling of_platform_populate() in the probe of the a10_sysctl node
> but it doesn't appear to setup the platform device data properly for the
> sub-child nodes.
>
> The top child node (a10_sysctl) is probed properly and has a valid of_node
> passed in. However, the sub-child nodes such as gpio4 have null passed in
> for pdev->dev.of_node (gpio4 probe prototype is int
> a10sycon_gpio_probe(struct platform_device *pdev).
>
> My current solution is to call of_find_matching_node() in
> a10sycon_gpio_probe() to get a valid node pointer but other examples tend to
> dereference pdev->dev.of_node.
>
> Thank you in advance for your insight.
This should work. There are quite a few users already including unit
tests. Can you tell what you are doing differently from those users?
Rob
>
> Thor
>
>
> My device tree looks like this:
>
> / {
> soc {
> spi0: spi@fff00000 {
> compatible = "snps,dw-spi-mmio";
> #address-cells = <1>;
> #size-cells = <0>;
> reg = <0xfff00000 0x1000>;
> interrupts = <0 154 4>;
> num-chipselect = <4>;
> clocks = <&per_base_clk>;
> status = "okay";
>
> a10_sysctl: a10_sysctl@0 {
> compatible = "altr,a10sycon";
> reg = <0>;
> interrupt-parent = <&gpio2>;
> /* low-level active IRQ at GPIO2_24 */
> interrupts = <24 0x8>;
> interrupt-controller;
> #interrupt-cells = <2>;
> spi-max-frequency = <100000>;
>
> gpio4: gpio-controller {
> compatible = "altr,a10sycon-gpio";
> gpio-controller;
> #gpio-cells = <2>;
> ngpios = <16>;
> };
>
> a10rst: a10rst {
> compatible = "altr,a10sycon-reset";
> #reset-cells = <1>;
> };
> };
> };
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Device Tree Child Node Parsing Question
[not found] ` <549999A7.2010608-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
2014-12-26 19:40 ` Rob Herring
@ 2014-12-27 4:15 ` He YunLei
1 sibling, 0 replies; 4+ messages in thread
From: He YunLei @ 2014-12-27 4:15 UTC (permalink / raw)
To: Thor Thayer
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
On 2014/12/24 0:34, Thor Thayer wrote:
> Hi,
>
> What is the best way to queue devicetree child nodes so the node is passed in the platform_device pointer to the probe() function?
>
> Documentation/devicetree/usage-model.txt has the following:
>
> "For Linux DT support, the generic behaviour is for child devices to be registered by the parent's device driver at driver .probe() time."
>
> "Actually, it turns out that registering children of some platform_devices as more platform_devices is a common pattern, and the
> device tree support code reflects that and makes the above example
> simpler. The second argument to of_platform_populate() is an
> of_device_id table, and any node that matches an entry in that table
> will also get its child nodes registered."
>
>
> I tried calling of_platform_populate() in the probe of the a10_sysctl node but it doesn't appear to setup the platform device data properly for the sub-child nodes.
>
> The top child node (a10_sysctl) is probed properly and has a valid of_node passed in. However, the sub-child nodes such as gpio4 have null passed in for pdev->dev.of_node (gpio4 probe prototype is int a10sycon_gpio_probe(struct platform_device *pdev).
Gpio4 is the child node of a10_sysctl? You call of_platform_populate() in the probe of the a10_sysctl node,
this action does no matter with gpio4.
Yours,
Yunlei
>
> My current solution is to call of_find_matching_node() in a10sycon_gpio_probe() to get a valid node pointer but other examples tend to dereference pdev->dev.of_node.
>
> Thank you in advance for your insight.
>
> Thor
>
>
> My device tree looks like this:
>
> / {
> soc {
> spi0: spi@fff00000 {
> compatible = "snps,dw-spi-mmio";
> #address-cells = <1>;
> #size-cells = <0>;
> reg = <0xfff00000 0x1000>;
> interrupts = <0 154 4>;
> num-chipselect = <4>;
> clocks = <&per_base_clk>;
> status = "okay";
>
> a10_sysctl: a10_sysctl@0 {
> compatible = "altr,a10sycon";
> reg = <0>;
> interrupt-parent = <&gpio2>;
> /* low-level active IRQ at GPIO2_24 */
> interrupts = <24 0x8>;
> interrupt-controller;
> #interrupt-cells = <2>;
> spi-max-frequency = <100000>;
>
> gpio4: gpio-controller {
> compatible = "altr,a10sycon-gpio";
> gpio-controller;
> #gpio-cells = <2>;
> ngpios = <16>;
> };
>
> a10rst: a10rst {
> compatible = "altr,a10sycon-reset";
> #reset-cells = <1>;
> };
> };
> };
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Device Tree Child Node Parsing Question
[not found] ` <CAL_JsqLzbEuQgNZoBbzr4R=Nj9_Qs=60uLhzENbZzTaaTgxnZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-01-05 14:48 ` Thor Thayer
0 siblings, 0 replies; 4+ messages in thread
From: Thor Thayer @ 2015-01-05 14:48 UTC (permalink / raw)
To: Rob Herring
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
On 12/26/2014 01:40 PM, Rob Herring wrote:
> On Tue, Dec 23, 2014 at 10:34 AM, Thor Thayer
> <tthayer-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org> wrote:
>> Hi,
>>
>> What is the best way to queue devicetree child nodes so the node is passed
>> in the platform_device pointer to the probe() function?
>>
>> Documentation/devicetree/usage-model.txt has the following:
>>
>> "For Linux DT support, the generic behaviour is for child devices to be
>> registered by the parent's device driver at driver .probe() time."
>>
>> "Actually, it turns out that registering children of some platform_devices
>> as more platform_devices is a common pattern, and the
>> device tree support code reflects that and makes the above example
>> simpler. The second argument to of_platform_populate() is an
>> of_device_id table, and any node that matches an entry in that table
>> will also get its child nodes registered."
>>
>>
>> I tried calling of_platform_populate() in the probe of the a10_sysctl node
>> but it doesn't appear to setup the platform device data properly for the
>> sub-child nodes.
>>
<snip>
>
> This should work. There are quite a few users already including unit
> tests. Can you tell what you are doing differently from those users?
>
> Rob
>
>>
<snip>
Just to tie up this conversation in case anyone else has an issue, it
ended up being my debug issue. The of_platform_populate() was working
properly. The issue was that I was also calling a mfd_add_devices()
using a devices table and I was watching the mfd_add_devices() probe.
Simply removing the mfd_add_devices() and the table and using
of_platform_populate() as below worked.
of_platform_populate(spi->dev.of_node, a10sycon_spi_of_match,
NULL, &spi->dev);
Thanks!
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-05 14:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-23 16:34 Device Tree Child Node Parsing Question Thor Thayer
[not found] ` <549999A7.2010608-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
2014-12-26 19:40 ` Rob Herring
[not found] ` <CAL_JsqLzbEuQgNZoBbzr4R=Nj9_Qs=60uLhzENbZzTaaTgxnZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-05 14:48 ` Thor Thayer
2014-12-27 4:15 ` He YunLei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).