DTS question - MPC5200b

5 messages, 4 authors, 2008-02-12 · open the first message on its own page

DTS question - MPC5200b

From: Nick <hidden>
Date: 2008-02-12 17:43:46

Hi,

I need some help.  I am trying to access timer 7 on the MPC5200B 
processor.  I have the DTS file setup like this

        gpt@670 {    // General Purpose Timer
          device_type = "gpt";
            compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
            cell-index = <7>;
            reg = <670 10>;
            interrupts = <1 10 0>;
            interrupt-parent = <&mpc5200_pic>;
        };

I have timers 0 to 6 defined the same way except the cell-index reflects 
the timer number.

In my platform file where I am doing my board setup, I tried the  following.

timer7 = mpc52xx_find_and_map ("mpc5200b-gpt");

How do I specify the timer based on the cell-index?

Thanks

Nick

Re: DTS question - MPC5200b

From: Grant Likely <hidden>
Date: 2008-02-12 18:28:03

On Feb 12, 2008 10:37 AM, Nick [off-list ref] wrote:
Hi,

I need some help.  I am trying to access timer 7 on the MPC5200B
processor.  I have the DTS file setup like this

        gpt@670 {    // General Purpose Timer
          device_type = "gpt";
            compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
            cell-index = <7>;
            reg = <670 10>;
            interrupts = <1 10 0>;
            interrupt-parent = <&mpc5200_pic>;
        };

I have timers 0 to 6 defined the same way except the cell-index reflects
the timer number.

In my platform file where I am doing my board setup, I tried the  following.

timer7 = mpc52xx_find_and_map ("mpc5200b-gpt");
Don't use find_and_map; it was a stupid API that I never should have written.

Instead, use for_each_compatible_node() or for_each_matching_node() to
iterate over them until you find the one with the correct reg address.

Then you can use of_iomap() to map the device registers.
How do I specify the timer based on the cell-index?
Match on the reg property instead of cell-index; I'll probably be
dropping the cell-index property from future 5200 device trees because
it just ends up duplicating information already provided by reg.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

Re: DTS question - MPC5200b

From: Jarno Manninen <hidden>
Date: 2008-02-12 19:17:31

On Tuesday 12 February 2008 19:37:07 Nick wrote:
How do I specify the timer based on the cell-index?
I don't know if that is possible to do in a one call, but maybe using the 
approach from mpc52xx_uart might help?

--clip--
        for_each_node_by_type(np, "serial") {
                if (!of_match_node(mpc52xx_uart_of_match, np))
                        continue;

                /* Is a particular device number requested? */
                devno = of_get_property(np, "port-number", NULL);
                mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1);
        }
--clip--

And change  serial->gpt, port-number to cell-index and add some logic to 
select the devices you want. Or if you wan't to do it a bit differently you 
could add a pseudo device outside the main tree like

	mydev {
		gpt-dev = <&the_gpt_dev>:
	};

And get it that way. However I don't know if this is recommended approach, but 
I've used it for some simple stuff like binding gpt in PWM mode to 
framebuffer backlight, along with power-pin.

Please correct any mistakes you who know better. 

- Jarno

Re: DTS question - MPC5200b

From: Grant Likely <hidden>
Date: 2008-02-12 19:47:19

On Feb 12, 2008 11:07 AM, Jarno Manninen [off-list ref] wrote:
On Tuesday 12 February 2008 19:37:07 Nick wrote:
quoted
How do I specify the timer based on the cell-index?
I don't know if that is possible to do in a one call, but maybe using the
approach from mpc52xx_uart might help?

--clip--
        for_each_node_by_type(np, "serial") {
                if (!of_match_node(mpc52xx_uart_of_match, np))
                        continue;

                /* Is a particular device number requested? */
                devno = of_get_property(np, "port-number", NULL);
                mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1);
        }
--clip--
This code has actually changed in 2.6.25-rc1.  It is now
for_each_matching_node() and the call to of_match_node is no longer
necessary.
And change  serial->gpt, port-number to cell-index and add some logic to
select the devices you want.
use 'reg' instead.  cell-index (and port-number for that matter) will
probably be going away in the near future.
Or if you wan't to do it a bit differently you
could add a pseudo device outside the main tree like

        mydev {
                gpt-dev = <&the_gpt_dev>:
        };

And get it that way. However I don't know if this is recommended approach, but
I've used it for some simple stuff like binding gpt in PWM mode to
framebuffer backlight, along with power-pin.
Yes, this is a good approach too.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

Re: DTS question - MPC5200b

From: David Gibson <hidden>
Date: 2008-02-12 22:49:06

On Tue, Feb 12, 2008 at 12:37:07PM -0500, Nick wrote:
Hi,

I need some help.  I am trying to access timer 7 on the MPC5200B 
processor.  I have the DTS file setup like this
Others have addressed the most salient points, but some general
corrections for your device tree..
        gpt@670 {    // General Purpose Timer
          device_type = "gpt";
device_type shouldn't be here.
            compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
            cell-index = <7>;
You probably don't want cell-index.  cell-index should *only* be used
when there is some global register somewhere that's indexed by the
cell number.
            reg = <670 10>;
            interrupts = <1 10 0>;
            interrupt-parent = <&mpc5200_pic>;
        };

I have timers 0 to 6 defined the same way except the cell-index reflects 
the timer number.
Presumably 'reg' is different for each, as well.
In my platform file where I am doing my board setup, I tried the  following.

timer7 = mpc52xx_find_and_map ("mpc5200b-gpt");

How do I specify the timer based on the cell-index?
You don't.  As Grant explains, use reg instead.

-- 
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help