linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Adapt spi_mpc83xx SPI driver for 832x
@ 2006-12-13  9:22 Joakim Tjernlund
  2006-12-13  9:44 ` Vitaly Wool
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Joakim Tjernlund @ 2006-12-13  9:22 UTC (permalink / raw)
  To: linuxppc-dev

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

The MPC 832x has a different SPI controller i/f, probably due to
its QUICC engine support. This patch adapts the spi_mpx83xx driver to
be usable on QE based 83xx cpus.

 Jocke

PS.
   Sorry for the attatcment, I have yet to figure out how to tell
   evolution not to mangle inline patches.

[-- Attachment #2: spi2.diff --]
[-- Type: text/x-patch, Size: 2451 bytes --]

diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index ff0b048..18f094e 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -47,13 +47,19 @@ struct mpc83xx_spi_reg {
 #define	SPMODE_ENABLE		(1 << 24)
 #define	SPMODE_LEN(x)		((x) << 20)
 #define	SPMODE_PM(x)		((x) << 16)
+#define	SPMODE_OP		(1 << 14)
 
 /*
  * Default for SPI Mode:
  * 	SPI MODE 0 (inactive low, phase middle, MSB, 8-bit length, slow clk
  */
-#define	SPMODE_INIT_VAL (SPMODE_CI_INACTIVEHIGH | SPMODE_DIV16 | SPMODE_REV | \
-			 SPMODE_MS | SPMODE_LEN(7) | SPMODE_PM(0xf))
+#define SPMODE_COMMON_INIT SPMODE_CI_INACTIVEHIGH | SPMODE_DIV16 | SPMODE_REV | \
+			   SPMODE_MS | SPMODE_LEN(7) | SPMODE_PM(0xf)
+#ifdef CONFIG_QUICC_ENGINE
+  #define SPMODE_INIT_VAL (SPMODE_COMMON_INIT | SPMODE_OP)
+#else
+  #define SPMODE_INIT_VAL (SPMODE_COMMON_INIT)
+#endif
 
 /* SPIE register values */
 #define	SPIE_NE		0x00000200	/* Not empty */
@@ -99,31 +105,39 @@ static inline u32 mpc83xx_spi_read_reg(_
 	return in_be32(reg);
 }
 
-#define MPC83XX_SPI_RX_BUF(type) 					  \
+#define MPC83XX_SPI_RX_BUF(type, shift)					  \
 void mpc83xx_spi_rx_buf_##type(u32 data, struct mpc83xx_spi *mpc83xx_spi) \
 {									  \
 	type * rx = mpc83xx_spi->rx;					  \
-	*rx++ = (type)data;						  \
+	*rx++ = (type)(data >> shift);					  \
 	mpc83xx_spi->rx = rx;						  \
 }
 
-#define MPC83XX_SPI_TX_BUF(type)				\
+#define MPC83XX_SPI_TX_BUF(type, shift)				\
 u32 mpc83xx_spi_tx_buf_##type(struct mpc83xx_spi *mpc83xx_spi)	\
 {								\
 	u32 data;						\
 	const type * tx = mpc83xx_spi->tx;			\
-	data = *tx++;						\
+	data = *tx++ << shift;					\
 	mpc83xx_spi->tx = tx;					\
 	return data;						\
 }
-
-MPC83XX_SPI_RX_BUF(u8)
-MPC83XX_SPI_RX_BUF(u16)
-MPC83XX_SPI_RX_BUF(u32)
-MPC83XX_SPI_TX_BUF(u8)
-MPC83XX_SPI_TX_BUF(u16)
-MPC83XX_SPI_TX_BUF(u32)
-
+#ifdef CONFIG_QUICC_ENGINE
+/* This assumes SPMODE_REV is set */
+MPC83XX_SPI_RX_BUF(u8, 16)
+MPC83XX_SPI_RX_BUF(u16, 16)
+MPC83XX_SPI_RX_BUF(u32, 0)
+MPC83XX_SPI_TX_BUF(u8, 24)
+MPC83XX_SPI_TX_BUF(u16, 16)
+MPC83XX_SPI_TX_BUF(u32, 0)
+#else
+MPC83XX_SPI_RX_BUF(u8, 0)
+MPC83XX_SPI_RX_BUF(u16, 0)
+MPC83XX_SPI_RX_BUF(u32, 0)
+MPC83XX_SPI_TX_BUF(u8, 0)
+MPC83XX_SPI_TX_BUF(u16, 0)
+MPC83XX_SPI_TX_BUF(u32, 0)
+#endif
 static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
 {
 	struct mpc83xx_spi *mpc83xx_spi;

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

* Re: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
  2006-12-13  9:22 Joakim Tjernlund
@ 2006-12-13  9:44 ` Vitaly Wool
  2006-12-13  9:53 ` Li Yang-r58472
  2006-12-13 14:46 ` Kumar Gala
  2 siblings, 0 replies; 9+ messages in thread
From: Vitaly Wool @ 2006-12-13  9:44 UTC (permalink / raw)
  To: joakim.tjernlund; +Cc: linuxppc-dev

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

On 12/13/06, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
>
> The MPC 832x has a different SPI controller i/f, probably due to
> its QUICC engine support. This patch adapts the spi_mpx83xx driver to
> be usable on QE based 83xx cpus.
>

First, I'm pretty much against sending such patches to arch lists and not to
subsystem lists.

@@ -99,31 +105,39 @@ static inline u32 mpc83xx_spi_read_reg(_
        return in_be32(reg);
 }

Then,  this
+       *rx++ = (type)(data >> shift);                                    \
and this
+       data = *tx++ << shift;                                  \

pieces of code are potentially dangerous (what if 'shift' is something like
'x & 0xf3 << 4' ?)

Vitaly

[-- Attachment #2: Type: text/html, Size: 1495 bytes --]

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

* RE: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
  2006-12-13  9:22 Joakim Tjernlund
  2006-12-13  9:44 ` Vitaly Wool
@ 2006-12-13  9:53 ` Li Yang-r58472
  2006-12-13 14:46 ` Kumar Gala
  2 siblings, 0 replies; 9+ messages in thread
From: Li Yang-r58472 @ 2006-12-13  9:53 UTC (permalink / raw)
  To: joakim.tjernlund, linuxppc-dev

The data shifts for receive register are truly different.
Please also send such patch to SPI list:
spi-devel-general@lists.sourceforge.net

- Leo

> -----Original Message-----
> From: linuxppc-dev-bounces+leoli=3Dfreescale.com@ozlabs.org
> [mailto:linuxppc-dev-bounces+leoli=3Dfreescale.com@ozlabs.org] On =
Behalf
Of Joakim
> Tjernlund
> Sent: Wednesday, December 13, 2006 5:22 PM
> To: linuxppc-dev@ozlabs.org
> Subject: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
>=20
> The MPC 832x has a different SPI controller i/f, probably due to
> its QUICC engine support. This patch adapts the spi_mpx83xx driver to
> be usable on QE based 83xx cpus.
>=20
>  Jocke
>=20
> PS.
>    Sorry for the attatcment, I have yet to figure out how to tell
>    evolution not to mangle inline patches.

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

* RE: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
@ 2006-12-13  9:59 Joakim Tjernlund
  0 siblings, 0 replies; 9+ messages in thread
From: Joakim Tjernlund @ 2006-12-13  9:59 UTC (permalink / raw)
  To: Vitaly Wool; +Cc: linuxppc-dev

> -----Original Message-----
> From: Vitaly Wool [mailto:vitalywool@gmail.com]=20
> Sent: 13 December 2006 10:44
> To: Joakim Tjernlund
> Cc: linuxppc-dev@ozlabs.org
> Subject: Re: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
>=20
> On 12/13/06, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
>=20
> 	The MPC 832x has a different SPI controller i/f, probably due to
> 	its QUICC engine support. This patch adapts the=20
> spi_mpx83xx driver to
> 	be usable on QE based 83xx cpus.
> =09
>=20
>=20
> First, I'm pretty much against sending such patches to arch=20
> lists and not to subsystem lists.

OK, you don't want it on this list at all then?
=20
>=20
> @@ -99,31 +105,39 @@ static inline u32 mpc83xx_spi_read_reg(_
>         return in_be32(reg);
>  }
>=20
> Then,  this=20
> +       *rx++ =3D (type)(data >> shift);                       =20
>             \
> and this=20
> +       data =3D *tx++ << shift;                                  \
>=20
> pieces of code are potentially dangerous (what if 'shift' is=20
> something like 'x & 0xf3 << 4' ?)

>From this I think you want to change it to:
+       *rx++ =3D (type)(data >> (shift));

and=20
+       data =3D *tx++ << (shift);

Will do and resubmit to spi-devel-general@lists.sourceforge.net
as requested by you and Leo.

 Jocke

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

* RE: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
@ 2006-12-13 10:05 Joakim Tjernlund
  2006-12-13 10:45 ` Vitaly Wool
  0 siblings, 1 reply; 9+ messages in thread
From: Joakim Tjernlund @ 2006-12-13 10:05 UTC (permalink / raw)
  To: Li Yang-r58472, linuxppc-dev

> -----Original Message-----
> From: Li Yang-r58472 [mailto:LeoLi@freescale.com]=20
> Sent: 13 December 2006 10:54
> To: Joakim Tjernlund; linuxppc-dev@ozlabs.org
> Subject: RE: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
>=20
> The data shifts for receive register are truly different.
> Please also send such patch to SPI list:
> spi-devel-general@lists.sourceforge.net

Not only receive register, transmit is also changed.

Will send an updated patch to spi-devel-general@lists.sourceforge.net
instead of here.

    Jocke
[SNIP]

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

* Re: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
  2006-12-13 10:05 [PATCH] Adapt spi_mpc83xx SPI driver for 832x Joakim Tjernlund
@ 2006-12-13 10:45 ` Vitaly Wool
  0 siblings, 0 replies; 9+ messages in thread
From: Vitaly Wool @ 2006-12-13 10:45 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: linuxppc-dev

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

On 12/13/06, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
>
> Will send an updated patch to spi-devel-general@lists.sourceforge.net
> instead of here.
>

It's pretty fine if you CC: this list as well, but the main recipients
better be SPI subsystem maintainer (David Brownell) and SPI development
list.

Thanks,
   Vitaly

[-- Attachment #2: Type: text/html, Size: 694 bytes --]

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

* RE: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
@ 2006-12-13 12:22 Joakim Tjernlund
  0 siblings, 0 replies; 9+ messages in thread
From: Joakim Tjernlund @ 2006-12-13 12:22 UTC (permalink / raw)
  To: Vitaly Wool; +Cc: linuxppc-dev

>=20
> On 12/13/06, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
>=20
> 	Will send an updated patch to=20
> spi-devel-general@lists.sourceforge.net
> 	instead of here.
> =09
>=20
>=20
> It's pretty fine if you CC: this list as well, but the main=20
> recipients better be SPI subsystem maintainer (David=20
> Brownell) and SPI development list.=20

I already sent it to SPI development list(only added () around shift).
Next round, if any, will include this list also.

 Thanks
       Jocke

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

* Re: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
  2006-12-13  9:22 Joakim Tjernlund
  2006-12-13  9:44 ` Vitaly Wool
  2006-12-13  9:53 ` Li Yang-r58472
@ 2006-12-13 14:46 ` Kumar Gala
  2006-12-13 15:36   ` Joakim Tjernlund
  2 siblings, 1 reply; 9+ messages in thread
From: Kumar Gala @ 2006-12-13 14:46 UTC (permalink / raw)
  To: joakim.tjernlund; +Cc: linuxppc-dev Development, spi-devel-general


On Dec 13, 2006, at 3:22 AM, Joakim Tjernlund wrote:

> The MPC 832x has a different SPI controller i/f, probably due to
> its QUICC engine support. This patch adapts the spi_mpx83xx driver to
> be usable on QE based 83xx cpus.
>
>  Jocke

One problem I have with this patch is the fact that it assumes the  
current driver for (mpc834x) and your mods to support mpc832x/QE are  
mutually exclusive.

We need to handle the case of having driver support for both the QE  
and MPC834x style in the same kernel.

- k

>
> PS.
>    Sorry for the attatcment, I have yet to figure out how to tell
>    evolution not to mangle inline patches.
> <spi2.diff>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

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

* RE: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
  2006-12-13 14:46 ` Kumar Gala
@ 2006-12-13 15:36   ` Joakim Tjernlund
  0 siblings, 0 replies; 9+ messages in thread
From: Joakim Tjernlund @ 2006-12-13 15:36 UTC (permalink / raw)
  To: 'Kumar Gala'
  Cc: 'linuxppc-dev Development', spi-devel-general

> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org] 
> Sent: den 13 december 2006 15:46
> To: joakim.tjernlund@transmode.se
> Cc: linuxppc-dev Development; spi-devel-general@lists.sourceforge.net
> Subject: Re: [PATCH] Adapt spi_mpc83xx SPI driver for 832x
> 
> 
> On Dec 13, 2006, at 3:22 AM, Joakim Tjernlund wrote:
> 
> > The MPC 832x has a different SPI controller i/f, probably due to
> > its QUICC engine support. This patch adapts the spi_mpx83xx 
> driver to
> > be usable on QE based 83xx cpus.
> >
> >  Jocke
> 
> One problem I have with this patch is the fact that it assumes the  
> current driver for (mpc834x) and your mods to support mpc832x/QE are  
> mutually exclusive.

I don't see that as a problem ATM. If that is added it should be optional.

> 
> We need to handle the case of having driver support for both the QE  
> and MPC834x style in the same kernel.

Adding that will double the number RX_BUF/TX_BUF functions from 6 to 12
(possibly this can be reduced by adding more logic to the tx_buf/rx_buf functions)
not to mention what will happen when support for reversed bit order is added.

I would argue that the kernel lacks the possibility to remove complexity
I don't need. Example in this driver is that there is no way to remove
support for 16 and 32 bit SPI character sizes. The same goes for a lot of
the probing code in fsl-soc.c.

It would be nice if a board port could add a custom header file that
gets included by all .c automatically. Then one could add knobs
(read #defines) there to futher tune such things as SPI char size.
That way one don't have add Kconfig entries for all those small
tuning knobs.

 Jocke

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

end of thread, other threads:[~2006-12-13 15:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 10:05 [PATCH] Adapt spi_mpc83xx SPI driver for 832x Joakim Tjernlund
2006-12-13 10:45 ` Vitaly Wool
  -- strict thread matches above, loose matches on Subject: below --
2006-12-13 12:22 Joakim Tjernlund
2006-12-13  9:59 Joakim Tjernlund
2006-12-13  9:22 Joakim Tjernlund
2006-12-13  9:44 ` Vitaly Wool
2006-12-13  9:53 ` Li Yang-r58472
2006-12-13 14:46 ` Kumar Gala
2006-12-13 15:36   ` Joakim Tjernlund

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