[PATCH] fsl_spi_init: Support non-QE processors

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE6910d

9 messages, 4 authors, 2007-10-08 · open the first message on its own page

[PATCH] fsl_spi_init: Support non-QE processors

From: Peter Korsgaard <jacmet@sunsite.dk>
Date: 2007-10-03 15:44:00

On non-QE processors (mpc831x/mpc834x) the SPI clock is the SoC clock.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/sysdev/fsl_soc.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index a57fe56..59e4188 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -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)
-- 
1.5.3.2


-- 
Bye, Peter Korsgaard

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Grant Likely <hidden>
Date: 2007-10-03 15:56:35

On 10/3/07, Peter Korsgaard [off-list ref] wrote:
quoted hunk
On non-QE processors (mpc831x/mpc834x) the SPI clock is the SoC clock.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/sysdev/fsl_soc.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index a57fe56..59e4188 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -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);
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.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Peter Korsgaard <jacmet@sunsite.dk>
Date: 2007-10-03 16:05:00

quoted
quoted
quoted
quoted
"Grant" == Grant Likely [off-list ref] 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).

-- 
Bye, Peter Korsgaard

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Grant Likely <hidden>
Date: 2007-10-03 18:17:46

On 10/3/07, Peter Korsgaard [off-list ref] wrote:
quoted
quoted
quoted
quoted
quoted
"Grant" == Grant Likely [off-list ref] 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).
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.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Kumar Gala <hidden>
Date: 2007-10-03 22:11:02

On Oct 3, 2007, at 1:17 PM, Grant Likely wrote:
On 10/3/07, Peter Korsgaard [off-list ref] wrote:
quoted
quoted
quoted
quoted
quoted
quoted
"Grant" == Grant Likely [off-list ref] 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).
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

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Stephen Rothwell <hidden>
Date: 2007-10-04 04:01:43

On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard [off-list ref] wrote:
quoted hunk
@@ -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.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Kumar Gala <hidden>
Date: 2007-10-05 14:11:14

On Oct 3, 2007, at 11:01 PM, Stephen Rothwell wrote:
On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard  
[off-list ref] wrote:
quoted
@@ -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

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Peter Korsgaard <jacmet@sunsite.dk>
Date: 2007-10-06 20:06:52

quoted
quoted
quoted
quoted
"Kumar" == Kumar Gala [off-list ref] writes:
 Kumar> On Oct 3, 2007, at 11:01 PM, Stephen Rothwell wrote:

 >> On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard
 >> [off-list ref] wrote:
 >>> 
 >>> @@ -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.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 arch/powerpc/sysdev/fsl_soc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index be5e0bd..3ace747 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -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);
-- 
1.5.3.2

-- 
Bye, Peter Korsgaard

Re: [PATCH] fsl_spi_init: Support non-QE processors

From: Kumar Gala <hidden>
Date: 2007-10-08 14:09:42

On Oct 6, 2007, at 3:06 PM, Peter Korsgaard wrote:
quoted
quoted
quoted
quoted
quoted
"Kumar" == Kumar Gala [off-list ref] writes:
 Kumar> On Oct 3, 2007, at 11:01 PM, Stephen Rothwell wrote:
quoted
quoted
On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard
[off-list ref] wrote:
quoted
@@ -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 ..
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help