linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsl_spi_init: Support non-QE processors
@ 2007-10-03 15:43 Peter Korsgaard
  2007-10-03 15:56 ` Grant Likely
  2007-10-04  4:01 ` Stephen Rothwell
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Korsgaard @ 2007-10-03 15:43 UTC (permalink / raw)
  To: galak, linuxppc-dev

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

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-03 15:43 [PATCH] fsl_spi_init: Support non-QE processors Peter Korsgaard
@ 2007-10-03 15:56 ` Grant Likely
  2007-10-03 16:04   ` Peter Korsgaard
  2007-10-04  4:01 ` Stephen Rothwell
  1 sibling, 1 reply; 9+ messages in thread
From: Grant Likely @ 2007-10-03 15:56 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linuxppc-dev

On 10/3/07, Peter Korsgaard <jacmet@sunsite.dk> wrote:
> 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

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-03 15:56 ` Grant Likely
@ 2007-10-03 16:04   ` Peter Korsgaard
  2007-10-03 18:17     ` Grant Likely
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Korsgaard @ 2007-10-03 16:04 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev

>>>>> "Grant" == Grant Likely <grant.likely@secretlab.ca> 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

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-03 16:04   ` Peter Korsgaard
@ 2007-10-03 18:17     ` Grant Likely
  2007-10-03 22:11       ` Kumar Gala
  0 siblings, 1 reply; 9+ messages in thread
From: Grant Likely @ 2007-10-03 18:17 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linuxppc-dev

On 10/3/07, Peter Korsgaard <jacmet@sunsite.dk> wrote:
> >>>>> "Grant" == Grant Likely <grant.likely@secretlab.ca> 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

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-03 18:17     ` Grant Likely
@ 2007-10-03 22:11       ` Kumar Gala
  0 siblings, 0 replies; 9+ messages in thread
From: Kumar Gala @ 2007-10-03 22:11 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linuxppc-dev@ozlabs.org list


On Oct 3, 2007, at 1:17 PM, Grant Likely wrote:

> On 10/3/07, Peter Korsgaard <jacmet@sunsite.dk> wrote:
>>>>>>> "Grant" == Grant Likely <grant.likely@secretlab.ca> 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

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-03 15:43 [PATCH] fsl_spi_init: Support non-QE processors Peter Korsgaard
  2007-10-03 15:56 ` Grant Likely
@ 2007-10-04  4:01 ` Stephen Rothwell
  2007-10-05 14:11   ` Kumar Gala
  1 sibling, 1 reply; 9+ messages in thread
From: Stephen Rothwell @ 2007-10-04  4:01 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard <jacmet@sunsite.dk> 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.

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

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-04  4:01 ` Stephen Rothwell
@ 2007-10-05 14:11   ` Kumar Gala
  2007-10-06 20:06     ` Peter Korsgaard
  0 siblings, 1 reply; 9+ messages in thread
From: Kumar Gala @ 2007-10-05 14:11 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: PowerPC dev list, Stephen Rothwell


On Oct 3, 2007, at 11:01 PM, Stephen Rothwell wrote:

> On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard  
> <jacmet@sunsite.dk> 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.

Peter, any chance of getting a respin.  I'd like this to go into 2.6.24.

- k

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-05 14:11   ` Kumar Gala
@ 2007-10-06 20:06     ` Peter Korsgaard
  2007-10-08 14:09       ` Kumar Gala
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Korsgaard @ 2007-10-06 20:06 UTC (permalink / raw)
  To: Kumar Gala; +Cc: PowerPC dev list, Stephen Rothwell

>>>>> "Kumar" == Kumar Gala <galak@kernel.crashing.org> writes:

 Kumar> On Oct 3, 2007, at 11:01 PM, Stephen Rothwell wrote:

 >> On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard
 >> <jacmet@sunsite.dk> 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

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

* Re: [PATCH] fsl_spi_init: Support non-QE processors
  2007-10-06 20:06     ` Peter Korsgaard
@ 2007-10-08 14:09       ` Kumar Gala
  0 siblings, 0 replies; 9+ messages in thread
From: Kumar Gala @ 2007-10-08 14:09 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: PowerPC dev list, Stephen Rothwell


On Oct 6, 2007, at 3:06 PM, Peter Korsgaard wrote:

>>>>>> "Kumar" == Kumar Gala <galak@kernel.crashing.org> writes:
>
>  Kumar> On Oct 3, 2007, at 11:01 PM, Stephen Rothwell wrote:
>
>>> On Wed, 03 Oct 2007 17:43:50 +0200 Peter Korsgaard
>>> <jacmet@sunsite.dk> 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 ..

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

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

end of thread, other threads:[~2007-10-08 14:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-03 15:43 [PATCH] fsl_spi_init: Support non-QE processors Peter Korsgaard
2007-10-03 15:56 ` Grant Likely
2007-10-03 16:04   ` Peter Korsgaard
2007-10-03 18:17     ` Grant Likely
2007-10-03 22:11       ` Kumar Gala
2007-10-04  4:01 ` Stephen Rothwell
2007-10-05 14:11   ` Kumar Gala
2007-10-06 20:06     ` Peter Korsgaard
2007-10-08 14:09       ` Kumar Gala

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