Skip to contentSkip to conversation

powerpc: eSPI and eSPI controller support

PATCH Superseded Shaohui Xie 3 participants 5 messages Apr 26, 2011

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 powerpc: eSPI and eSPI controller support

From: Mingkai Hu <[email protected]>

----
changes for v2:
remove #ifdef wrapper and refactor spi_xfer by use SPI_XFER(BEGIN | END). remove 'volatile' use I/O accessors instead.

changes for v3:
move powerpc specific code to asm/config.h.
use spi_claim_bus() to setup hardware rather than spi_setup_slave(). use slave data rather than global.
drop useless return.

changes for v4:
use controller specific struct rather than put in common header. merge read more than 0xfffa bytes patch.

 arch/powerpc/include/asm/config.h |    7 +
 drivers/spi/Makefile              |    1 +
 drivers/spi/fsl_espi.c            |  337 +++++++++++++++++++++++++++++++++++++
 include/spi.h                     |    9 +-
 4 files changed, 347 insertions(+), 7 deletions(-)
 create mode 100644 drivers/spi/fsl_espi.c
arch/powerpc/include/asm/config.h +7 -0
index 624d8c2..9aad9be 100644
@@ -29,6 +29,13 @@
 #include <asm/config_mpc86xx.h>
 #endif
 
+/* CONFIG_HARD_SPI triggers SPI bus initialization in PowerPC */
+#if defined(CONFIG_MPC8XXX_SPI) || defined(CONFIG_FSL_ESPI)
+# ifndef CONFIG_HARD_SPI
+#  define CONFIG_HARD_SPI
+# endif
+#endif
+
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
 #define CONFIG_SYS_BOOT_GET_CMDLINE
drivers/spi/Makefile +1 -0
index d582fbb..74f1293 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o
 COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
 COBJS-$(CONFIG_SH_SPI) += sh_spi.o
+COBJS-$(CONFIG_FSL_ESPI) += fsl_espi.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/spi/fsl_espi.c new file +337 -0

337 lines not on this page · raw message

include/spi.h +2 -7
index 320e50e..2a63f7e 100644
@@ -2,6 +2,8 @@
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com.
  *
+ * Copyright 2010-2011 Freescale Semiconductor, Inc
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -26,13 +28,6 @@
 
 /* Controller-specific definitions: */
 
-/* CONFIG_HARD_SPI triggers SPI bus initialization in PowerPC */
-#ifdef CONFIG_MPC8XXX_SPI
-# ifndef CONFIG_HARD_SPI
-#  define CONFIG_HARD_SPI
-# endif
-#endif
-
 /* SPI mode flags */
 #define	SPI_CPHA	0x01			/* clock phase */
 #define	SPI_CPOL	0x02			/* clock polarity */
Signature · 1 line
1.6.4
#1 lore raw

PATCH v4 1/1 powerpc: eSPI and eSPI controller support

Dear Shaohui Xie,

Quoted 6 lines · In message <[email protected]> you wrote:

From: Mingkai Hu <[email protected]>

...

drivers/spi/fsl_espi.c line 101

Quoted 4 lines
drivers/spi/fsl_espi.c new file +4 -0
+		if (pm > 16) {
+			pm = 16;
+			debug("Requested speed is too low: %d Hz"
+			" %d Hz is used.\n", max_hz, spibrg / (32 * 16));

Please indent continuation lines.

...

drivers/spi/fsl_espi.c line 266

Quoted 1 line
drivers/spi/fsl_espi.c new file +1 -0
+				/* Set up the next iteration if sending > 4 bytes */

Line to long. Please fix globally.

Quoted 15 lines
include/spi.h +2 -0
@@ -2,6 +2,8 @@
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com.
  *
+ * Copyright 2010-2011 Freescale Semiconductor, Inc
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -26,13 +28,6 @@
 
 /* Controller-specific definitions: */
 

include/spi.h line 33

Quoted 10 lines
include/spi.h +0 -7
-/* CONFIG_HARD_SPI triggers SPI bus initialization in PowerPC */
-#ifdef CONFIG_MPC8XXX_SPI
-# ifndef CONFIG_HARD_SPI
-#  define CONFIG_HARD_SPI
-# endif
-#endif
-
 /* SPI mode flags */
 #define	SPI_CPHA	0x01			/* clock phase */
 #define	SPI_CPOL	0x02			/* clock polarity */

Please omit this part. The deletion of 6 lines of code is not something which earns FSL any copyright.

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Stanford research group advertised for participants in a  study  of
obsessive-compulsive  disorder. They were looking for therapy clients
who had been diagnosed with this disorder. The  response  was  grati-
fying;  they  got  3,000 responses about three days after the ad came
out. All from the same person.
#2 lore raw

PATCH v4 1/1 powerpc: eSPI and eSPI controller support

Quoted 20 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Tuesday, April 26, 2011 2:51 PM
To: Xie Shaohui-B21989
Cc: u-boot at lists.denx.de; Gala Kumar-B11780
Subject: Re: [U-Boot] [PATCH][v4] powerpc: eSPI and eSPI controller support

Dear Shaohui Xie,

In message <[email protected]> you

Quoted 6 lines · wrote:

From: Mingkai Hu <[email protected]>

Quoted 7 lines

...

drivers/spi/fsl_espi.c line 101

Quoted 4 lines
drivers/spi/fsl_espi.c new file +4 -0
+		if (pm > 16) {
+			pm = 16;
+			debug("Requested speed is too low: %d Hz"
+			" %d Hz is used.\n", max_hz, spibrg / (32 * 16));

Please indent continuation lines.

[Xie Shaohui] OK.

Quoted 6 lines

...

Review

Quoted 1 line
(quoted diff) +1 -0
+				/* Set up the next iteration if sending > 4 bytes

*/

Line to long. Please fix globally.

[Xie Shaohui] OK.

Quoted 17 lines
Quoted 17 lines
include/spi.h +2 -0
@@ -2,6 +2,8 @@
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren at cideas.com.
  *
+ * Copyright 2010-2011 Freescale Semiconductor, Inc
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -26,13 +28,6 @@
 
 /* Controller-specific definitions: */
 
Quoted 11 lines
Quoted 7 lines
include/spi.h +0 -2
-/* CONFIG_HARD_SPI triggers SPI bus initialization in PowerPC */
-#ifdef CONFIG_MPC8XXX_SPI -# ifndef CONFIG_HARD_SPI -#  define

CONFIG_HARD_SPI -# endif -#endif
-
/* SPI mode flags */
#define SPI_CPHA 0x01 /* clock phase */
#define SPI_CPOL 0x02 /* clock polarity */

Please omit this part. The deletion of 6 lines of code is not something which earns FSL any copyright.

[Xie Shaohui] OK, thanks, I'll wait to see if Mike has any comment for the rest of the patch, and resend a new version.

Best Regards,
Shaohui Xie

#3 lore raw

PATCH v4 1/1 powerpc: eSPI and eSPI controller support

In reply to Shaohui Xie

drivers/spi/fsl_espi.c

Quoted 4 lines · Shaohui Xie
drivers/spi/fsl_espi.c new file +4 -0
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ ? ? ? ? ? ? ? unsigned int max_hz, unsigned int mode)
+{
+ ? ? ? fsl = malloc(sizeof(struct fsl_spi_slave));

personally, i like to use sizeof(*fsl). up to you.

Quoted 1 line

+ ? ? ? int numBlks

i believe camel case is banned in u-boot, so use "num_blks"

drivers/spi/fsl_espi.c line 237

Quoted 3 lines
drivers/spi/fsl_espi.c new file +3 -0
+       default:
+               printf("Unsupported flags: %ld\n", flags);
+               return 1;

no one else bothers checking flags, so you dont really need to either.
but if you keep this, the printf should have a prefix (such as
__func__), and the flags should be shown with %#lx.

otherwise, the actual arch-specific pieces dont jump out at me ... not that i know anything about programming ppc ...
-mike

#4 lore raw

PATCH v4 1/1 powerpc: eSPI and eSPI controller support

Quoted 7 lines · Shaohui Xie
Quoted 3 lines

+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+ ? ? ? ? ? ? ? unsigned int max_hz, unsigned int mode) {
+ ? ? ? fsl = malloc(sizeof(struct fsl_spi_slave));

Quoted 6 lines

personally, i like to use sizeof(*fsl). up to you.

Quoted 1 line

+ ? ? ? int numBlks

i believe camel case is banned in u-boot, so use "num_blks"

[Xie Shaohui] OK.

Quoted 7 lines

drivers/spi/fsl_espi.c line 237

Quoted 3 lines
drivers/spi/fsl_espi.c new file +3 -0
+       default:
+               printf("Unsupported flags: %ld\n", flags);
+               return 1;

no one else bothers checking flags, so you dont really need to either. but if you keep this, the printf should have a prefix (such as __func__), and the flags should be shown with %#lx.

[Xie Shaohui] OK, I'll remove the flag check.

Quoted 3 lines

otherwise, the actual arch-specific pieces dont jump out at me ... not that i know anything about programming ppc ...

[Xie Shaohui] This is also hard to me, the hardware is so different, and I cannot add specific controller code in common part, it's easier for software to handle transaction in common part, I've to consider many situations when handle transactions in spi_xfer().

Best Regards,
Shaohui Xie