devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* dt confusion, for_each_matching_node...
@ 2011-07-26 20:15 Niklas Hernaeus
       [not found] ` <CA+03iojnhNU7ksPR=GBYgHo10juXXOTWcnxYH0F9h3kTtHSZzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Niklas Hernaeus @ 2011-07-26 20:15 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ


[-- Attachment #1.1: Type: text/plain, Size: 2360 bytes --]

Hi Grant.

I am afraid I am seriously confused about how the dt is supposed to work.
Maybe I simply lack a detail, if I am lucky... perhaps it is to late in the
day...

Problem:
I cannot get the for_each_matching_node macro to give me anything, so the I
guess the of_find_matching_node cannot find anything.
I am using the uarts in the test code. With the test code below the snowball
dies.
Anyone see my mistake?

Thanks for any and all input.
/Niklas.

Suggestion: I forgot some initialization somewhere?

In this device tree I have:

/ {
        model = "ST-Ericsson Snowball";
        compatible = "snowball";
        #address-cells = <1>;
        #size-cells = <1>;

        #chosen {
                bootargs = "root=/dev/ram0 console=ttyAMA2,115200n8 debug
earlyprintk";
        };

        #memory {
                reg = <0x90000000 0x20000000>;
        };

        #soc-u8500 {
                address-cells = <1>;
                size-cells = <1>;
                compatible = "simple-bus";
                periph1-base = <0x32000>;

                cpus {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        cpu@0 {
                                compatible = "arm,cortex-a9";
                                reg = <0>;
                        };
                        cpu@1 {
                                compatible = "arm,cortex-a9";
                                reg = <1>;
                        };
                };
        };

        uart@80120000 {
                compatible = "arm,pl011";
        };
        uart@80121000 {
                compatible = "arm,pl011";
        };
        uart@80007000 {
                compatible = "arm,pl011";
        };
  };


Test code:

static const struct of_device_id snowball_uarts[] __initconst={
        {.compatible="arm,pl011"},
        {},
};

static void __init mop500_uart_init_dt(void)
{
        struct device_node *node;
        u32 p0;
        int ret;

        /* Get device info from device-tree */
        for_each_matching_node(node, snowball_uarts) {
                goto doit;  /* Got something, all ok */
        }
        goto die;

 doit:
        /* Standard init, no dt */
        db8500_add_uart0(&uart0_plat);
        db8500_add_uart1(&uart1_plat);
        db8500_add_uart2(&uart2_plat);
die:
        ;
};

[-- Attachment #1.2: Type: text/html, Size: 2846 bytes --]

[-- Attachment #2: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dt confusion, for_each_matching_node...
       [not found] ` <CA+03iojnhNU7ksPR=GBYgHo10juXXOTWcnxYH0F9h3kTtHSZzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-07-28 22:27   ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2011-07-28 22:27 UTC (permalink / raw)
  To: Niklas Hernaeus; +Cc: Grant Likely, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On Tue, Jul 26, 2011 at 10:15:56PM +0200, Niklas Hernaeus wrote:
> Hi Grant.
> 
> I am afraid I am seriously confused about how the dt is supposed to work.
> Maybe I simply lack a detail, if I am lucky... perhaps it is to late in the
> day...
> 
> Problem:
> I cannot get the for_each_matching_node macro to give me anything, so the I
> guess the of_find_matching_node cannot find anything.
> I am using the uarts in the test code. With the test code below the snowball
> dies.
> Anyone see my mistake?
> 
> Thanks for any and all input.
> /Niklas.

The code looks fine, but as discussed on IRC, it looks like the dtb
isn't getting handed to the kernel in the first place, which would be
the root cause.  :-)

g.

> 
> Suggestion: I forgot some initialization somewhere?
> 
> In this device tree I have:
> 
> / {
>         model = "ST-Ericsson Snowball";
>         compatible = "snowball";
>         #address-cells = <1>;
>         #size-cells = <1>;
> 
>         #chosen {
>                 bootargs = "root=/dev/ram0 console=ttyAMA2,115200n8 debug
> earlyprintk";
>         };
> 
>         #memory {
>                 reg = <0x90000000 0x20000000>;
>         };
> 
>         #soc-u8500 {
>                 address-cells = <1>;
>                 size-cells = <1>;
>                 compatible = "simple-bus";
>                 periph1-base = <0x32000>;
> 
>                 cpus {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                         cpu@0 {
>                                 compatible = "arm,cortex-a9";
>                                 reg = <0>;
>                         };
>                         cpu@1 {
>                                 compatible = "arm,cortex-a9";
>                                 reg = <1>;
>                         };
>                 };
>         };
> 
>         uart@80120000 {
>                 compatible = "arm,pl011";
>         };
>         uart@80121000 {
>                 compatible = "arm,pl011";
>         };
>         uart@80007000 {
>                 compatible = "arm,pl011";
>         };
>   };
> 
> 
> Test code:
> 
> static const struct of_device_id snowball_uarts[] __initconst={
>         {.compatible="arm,pl011"},
>         {},
> };
> 
> static void __init mop500_uart_init_dt(void)
> {
>         struct device_node *node;
>         u32 p0;
>         int ret;
> 
>         /* Get device info from device-tree */
>         for_each_matching_node(node, snowball_uarts) {
>                 goto doit;  /* Got something, all ok */
>         }
>         goto die;
> 
>  doit:
>         /* Standard init, no dt */
>         db8500_add_uart0(&uart0_plat);
>         db8500_add_uart1(&uart1_plat);
>         db8500_add_uart2(&uart2_plat);
> die:
>         ;
> };

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-28 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26 20:15 dt confusion, for_each_matching_node Niklas Hernaeus
     [not found] ` <CA+03iojnhNU7ksPR=GBYgHo10juXXOTWcnxYH0F9h3kTtHSZzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-07-28 22:27   ` Grant Likely

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).