DTS question - MPC5200b
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
Quoted 14 lines · Nick
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>; };
Quoted 6 lines
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.
Quoted 1 line
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.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 1 line · 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
Quoted 16 lines · Jarno Manninen
Quoted 1 line · 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_uartmight 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); }
Quoted 1 line
--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.
Quoted 3 lines
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.
Quoted 10 lines
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.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
Quoted 4 lines · Nick
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..
Quoted 2 lines
gpt@670 { // General Purpose Timer
device_type= "gpt";
device_type shouldn't be here.
Quoted 2 lines
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.
Quoted 7 lines
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.
Quoted 5 lines
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.
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