fsl_spi_init: Support non-QE processors
PATCH 1/1 fsl_spi_init: Support non-QE processors
On non-QE processors (mpc831x/mpc834x) the SPI clock is the SoC clock.
--- arch/powerpc/sysdev/fsl_soc.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +19 -8
@@ -1220,14 +1220,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, {struct device_node *np;unsigned int i; -const u32 *sysclk; +const u32 *qe_sysclk =0 , *soc_sysclk =0 ; np =of_find_node_by_type (NULL ,"qe" ); -if (!np) -return -ENODEV ; +if (np) + qe_sysclk =of_get_property (np,"bus-frequency" ,NULL ); + + np =of_find_node_by_type (NULL ,"soc" ); +if (np) + soc_sysclk =of_get_property (np,"bus-frequency" ,NULL ); - sysclk =of_get_property (np,"bus-frequency" ,NULL ); -if (!sysclk) +if (!(qe_sysclk || soc_sysclk))return -ENODEV ; for (np = NULL, i = 1;
@@ -1245,16 +1248,24 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,memset (res,0 ,sizeof (res)); - pdata.sysclk = *sysclk; - prop =of_get_property (np,"reg" ,NULL );if (!prop) goto err; pdata.bus_num = *(u32 *)prop; prop =of_get_property (np,"mode" ,NULL ); -if (prop && !strcmp (prop,"qe" )) +if (prop && !strcmp (prop,"qe" )) { pdata.qe_mode =1 ; +if (qe_sysclk) + pdata.sysclk = *qe_sysclk; +else + goto err; + }else { +if (soc_sysclk) + pdata.sysclk = *soc_sysclk; +else + goto err; + }for (j =0 ; j < num_board_infos; j++) {if (board_infos[j].bus_num == pdata.bus_num)
Signature · 5 lines
1.5.3.2 -- Bye, Peter Korsgaard
Quoted 17 lines · Peter Korsgaard
On non-QE processors (mpc831x/mpc834x) the SPI clock is the SoC clock.
Signed-off-by Peter Korsgaard <[email protected]>--- arch/powerpc/sysdev/fsl_soc.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-)arch/powerpc/sysdev/fsl_soc.c +1
-1@@ -1220,14 +1220,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, {struct device_node *np;unsigned int i; -const u32 *sysclk; +const u32 *qe_sysclk =0 , *soc_sysclk =0 ;
arch/powerpc/sysdev/fsl_soc.c int __init fsl_spi_init(struct spi_board_info *board_infos, · line 1231
Quoted 10 lines
arch/powerpc/sysdev/fsl_soc.c +6
-2np =of_find_node_by_type (NULL ,"qe" ); -if (!np) -return -ENODEV ; +if (np) + qe_sysclk =of_get_property (np,"bus-frequency" ,NULL ); + + np =of_find_node_by_type (NULL ,"soc" ); +if (np) + soc_sysclk =of_get_property (np,"bus-frequency" ,NULL );
Why not just:
np = of_find_node_by_type(NULL, "qe");
+ if (!np)
+ np = of_find_node_by_type(NULL, "soc");
if (!np)
return -ENODEV;The other changes aren't needed that way.
g.
Signature · 4 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. [email protected] (403) 399-0195
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Grant" == Grant Likely <[email protected]> writes:
Hi,
Grant> Why not just:
Grant> np = of_find_node_by_type(NULL, "qe");
Grant> + if (!np)
Grant> + np = of_find_node_by_type(NULL, "soc");
Grant> if (!np)
Grant> return -ENODEV;
My first iteration did it like that, but then you don't get a -ENODEV if the node is missing (and you'll end up using the wrong clock) and it doesn't support processors with SPI on and off QE (if that exists/will ever exist).
Signature · 1 line
Bye, Peter Korsgaard
Quoted 12 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Grant" == Grant Likely <[email protected]> writes:
Hi,
Grant> Why not just:
Grant> np =
of_find_node_by_type(NULL, "qe");
Grant> + if (!np)
Grant> + np =of_find_node_by_type(NULL, "soc");
Grant> if (!np)
Grant> return-ENODEV;
Quoted 4 lines
My first iteration did it like that, but then you don't get a
-ENODEVif the node is missing (and you'll end up using the wrong clock) and it doesn't support processors with SPI on and off QE (if that exists/will ever exist).
Okay, but you should at least be able confine your determination of which sysclk value to use to one part of the function. Otherwise, it looks good.
Cheers,
g.
Signature · 4 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. [email protected] (403) 399-0195
Quoted 13 lines · Grant Likely
Quoted 12 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Grant" == Grant Likely <[email protected]> writes:
Hi,
Grant> Why not just:
Grant> np =
of_find_node_by_type(NULL, "qe");
Grant> + if (!np)
Grant> + np =of_find_node_by_type(NULL, "soc");
Grant> if (!np)
Grant> return-ENODEV;
Quoted 8 lines
Quoted 4 lines
My first iteration did it like that, but then you don't get a
-ENODEVif the node is missing (and you'll end up using the wrong clock) and it doesn't support processors with SPI on and off QE (if that exists/will ever exist).Okay, but you should at least be able confine your determination of which sysclk value to use to one part of the function. Otherwise, it looks good.
Peter, can you respin this w/Grant's modification. I've grabbed the other patches and applied them. waiting on this one.
- k
arch/powerpc/sysdev/fsl_soc.c int __init fsl_spi_init(struct spi_board_info *board_infos, · line 1223
Quoted 7 lines · On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard <[email protected]> wrote:
arch/powerpc/sysdev/fsl_soc.c +1
-1@@ -1220,14 +1220,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, {struct device_node *np;unsigned int i; -const u32 *sysclk; +const u32 *qe_sysclk =0 , *soc_sysclk =0 ;
Please use NULL when referring to pointers.
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Quoted 11 lines · Stephen Rothwell
arch/powerpc/sysdev/fsl_soc.c int __init fsl_spi_init(struct · line 1224
Quoted 8 lines · On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard <[email protected]> wrote:
arch/powerpc/sysdev/fsl_soc.c +1
-1@@ -1220,14 +1220,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, {struct device_node *np;unsigned int i; -const u32 *sysclk; +const u32 *qe_sysclk =0 , *soc_sysclk =0 ;Please use NULL when referring to pointers.
Peter, any chance of getting a respin. I'd like this to go into 2.6.24.
- k
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kumar" == Kumar Gala <[email protected]> writes:
Quoted 12 lines · Stephen Rothwell
Quoted 12 lines
Review int __init fsl_spi_init(struct · line 1224
Quoted 8 lines · On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard <[email protected]> wrote:
(quoted diff) +1
-1@@ -1220,14 +1220,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, { struct device_node *np; unsigned int i; - const u32 *sysclk; + const u32 *qe_sysclk = 0, *soc_sysclk = 0;Please use NULL when referring to pointers.
Kumar> Peter, any chance of getting a respin. I'd like this to go Kumar> into 2.6.24.
Certainly. Sorry for the delay, I have been offline for 2 days building my house ..
---fsl_spi_init: Support non-QE processors
On non-QE processors (mpc831x/mpc834x) the SPI clock is the SoC clock.
--- arch/powerpc/sysdev/fsl_soc.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +4 -0
@@ -1222,8 +1222,12 @@ int __init fsl_spi_init(struct spi_board_info *board_infos,unsigned int i;const u32 *sysclk; +/* SPI controller is either clocked from QE or SoC clock */ np =of_find_node_by_type (NULL ,"qe" );if (!np) + np =of_find_node_by_type (NULL ,"soc" ); + +if (!np)return -ENODEV ; sysclk =of_get_property (np,"bus-frequency" ,NULL );
Signature · 4 lines
1.5.3.2 -- Bye, Peter Korsgaard
Kumar Gala
AppliedQuoted 17 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kumar" == Kumar Gala <[email protected]> writes:
Quoted 12 lines · Stephen Rothwell
Quoted 12 lines
Review int __init fsl_spi_init(struct · line 1224
Quoted 8 lines · On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard <[email protected]> wrote:
(quoted diff) +1
-1@@ -1220,14 +1220,17 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, { struct device_node *np; unsigned int i; - const u32 *sysclk; + const u32 *qe_sysclk = 0, *soc_sysclk = 0;Please use NULL when referring to pointers.
Quoted 5 lines
Kumar> Peter, any chance of getting a respin. I'd like this to go Kumar> into 2.6.24.
Certainly. Sorry for the delay, I have been offline for 2 days building my house ..
applied.
No problem, sounds like fun.
If you get a chance can you test my for-2.6.24 board to make SPI is functional as you expect.
thanks
- k