Skip to contentSkip to conversation

spi: DM_SPI migration timeout!

PATCH Superseded Jagan Teki 3 participants 41 messages Nov 20, 2018 – Nov 21, 2018

Subsystems (7)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

cover spi: DM_SPI migration timeout!

This series grouped all dm related patches, which were in ML since from many releases.

We have not heard any positive feed back about dm-conversion on spi drivers along with no response for the work done by Akash and me.

So, finally I've taken step.
- for partially converted drivers:
now drivers is fully dm-driven, and non-dm calls are routed to dummy calls in drivers/spi/spi.c, now it's board maintainer to enable DM_SPI otherwise the relevent spi stuff is not working.
- for no dm conversion drivers:
removed the drivers along with respective instances.

Note:
- fsl_espi, managing many files, but will remove in next version
- I'm hoping this conversion can hit the foot-print issues, but will discuss how to move this further otherwise this can be final.

Jagan Teki (16):
spi: Remove unused spi_init
spi: Remove used spi_init
spi: davinci: Full dm conversion
spi: kirkwood: Full dm conversion
spi: ti_qspi: Full dm conversion
spi: Zap cf_spi driver-related code
spi: Zap lpc32xx_ssp driver-related code
spi: Zap mxs_spi driver-related code
spi: Zap sh_spi driver-related code
spi: Zap soft_spi_legacy driver-related code
spi: Zap mpc8xx_spi driver-related code
spi: Zap mxc_spi driver-related code
spi: Zap omap3_spi driver-related code
spi: Zap atmel_spi driver-related code
spi: fsl_dspi: Drop non-dm code
dm: MIGRATION: spi: Update SPI driver status

Mario Six (18):
spi: mpc8xxx: Use short type names
spi: mpc8xxx: Fix comments
spi: mpc8xxx: Rename camel-case variables
spi: mpc8xxx: Fix space after cast
spi: mpc8xxx: Fix function names in strings
spi: mpc8xxx: Replace defines with enums
spi: mpc8xxx: Use IO accessors
spi: mpc8xxx: Simplify if
spi: mpc8xxx: Get rid of is_read
spi: mpc8xxx: Simplify logic a bit
spi: mpc8xxx: Reduce scope of loop variables
spi: mpc8xxx: Make code more readable
spi: mpc8xxx: Rename variable
spi: mpc8xxx: Document LEN setting better
spi: mpc8xxx: Re-order transfer setup
spi: mpc8xxx: Fix if check
spi: mpc8xxx: Use get_timer
spi: mpc8xxx: Convert to DM

 Makefile                                      |  11 +
 cmd/eeprom.c                                  |   4 +-
 common/board_f.c                              |   1 -
 common/board_r.c                              |   7 -
 configs/M52277EVB_defconfig                   |   6 -
 configs/M52277EVB_stmicro_defconfig           |   7 -
 configs/M54418TWR_defconfig                   |   7 -
 configs/M54418TWR_nand_mii_defconfig          |   6 -
 configs/M54418TWR_nand_rmii_defconfig         |   6 -
 configs/M54418TWR_nand_rmii_lowfreq_defconfig |   6 -
 configs/M54418TWR_serial_mii_defconfig        |   7 -
 configs/M54418TWR_serial_rmii_defconfig       |   7 -
 configs/M54451EVB_defconfig                   |   6 -
 configs/M54451EVB_stmicro_defconfig           |   7 -
 configs/M54455EVB_a66_defconfig               |   6 -
 configs/M54455EVB_defconfig                   |   6 -
 configs/M54455EVB_i66_defconfig               |   6 -
 configs/M54455EVB_intel_defconfig             |   6 -
 configs/M54455EVB_stm33_defconfig             |   7 -
 configs/bg0900_defconfig                      |   7 -
 configs/devkit3250_defconfig                  |   3 -
 configs/mx28evk_auart_console_defconfig       |   6 -
 configs/mx28evk_defconfig                     |   6 -
 configs/mx28evk_nand_defconfig                |   6 -
 configs/mx28evk_spi_defconfig                 |   7 -
 configs/sh7752evb_defconfig                   |   7 -
 configs/sh7753evb_defconfig                   |   7 -
 configs/sh7757lcr_defconfig                   |   6 -
 configs/stmark2_defconfig                     |   8 -
 configs/work_92105_defconfig                  |   3 -
 configs/zipitz2_defconfig                     |   1 -
 doc/driver-model/MIGRATION.txt                |  17 +-
 doc/driver-model/spi-howto.txt                |   5 -
 drivers/net/e1000_spi.c                       |   3 -
 drivers/spi/Kconfig                           |  41 +-
 drivers/spi/Makefile                          |  20 +-
 drivers/spi/atmel_spi.c                       | 203 --------
 drivers/spi/cf_spi.c                          | 335 ------------
 drivers/spi/davinci_spi.c                     | 162 ------
 drivers/spi/fsl_dspi.c                        | 137 -----
 drivers/spi/fsl_espi.c                        |   5 -
 drivers/spi/kirkwood_spi.c                    | 229 ++------
 drivers/spi/lpc32xx_ssp.c                     | 143 -----
 drivers/spi/mpc8xx_spi.c                      | 335 ------------
 drivers/spi/mpc8xxx_spi.c                     | 279 ++++++----
 drivers/spi/mxc_spi.c                         | 127 +----
 drivers/spi/mxs_spi.c                         | 362 -------------
 drivers/spi/omap3_spi.c                       | 131 -----
 drivers/spi/sh_qspi.c                         |   5 -
 drivers/spi/sh_spi.c                          | 253 ---------
 drivers/spi/sh_spi.h                          |  67 ---
 drivers/spi/soft_spi_legacy.c                 | 175 -------
 drivers/spi/spi.c                             |  42 ++
 drivers/spi/ti_qspi.c                         | 490 +++++++-----------
 examples/standalone/atmel_df_pow2.c           |   2 -
 include/_exports.h                            |   2 -
 include/common.h                              |   7 -
 include/configs/MPC8349EMDS.h                 |   3 -
 include/configs/devkit3250.h                  |   5 -
 include/configs/sh7752evb.h                   |   5 -
 include/configs/sh7753evb.h                   |   5 -
 include/configs/sh7757lcr.h                   |   5 -
 include/configs/work_92105.h                  |   5 -
 include/configs/zipitz2.h                     |   7 -
 include/dm/platform_data/spi_kirkwood.h       |  15 +
 include/dm/platform_data/spi_ti_qspi.h        |  19 +
 include/spi.h                                 |   7 -
 scripts/config_whitelist.txt                  |   2 -
 68 files changed, 512 insertions(+), 3329 deletions(-)
 delete mode 100644 drivers/spi/cf_spi.c
 delete mode 100644 drivers/spi/lpc32xx_ssp.c
 delete mode 100644 drivers/spi/mpc8xx_spi.c
 delete mode 100644 drivers/spi/mxs_spi.c
 delete mode 100644 drivers/spi/sh_spi.c
 delete mode 100644 drivers/spi/sh_spi.h
 delete mode 100644 drivers/spi/soft_spi_legacy.c
 create mode 100644 include/dm/platform_data/spi_kirkwood.h
 create mode 100644 include/dm/platform_data/spi_ti_qspi.h
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#1 lore raw

PATCH 1/34 spi: Remove unused spi_init

Remove spi_init definition which never used on
respective code since from many years.

---
 drivers/net/e1000_spi.c       | 3 ---
 drivers/spi/atmel_spi.c       | 5 -----
 drivers/spi/davinci_spi.c     | 5 -----
 drivers/spi/fsl_dspi.c        | 5 -----
 drivers/spi/fsl_espi.c        | 5 -----
 drivers/spi/lpc32xx_ssp.c     | 9 ---------
 drivers/spi/mxc_spi.c         | 4 ----
 drivers/spi/mxs_spi.c         | 4 ----
 drivers/spi/omap3_spi.c       | 5 -----
 drivers/spi/sh_qspi.c         | 5 -----
 drivers/spi/sh_spi.c          | 4 ----
 drivers/spi/soft_spi_legacy.c | 7 -------
 include/spi.h                 | 7 -------
 13 files changed, 68 deletions(-)
drivers/net/e1000_spi.c +0 -3
index b38f4df9f3..aecd290d72 100644
@@ -77,9 +77,6 @@ static inline struct e1000_hw *e1000_hw_from_spi(struct spi_slave *spi)
 	return container_of(spi, struct e1000_hw, spi);
 }
 
-/* Not sure why all of these are necessary */
-void spi_init(void)   { /* Nothing to do */ }
-
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int mode)
 {
drivers/spi/atmel_spi.c +0 -5
index 1db8bbef2b..cf4de9ee1a 100644
@@ -34,11 +34,6 @@ static int spi_has_wdrbt(struct atmel_spi_slave *slave)
 	return (ATMEL_SPI_VERSION_REV(ver) >= 0x210);
 }
 
-void spi_init()
-{
-
-}
-
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 			unsigned int max_hz, unsigned int mode)
 {
drivers/spi/davinci_spi.c +0 -5
index 07fa5e3b8a..4d2c106440 100644
@@ -388,11 +388,6 @@ void spi_cs_deactivate(struct spi_slave *slave)
 	/* do nothing */
 }
 
-void spi_init(void)
-{
-	/* do nothing */
-}
-
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 			unsigned int max_hz, unsigned int mode)
 {
drivers/spi/fsl_dspi.c +0 -5
index f7ed8fbe08..764c94215e 100644
@@ -390,11 +390,6 @@ static int fsl_dspi_cfg_speed(struct fsl_dspi_priv *priv, uint speed)
 	return 0;
 }
 #ifndef CONFIG_DM_SPI
-void spi_init(void)
-{
-	/* Nothing to do */
-}
-
 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
 {
 	if (((cs >= 0) && (cs < 8)) && ((bus >= 0) && (bus < 8)))
drivers/spi/fsl_espi.c +0 -5
index e9941593f5..7444ae1a06 100644
@@ -118,11 +118,6 @@ void spi_free_slave(struct spi_slave *slave)
 	free(fsl);
 }
 
-void spi_init(void)
-{
-
-}
-
 int spi_claim_bus(struct spi_slave *slave)
 {
 	struct fsl_spi_slave *fsl = to_fsl_spi_slave(slave);
drivers/spi/lpc32xx_ssp.c +0 -9
index ce12eee657..4b09366317 100644
@@ -47,15 +47,6 @@ static inline struct lpc32xx_spi_slave *to_lpc32xx_spi_slave(
 	return container_of(slave, struct lpc32xx_spi_slave, slave);
 }
 
-/* spi_init is called during boot when CONFIG_CMD_SPI is defined */
-void spi_init(void)
-{
-	/*
-	 *  nothing to do: clocking was enabled in lpc32xx_ssp_enable()
-	 * and configuration will be done in spi_setup_slave()
-	*/
-}
-
 /* the following is called in sequence by do_spi_xfer() */
 
 struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode)
drivers/spi/mxc_spi.c +0 -4
index 0dccc38b82..b2636909ce 100644
@@ -400,10 +400,6 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
 	return mxc_spi_xfer_internal(mxcs, bitlen, dout, din, flags);
 }
 
-void spi_init(void)
-{
-}
-
 /*
  * Some SPI devices require active chip-select over multiple
  * transactions, we achieve this using a GPIO. Still, the SPI
drivers/spi/mxs_spi.c +0 -4
index 006fe8281c..5065e407f8 100644
@@ -39,10 +39,6 @@ static inline struct mxs_spi_slave *to_mxs_slave(struct spi_slave *slave)
 	return container_of(slave, struct mxs_spi_slave, slave);
 }
 
-void spi_init(void)
-{
-}
-
 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
 {
 	/* MXS SPI: 4 ports and 3 chip selects maximum */
drivers/spi/omap3_spi.c +0 -5
index ecf54bb714..c7fcf050a5 100644
@@ -461,11 +461,6 @@ static inline struct omap3_spi_priv *to_omap3_spi(struct spi_slave *slave)
 	return container_of(slave, struct omap3_spi_priv, slave);
 }
 
-void spi_init(void)
-{
-	/* do nothing */
-}
-
 void spi_free_slave(struct spi_slave *slave)
 {
 	struct omap3_spi_priv *priv = to_omap3_spi(slave);
drivers/spi/sh_qspi.c +0 -5
index 64dfd748d6..5ae203d8d4 100644
@@ -247,11 +247,6 @@ void spi_cs_deactivate(struct spi_slave *slave)
 	sh_qspi_cs_deactivate(ss);
 }
 
-void spi_init(void)
-{
-	/* nothing to do */
-}
-
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int mode)
 {
drivers/spi/sh_spi.c +0 -4
index bc2bd638e6..c58fd0ebc4 100644
@@ -66,10 +66,6 @@ static int write_fifo_empty_wait(struct sh_spi *ss)
 	return 0;
 }
 
-void spi_init(void)
-{
-}
-
 static void sh_spi_set_cs(struct sh_spi *ss, unsigned int cs)
 {
 	unsigned long val = 0;
drivers/spi/soft_spi_legacy.c +0 -7
index 0aac0c065d..cc5ab5f991 100644
@@ -36,13 +36,6 @@ static inline struct soft_spi_slave *to_soft_spi(struct spi_slave *slave)
 /*                         Public Functions                            */
 /*=====================================================================*/
 
-/*-----------------------------------------------------------------------
- * Initialization
- */
-void spi_init (void)
-{
-}
-
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int mode)
 {
include/spi.h +0 -7
index 938627bc01..92427e5f32 100644
@@ -117,13 +117,6 @@ struct spi_slave {
 #define SPI_XFER_MMAP_END	BIT(3)	/* Memory Mapped End */
 };
 
-/**
- * Initialization, must be called once on start up.
- *
- * TODO: I don't think we really need this.
- */
-void spi_init(void);
-
 /**
  * spi_do_alloc_slave - Allocate a new SPI slave (internal)
  *
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#2 lore raw

PATCH 2/34 spi: Remove used spi_init

In reply to Jagan Teki

spi_init used in some areas in tree, but the respective drivers will remove in future patches.

So remove the same instances.

---
 common/board_f.c                    | 1 -
 doc/driver-model/spi-howto.txt      | 5 -----
 examples/standalone/atmel_df_pow2.c | 2 --
 include/_exports.h                  | 2 --
 4 files changed, 10 deletions(-)
common/board_f.c +0 -1
index f1a1432d86..27c27803cc 100644
@@ -262,7 +262,6 @@ __weak int init_func_vid(void)
 static int init_func_spi(void)
 {
 	puts("SPI:   ");
-	spi_init();
 	puts("ready\n");
 	return 0;
 }
doc/driver-model/spi-howto.txt +0 -5
index 1955ffe284..38c26f642b 100644
@@ -163,11 +163,6 @@ At this point you should be able to build U-Boot for your board with the
 empty SPI driver. You still have empty methods in your driver, but we will
 write these one by one.
 
-If you have spi_init() functions or the like that are called from your
-board then the build will fail. Remove these calls and make a note of the
-init that needs to be done.
-
-
 7. Set up your platform data structure
 
 This will hold the information your driver to operate, like its hardware
examples/standalone/atmel_df_pow2.c +0 -2
index 2e14aba390..b7bd243730 100644
@@ -126,8 +126,6 @@ int atmel_df_pow2(int argc, char * const argv[])
 		return 1;
 	}
 
-	spi_init();
-
 	while (1) {
 		struct spi_slave *slave;
 		char *line, *p;
include/_exports.h +0 -2
index 5416041243..c15050e30b 100644
@@ -50,11 +50,9 @@
 #endif
 
 #if !defined(CONFIG_CMD_SPI) || defined(CONFIG_DM_SPI)
-	EXPORT_FUNC(dummy, void, spi_init, void)
 	EXPORT_FUNC(dummy, void, spi_setup_slave, void)
 	EXPORT_FUNC(dummy, void, spi_free_slave, void)
 #else
-	EXPORT_FUNC(spi_init, void, spi_init, void)
 	EXPORT_FUNC(spi_setup_slave, struct spi_slave *, spi_setup_slave,
 		    unsigned int, unsigned int, unsigned int, unsigned int)
 	EXPORT_FUNC(spi_free_slave, void, spi_free_slave, struct spi_slave *)
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#3 lore raw

PATCH 3/34 spi: davinci: Full dm conversion

In reply to Jagan Teki

davinci_spi now support dt along with platform data, respective boards need to switch into dm for the same.

Cc Adam Ford <[email protected]>
Cc Vitaly Andrianov <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Peter Howard <[email protected]>
Cc Tom Rini <[email protected]>
---
 Makefile                  |   9 +++
 drivers/spi/Makefile      |   2 +-
 drivers/spi/davinci_spi.c | 157 --------------------------------------
 drivers/spi/spi.c         |  35 +++++++++
 4 files changed, 45 insertions(+), 158 deletions(-)
Makefile +9 -0
index 552687db53..d06cb5c287 100644
@@ -917,6 +917,15 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 	@echo "(possibly in a subsequent patch in your series)"
 	@echo "before sending patches to the mailing list."
 	@echo "===================================================="
+endif
+ifeq ($(CONFIG_DM_SPI),)
+ifeq ($(CONFIG_DAVINCI_SPI),y)
+	@echo "===================== WARNING ======================"
+	@echo "This board uses SPI driver from drivers/spi/ without"
+	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
+	@echo "otherwise SPI on this board, cannot work."
+	@echo "===================================================="
+endif
 endif
 	@# Check that this build does not use CONFIG options that we do not
 	@# know about unless they are in Kconfig. All the existing CONFIG
drivers/spi/Makefile +1 -1
index 7242ea7e40..cf5a5cccc0 100644
@@ -6,6 +6,7 @@
 # There are many options which enable SPI, so make this library available
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
+obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -22,7 +23,6 @@ obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
 obj-$(CONFIG_BCMSTB_SPI) += bcmstb_spi.o
 obj-$(CONFIG_CADENCE_QSPI) += cadence_qspi.o cadence_qspi_apb.o
 obj-$(CONFIG_CF_SPI) += cf_spi.o
-obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_DESIGNWARE_SPI) += designware_spi.o
 obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
drivers/spi/davinci_spi.c +0 -157

178 lines not on this page · raw message

drivers/spi/spi.c +35 -0
index 22910de0dd..ba1d1b082d 100644
@@ -38,3 +38,38 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 
 	return ptr;
 }
+
+#if !defined(CONFIG_DM_SPI) && defined(CONFIG_DAVINCI_SPI)
+void spi_cs_activate(struct spi_slave *slave)
+{
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+				  unsigned int max_hz, unsigned int mode)
+{
+	return NULL;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+	     const void *dout, void *din, unsigned long flags)
+{
+	return 0;
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+	return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+}
+#endif
Signature · 1 line
2.18.0.321.gffc6fa0e3
#4 lore raw

PATCH 3/34 spi: davinci: Full dm conversion

Quoted 10 lines · Jagan Teki

davinci_spi now support dt along with platform data, respective boards need to switch into dm for the same.

Cc Adam Ford <[email protected]>
Cc Vitaly Andrianov <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Peter Howard <[email protected]>
Cc Tom Rini <[email protected]>

I applied the whole series to origin/master, but the atmel driver didn't apply with git am, so I skipped it.

With that caveat, I tested this on the da850 EVM and I found no issues, so you can mark me as

Quoted 279 lines
---
 Makefile                  |   9 +++
 drivers/spi/Makefile      |   2 +-
 drivers/spi/davinci_spi.c | 157 --------------------------------------
 drivers/spi/spi.c         |  35 +++++++++
 4 files changed, 45 insertions(+), 158 deletions(-)
Makefile +9 -0
index 552687db53..d06cb5c287 100644
@@ -917,6 +917,15 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
        @echo "(possibly in a subsequent patch in your series)"
        @echo "before sending patches to the mailing list."
        @echo "===================================================="
+endif
+ifeq ($(CONFIG_DM_SPI),)
+ifeq ($(CONFIG_DAVINCI_SPI),y)
+       @echo "===================== WARNING ======================"
+       @echo "This board uses SPI driver from drivers/spi/ without"
+       @echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
+       @echo "otherwise SPI on this board, cannot work."
+       @echo "===================================================="
+endif
 endif
        @# Check that this build does not use CONFIG options that we do not
        @# know about unless they are in Kconfig. All the existing CONFIG
drivers/spi/Makefile +1 -1
index 7242ea7e40..cf5a5cccc0 100644
@@ -6,6 +6,7 @@
 # There are many options which enable SPI, so make this library available
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
+obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -22,7 +23,6 @@ obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
 obj-$(CONFIG_BCMSTB_SPI) += bcmstb_spi.o
 obj-$(CONFIG_CADENCE_QSPI) += cadence_qspi.o cadence_qspi_apb.o
 obj-$(CONFIG_CF_SPI) += cf_spi.o
-obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_DESIGNWARE_SPI) += designware_spi.o
 obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
drivers/spi/davinci_spi.c +0 -157
index 4d2c106440..c1646f6cdc 100644
@@ -52,41 +52,6 @@
 /* SPIDEF */
 #define SPIDEF_CSDEF0_MASK     BIT(0)
 
-#ifndef CONFIG_DM_SPI
-#define SPI0_BUS               0
-#define SPI0_BASE              CONFIG_SYS_SPI_BASE
-/*
- * Define default SPI0_NUM_CS as 1 for existing platforms that uses this
- * driver. Platform can configure number of CS using CONFIG_SYS_SPI0_NUM_CS
- * if more than one CS is supported and by defining CONFIG_SYS_SPI0.
- */
-#ifndef CONFIG_SYS_SPI0
-#define SPI0_NUM_CS            1
-#else
-#define SPI0_NUM_CS            CONFIG_SYS_SPI0_NUM_CS
-#endif
-
-/*
- * define CONFIG_SYS_SPI1 when platform has spi-1 device (bus #1) and
- * CONFIG_SYS_SPI1_NUM_CS defines number of CS on this bus
- */
-#ifdef CONFIG_SYS_SPI1
-#define SPI1_BUS               1
-#define SPI1_NUM_CS            CONFIG_SYS_SPI1_NUM_CS
-#define SPI1_BASE              CONFIG_SYS_SPI1_BASE
-#endif
-
-/*
- * define CONFIG_SYS_SPI2 when platform has spi-2 device (bus #2) and
- * CONFIG_SYS_SPI2_NUM_CS defines number of CS on this bus
- */
-#ifdef CONFIG_SYS_SPI2
-#define SPI2_BUS               2
-#define SPI2_NUM_CS            CONFIG_SYS_SPI2_NUM_CS
-#define SPI2_BASE              CONFIG_SYS_SPI2_BASE
-#endif
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 /* davinci spi register set */
@@ -119,9 +84,6 @@ struct davinci_spi_regs {
 
 /* davinci spi slave */
 struct davinci_spi_slave {
-#ifndef CONFIG_DM_SPI
-       struct spi_slave slave;
-#endif
        struct davinci_spi_regs *regs;
        unsigned int freq; /* current SPI bus frequency */
        unsigned int mode; /* current SPI mode used */
@@ -343,124 +305,6 @@ out:
        return 0;
 }
 
-#ifndef CONFIG_DM_SPI
-
-static inline struct davinci_spi_slave *to_davinci_spi(struct spi_slave *slave)
-{
-       return container_of(slave, struct davinci_spi_slave, slave);
-}
-
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-       int ret = 0;
-
-       switch (bus) {
-       case SPI0_BUS:
-               if (cs < SPI0_NUM_CS)
-                       ret = 1;
-               break;
-#ifdef CONFIG_SYS_SPI1
-       case SPI1_BUS:
-               if (cs < SPI1_NUM_CS)
-                       ret = 1;
-               break;
-#endif
-#ifdef CONFIG_SYS_SPI2
-       case SPI2_BUS:
-               if (cs < SPI2_NUM_CS)
-                       ret = 1;
-               break;
-#endif
-       default:
-               /* Invalid bus number. Do nothing */
-               break;
-       }
-       return ret;
-}
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-       /* do nothing */
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-       /* do nothing */
-}
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-                       unsigned int max_hz, unsigned int mode)
-{
-       struct davinci_spi_slave        *ds;
-
-       if (!spi_cs_is_valid(bus, cs))
-               return NULL;
-
-       ds = spi_alloc_slave(struct davinci_spi_slave, bus, cs);
-       if (!ds)
-               return NULL;
-
-       switch (bus) {
-       case SPI0_BUS:
-               ds->regs = (struct davinci_spi_regs *)SPI0_BASE;
-               break;
-#ifdef CONFIG_SYS_SPI1
-       case SPI1_BUS:
-               ds->regs = (struct davinci_spi_regs *)SPI1_BASE;
-               break;
-#endif
-#ifdef CONFIG_SYS_SPI2
-       case SPI2_BUS:
-               ds->regs = (struct davinci_spi_regs *)SPI2_BASE;
-               break;
-#endif
-       default: /* Invalid bus number */
-               return NULL;
-       }
-
-       ds->freq = max_hz;
-       ds->mode = mode;
-
-       return &ds->slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-       struct davinci_spi_slave *ds = to_davinci_spi(slave);
-
-       free(ds);
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
-            const void *dout, void *din, unsigned long flags)
-{
-       struct davinci_spi_slave *ds = to_davinci_spi(slave);
-
-       ds->cur_cs = slave->cs;
-
-       return __davinci_spi_xfer(ds, bitlen, dout, din, flags);
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-       struct davinci_spi_slave *ds = to_davinci_spi(slave);
-
-#ifdef CONFIG_SPI_HALF_DUPLEX
-       ds->half_duplex = true;
-#else
-       ds->half_duplex = false;
-#endif
-       return __davinci_spi_claim_bus(ds, ds->slave.cs);
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-       struct davinci_spi_slave *ds = to_davinci_spi(slave);
-
-       __davinci_spi_release_bus(ds);
-}
-
-#else
 static int davinci_spi_set_speed(struct udevice *bus, uint max_hz)
 {
        struct davinci_spi_slave *ds = dev_get_priv(bus);
@@ -579,4 +423,3 @@ U_BOOT_DRIVER(davinci_spi) = {
        .ops = &davinci_spi_ops,
        .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
 };
-#endif
drivers/spi/spi.c +35 -1
index 22910de0dd..ba1d1b082d 100644
@@ -38,3 +38,38 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 
        return ptr;
 }
+
+#if !defined(CONFIG_DM_SPI) && defined(CONFIG_DAVINCI_SPI)
+void spi_cs_activate(struct spi_slave *slave)
+{
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+                                 unsigned int max_hz, unsigned int mode)
+{
+       return NULL;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+            const void *dout, void *din, unsigned long flags)
+{
+       return 0;
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+       return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+}
+#endif
--

2.18.0.321.gffc6fa0e3

#5 lore raw

PATCH 3/34 spi: davinci: Full dm conversion

In reply to Jagan Teki

Hi Jagan,

Makefile ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y) · line 928

Quoted 9 lines · Jagan Teki
Makefile +8 -0
+ifeq ($(CONFIG_DM_SPI),)
+ifeq ($(CONFIG_DAVINCI_SPI),y)
+       @echo "===================== WARNING ======================"
+       @echo "This board uses SPI driver from drivers/spi/ without"
+       @echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
+       @echo "otherwise SPI on this board, cannot work."
+       @echo "===================================================="
+endif

Is it worth making this @echo >&2 "...." that way buildman will consider this a warning.

author
#6 lore raw

PATCH 4/34 spi: kirkwood: Full dm conversion

In reply to Jagan Teki

kirkwood now support dt along with platform data, respective boards need to switch into dm for the same.

---
 Makefile                                |   2 +-
 drivers/spi/Makefile                    |   2 +-
 drivers/spi/kirkwood_spi.c              | 229 +++++-------------------
 drivers/spi/spi.c                       |   4 +-
 include/dm/platform_data/spi_kirkwood.h |  15 ++
 5 files changed, 61 insertions(+), 191 deletions(-)
 create mode 100644 include/dm/platform_data/spi_kirkwood.h
Makefile +1 -1
index d06cb5c287..214f1bcdbf 100644
@@ -919,7 +919,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 	@echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(CONFIG_DAVINCI_SPI),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI),y),y)
 	@echo "===================== WARNING ======================"
 	@echo "This board uses SPI driver from drivers/spi/ without"
 	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index cf5a5cccc0..3c74418992 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -29,7 +30,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/kirkwood_spi.c +41 -188

309 lines not on this page · raw message

drivers/spi/spi.c +3 -1
index ba1d1b082d..5181d5b83f 100644
@@ -39,7 +39,9 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 	return ptr;
 }
 
-#if !defined(CONFIG_DM_SPI) && defined(CONFIG_DAVINCI_SPI)
+#if !defined(CONFIG_DM_SPI) && \
+	defined(CONFIG_DAVINCI_SPI) || \
+	defined(CONFIG_KIRKWOOD_SPI)
 void spi_cs_activate(struct spi_slave *slave)
 {
 }
include/dm/platform_data/spi_kirkwood.h new file +15 -0
new file mode 100644
index 0000000000..ae9b2783a9
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2018 Jagan Teki <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __spi_kirkwood_h
+#define __spi_kirkwood_h
+
+struct mvebu_spi_platdata {
+	struct kwspi_registers *spireg;
+	bool is_errata_50mhz_ac;
+};
+
+#endif /* __spi_kirkwood_h */
Signature · 1 line
2.18.0.321.gffc6fa0e3
#7 lore raw

PATCH 4/34 spi: kirkwood: Full dm conversion

Hi Jagan,

Quoted 326 lines · Jagan Teki

kirkwood now support dt along with platform data, respective boards need to switch into dm for the same.

---
 Makefile                                |   2 +-
 drivers/spi/Makefile                    |   2 +-
 drivers/spi/kirkwood_spi.c              | 229 +++++-------------------
 drivers/spi/spi.c                       |   4 +-
 include/dm/platform_data/spi_kirkwood.h |  15 ++
 5 files changed, 61 insertions(+), 191 deletions(-)
 create mode 100644 include/dm/platform_data/spi_kirkwood.h
Makefile +1 -1
index d06cb5c287..214f1bcdbf 100644
@@ -919,7 +919,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
        @echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(CONFIG_DAVINCI_SPI),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI),y),y)
        @echo "===================== WARNING ======================"
        @echo "This board uses SPI driver from drivers/spi/ without"
        @echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index cf5a5cccc0..3c74418992 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -29,7 +30,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/kirkwood_spi.c +25 -186
index 5dd1ad67cf..e9ca95697f 100644
@@ -13,31 +13,41 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/soc.h>
-#ifdef CONFIG_KIRKWOOD
-#include <asm/arch/mpp.h>
-#endif
 #include <asm/arch-mvebu/spi.h>
 
-static void _spi_cs_activate(struct kwspi_registers *reg)
+#include <dm/platform_data/spi_kirkwood.h>
+
+struct mvebu_spi_dev {
+       bool    is_errata_50mhz_ac;
+};
+
+struct mvebu_spi_priv {
+       struct kwspi_registers *spireg;
+};
+
+static void spi_cs_activate(struct kwspi_registers *reg)
 {
        setbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static void _spi_cs_deactivate(struct kwspi_registers *reg)
+static void spi_cs_deactivate(struct kwspi_registers *reg)
 {
        clrbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
-                    const void *dout, void *din, unsigned long flags)
+static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
+                         const void *dout, void *din, unsigned long flags)
 {
+       struct udevice *bus = dev->parent;
+       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+       struct kwspi_registers *reg = plat->spireg;
        unsigned int tmpdout, tmpdin;
        int tm, isread = 0;
 
-       debug("spi_xfer: dout %p din %p bitlen %u\n", dout, din, bitlen);
+       debug("%s: dout %p din %p bitlen %u\n", __func__, dout, din, bitlen);
 
        if (flags & SPI_XFER_BEGIN)
-               _spi_cs_activate(reg);
+               spi_cs_activate(reg);
 
        /*
         * handle data in 8-bit chunks
@@ -55,8 +65,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
 
                clrbits_le32(&reg->irq_cause, KWSPI_SMEMRDIRQ);
                writel(tmpdout, &reg->dout);    /* Write the data out */
-               debug("*** spi_xfer: ... %08x written, bitlen %d\n",
-                     tmpdout, bitlen);
+               debug("%s: ... %08x written, bitlen %d\n",
+                     __func__, tmpdout, bitlen);
 
                /*
                 * Wait for SPI transmit to get out
@@ -67,8 +77,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                        if (readl(&reg->irq_cause) & KWSPI_SMEMRDIRQ) {
                                isread = 1;
                                tmpdin = readl(&reg->din);
-                               debug("spi_xfer: din %p..%08x read\n",
-                                     din, tmpdin);
+                               debug("%s: din %p..%08x read\n",
+                                     __func__, din, tmpdin);
 
                                if (din) {
                                        *((u8 *)din) = (u8)tmpdin;
@@ -82,179 +92,17 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                                break;
                }
                if (tm >= KWSPI_TIMEOUT)
-                       printf("*** spi_xfer: Time out during SPI transfer\n");
+                       printf("%s: Time out during SPI transfer\n", __func__);
 
                debug("loopend bitlen %d\n", bitlen);
        }
 
        if (flags & SPI_XFER_END)
-               _spi_cs_deactivate(reg);
+               spi_cs_deactivate(reg);
 
        return 0;
 }
 
-#ifndef CONFIG_DM_SPI
-
-static struct kwspi_registers *spireg =
-       (struct kwspi_registers *)MVEBU_SPI_BASE;
-
-#ifdef CONFIG_KIRKWOOD
-static u32 cs_spi_mpp_back[2];
-#endif
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-                               unsigned int max_hz, unsigned int mode)
-{
-       struct spi_slave *slave;
-       u32 data;
-#ifdef CONFIG_KIRKWOOD
-       static const u32 kwspi_mpp_config[2][2] = {
-               { MPP0_SPI_SCn, 0 }, /* if cs == 0 */
-               { MPP7_SPI_SCn, 0 } /* if cs != 0 */
-       };
-#endif
-
-       if (!spi_cs_is_valid(bus, cs))
-               return NULL;
-
-       slave = spi_alloc_slave_base(bus, cs);
-       if (!slave)
-               return NULL;
-
-       writel(KWSPI_SMEMRDY, &spireg->ctrl);
-
-       /* calculate spi clock prescaller using max_hz */
-       data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
-       data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data;
-       data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data;
-
-       /* program spi clock prescaller using max_hz */
-       writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
-       debug("data = 0x%08x\n", data);
-
-       writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
-       writel(KWSPI_IRQMASK, &spireg->irq_mask);
-
-#ifdef CONFIG_KIRKWOOD
-       /* program mpp registers to select  SPI_CSn */
-       kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
-#endif
-
-       return slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-#ifdef CONFIG_KIRKWOOD
-       kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
-#endif
-       free(slave);
-}
-
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-u32 spi_mpp_backup[4];
-#endif
-
-__attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave)
-{
-       return 0;
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       u32 config;
-       u32 spi_mpp_config[4];
-
-       config = CONFIG_SYS_KW_SPI_MPP;
-
-       if (config & MOSI_MPP6)
-               spi_mpp_config[0] = MPP6_SPI_MOSI;
-       else
-               spi_mpp_config[0] = MPP1_SPI_MOSI;
-
-       if (config & SCK_MPP10)
-               spi_mpp_config[1] = MPP10_SPI_SCK;
-       else
-               spi_mpp_config[1] = MPP2_SPI_SCK;
-
-       if (config & MISO_MPP11)
-               spi_mpp_config[2] = MPP11_SPI_MISO;
-       else
-               spi_mpp_config[2] = MPP3_SPI_MISO;
-
-       spi_mpp_config[3] = 0;
-       spi_mpp_backup[3] = 0;
-
-       /* set new spi mpp and save current mpp config */
-       kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
-#endif
-
-       return board_spi_claim_bus(slave);
-}
-
-__attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave)
-{
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       kirkwood_mpp_conf(spi_mpp_backup, NULL);
-#endif
-
-       board_spi_release_bus(slave);
-}
-
-#ifndef CONFIG_SPI_CS_IS_VALID
-/*
- * you can define this function board specific
- * define above CONFIG in board specific config file and
- * provide the function in board specific src file
- */
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-       return bus == 0 && (cs == 0 || cs == 1);
-}
-#endif
-
-void spi_init(void)
-{
-}
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-       _spi_cs_activate(spireg);
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-       _spi_cs_deactivate(spireg);
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
-            const void *dout, void *din, unsigned long flags)
-{
-       return _spi_xfer(spireg, bitlen, dout, din, flags);
-}
-
-#else
-
-/* Here now the DM part */
-
-struct mvebu_spi_dev {
-       bool                    is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_platdata {
-       struct kwspi_registers *spireg;
-       bool is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_priv {
-       struct kwspi_registers *spireg;
-};
-
 static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 {
        struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -329,15 +177,6 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
        return 0;
 }
 
-static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
-                         const void *dout, void *din, unsigned long flags)
-{
-       struct udevice *bus = dev->parent;
-       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
-
-       return _spi_xfer(plat->spireg, bitlen, dout, din, flags);
-}
-
 static int mvebu_spi_claim_bus(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
@@ -351,6 +190,17 @@ static int mvebu_spi_claim_bus(struct udevice *dev)
        return 0;
 }
 

drivers/spi/kirkwood_spi.c static int mvebu_spi_claim_bus(struct udevice *dev) · line 202

Quoted 10 lines
drivers/spi/kirkwood_spi.c +10 -0
+static const struct dm_spi_ops mvebu_spi_ops = {
+       .claim_bus      = mvebu_spi_claim_bus,
+       .xfer           = mvebu_spi_xfer,
+       .set_speed      = mvebu_spi_set_speed,
+       .set_mode       = mvebu_spi_set_mode,
+       /*
+        * cs_info is not needed, since we require all chip selects to be
+        * in the device tree explicitly
+        */
+};

This was already added in commit 9985bdb1cea7 ("spi: kirkwood_spi.c:
Add driver model support").

Quoted 74 lines
drivers/spi/kirkwood_spi.c +5 -2
 static int mvebu_spi_probe(struct udevice *bus)
 {
        struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -363,6 +213,7 @@ static int mvebu_spi_probe(struct udevice *bus)
        return 0;
 }
 
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -421,15 +272,17 @@ static const struct udevice_id mvebu_spi_ids[] = {
        },
        { }
 };
+#endif
 
 U_BOOT_DRIVER(mvebu_spi) = {
        .name = "mvebu_spi",
        .id = UCLASS_SPI,
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
        .of_match = mvebu_spi_ids,
-       .ops = &mvebu_spi_ops,
        .ofdata_to_platdata = mvebu_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct mvebu_spi_platdata),
+#endif
+       .ops = &mvebu_spi_ops,
        .priv_auto_alloc_size = sizeof(struct mvebu_spi_priv),
        .probe = mvebu_spi_probe,
 };
-#endif
drivers/spi/spi.c +3 -1
index ba1d1b082d..5181d5b83f 100644
@@ -39,7 +39,9 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
        return ptr;
 }
 
-#if !defined(CONFIG_DM_SPI) && defined(CONFIG_DAVINCI_SPI)
+#if !defined(CONFIG_DM_SPI) && \
+       defined(CONFIG_DAVINCI_SPI) || \
+       defined(CONFIG_KIRKWOOD_SPI)
 void spi_cs_activate(struct spi_slave *slave)
 {
 }
include/dm/platform_data/spi_kirkwood.h new file +15 -1
new file mode 100644
index 0000000000..ae9b2783a9
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2018 Jagan Teki <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __spi_kirkwood_h
+#define __spi_kirkwood_h
+
+struct mvebu_spi_platdata {
+       struct kwspi_registers *spireg;
+       bool is_errata_50mhz_ac;
+};
+
+#endif /* __spi_kirkwood_h */
--

2.18.0.321.gffc6fa0e3

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

author
#8 lore raw

PATCH 4/34 spi: kirkwood: Full dm conversion

Quoted 329 lines · Chris Packham

Hi Jagan,

Quoted 326 lines · Jagan Teki

kirkwood now support dt along with platform data, respective boards need to switch into dm for the same.

---
 Makefile                                |   2 +-
 drivers/spi/Makefile                    |   2 +-
 drivers/spi/kirkwood_spi.c              | 229 +++++-------------------
 drivers/spi/spi.c                       |   4 +-
 include/dm/platform_data/spi_kirkwood.h |  15 ++
 5 files changed, 61 insertions(+), 191 deletions(-)
 create mode 100644 include/dm/platform_data/spi_kirkwood.h
Makefile +1 -1
index d06cb5c287..214f1bcdbf 100644
@@ -919,7 +919,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
        @echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(CONFIG_DAVINCI_SPI),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI),y),y)
        @echo "===================== WARNING ======================"
        @echo "This board uses SPI driver from drivers/spi/ without"
        @echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index cf5a5cccc0..3c74418992 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -29,7 +30,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/kirkwood_spi.c +25 -186
index 5dd1ad67cf..e9ca95697f 100644
@@ -13,31 +13,41 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/soc.h>
-#ifdef CONFIG_KIRKWOOD
-#include <asm/arch/mpp.h>
-#endif
 #include <asm/arch-mvebu/spi.h>
 
-static void _spi_cs_activate(struct kwspi_registers *reg)
+#include <dm/platform_data/spi_kirkwood.h>
+
+struct mvebu_spi_dev {
+       bool    is_errata_50mhz_ac;
+};
+
+struct mvebu_spi_priv {
+       struct kwspi_registers *spireg;
+};
+
+static void spi_cs_activate(struct kwspi_registers *reg)
 {
        setbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static void _spi_cs_deactivate(struct kwspi_registers *reg)
+static void spi_cs_deactivate(struct kwspi_registers *reg)
 {
        clrbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
-                    const void *dout, void *din, unsigned long flags)
+static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
+                         const void *dout, void *din, unsigned long flags)
 {
+       struct udevice *bus = dev->parent;
+       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+       struct kwspi_registers *reg = plat->spireg;
        unsigned int tmpdout, tmpdin;
        int tm, isread = 0;
 
-       debug("spi_xfer: dout %p din %p bitlen %u\n", dout, din, bitlen);
+       debug("%s: dout %p din %p bitlen %u\n", __func__, dout, din, bitlen);
 
        if (flags & SPI_XFER_BEGIN)
-               _spi_cs_activate(reg);
+               spi_cs_activate(reg);
 
        /*
         * handle data in 8-bit chunks
@@ -55,8 +65,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
 
                clrbits_le32(&reg->irq_cause, KWSPI_SMEMRDIRQ);
                writel(tmpdout, &reg->dout);    /* Write the data out */
-               debug("*** spi_xfer: ... %08x written, bitlen %d\n",
-                     tmpdout, bitlen);
+               debug("%s: ... %08x written, bitlen %d\n",
+                     __func__, tmpdout, bitlen);
 
                /*
                 * Wait for SPI transmit to get out
@@ -67,8 +77,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                        if (readl(&reg->irq_cause) & KWSPI_SMEMRDIRQ) {
                                isread = 1;
                                tmpdin = readl(&reg->din);
-                               debug("spi_xfer: din %p..%08x read\n",
-                                     din, tmpdin);
+                               debug("%s: din %p..%08x read\n",
+                                     __func__, din, tmpdin);
 
                                if (din) {
                                        *((u8 *)din) = (u8)tmpdin;
@@ -82,179 +92,17 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                                break;
                }
                if (tm >= KWSPI_TIMEOUT)
-                       printf("*** spi_xfer: Time out during SPI transfer\n");
+                       printf("%s: Time out during SPI transfer\n", __func__);
 
                debug("loopend bitlen %d\n", bitlen);
        }
 
        if (flags & SPI_XFER_END)
-               _spi_cs_deactivate(reg);
+               spi_cs_deactivate(reg);
 
        return 0;
 }
 
-#ifndef CONFIG_DM_SPI
-
-static struct kwspi_registers *spireg =
-       (struct kwspi_registers *)MVEBU_SPI_BASE;
-
-#ifdef CONFIG_KIRKWOOD
-static u32 cs_spi_mpp_back[2];
-#endif
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-                               unsigned int max_hz, unsigned int mode)
-{
-       struct spi_slave *slave;
-       u32 data;
-#ifdef CONFIG_KIRKWOOD
-       static const u32 kwspi_mpp_config[2][2] = {
-               { MPP0_SPI_SCn, 0 }, /* if cs == 0 */
-               { MPP7_SPI_SCn, 0 } /* if cs != 0 */
-       };
-#endif
-
-       if (!spi_cs_is_valid(bus, cs))
-               return NULL;
-
-       slave = spi_alloc_slave_base(bus, cs);
-       if (!slave)
-               return NULL;
-
-       writel(KWSPI_SMEMRDY, &spireg->ctrl);
-
-       /* calculate spi clock prescaller using max_hz */
-       data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
-       data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data;
-       data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data;
-
-       /* program spi clock prescaller using max_hz */
-       writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
-       debug("data = 0x%08x\n", data);
-
-       writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
-       writel(KWSPI_IRQMASK, &spireg->irq_mask);
-
-#ifdef CONFIG_KIRKWOOD
-       /* program mpp registers to select  SPI_CSn */
-       kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
-#endif
-
-       return slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-#ifdef CONFIG_KIRKWOOD
-       kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
-#endif
-       free(slave);
-}
-
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-u32 spi_mpp_backup[4];
-#endif
-
-__attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave)
-{
-       return 0;
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       u32 config;
-       u32 spi_mpp_config[4];
-
-       config = CONFIG_SYS_KW_SPI_MPP;
-
-       if (config & MOSI_MPP6)
-               spi_mpp_config[0] = MPP6_SPI_MOSI;
-       else
-               spi_mpp_config[0] = MPP1_SPI_MOSI;
-
-       if (config & SCK_MPP10)
-               spi_mpp_config[1] = MPP10_SPI_SCK;
-       else
-               spi_mpp_config[1] = MPP2_SPI_SCK;
-
-       if (config & MISO_MPP11)
-               spi_mpp_config[2] = MPP11_SPI_MISO;
-       else
-               spi_mpp_config[2] = MPP3_SPI_MISO;
-
-       spi_mpp_config[3] = 0;
-       spi_mpp_backup[3] = 0;
-
-       /* set new spi mpp and save current mpp config */
-       kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
-#endif
-
-       return board_spi_claim_bus(slave);
-}
-
-__attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave)
-{
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       kirkwood_mpp_conf(spi_mpp_backup, NULL);
-#endif
-
-       board_spi_release_bus(slave);
-}
-
-#ifndef CONFIG_SPI_CS_IS_VALID
-/*
- * you can define this function board specific
- * define above CONFIG in board specific config file and
- * provide the function in board specific src file
- */
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-       return bus == 0 && (cs == 0 || cs == 1);
-}
-#endif
-
-void spi_init(void)
-{
-}
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-       _spi_cs_activate(spireg);
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-       _spi_cs_deactivate(spireg);
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
-            const void *dout, void *din, unsigned long flags)
-{
-       return _spi_xfer(spireg, bitlen, dout, din, flags);
-}
-
-#else
-
-/* Here now the DM part */
-
-struct mvebu_spi_dev {
-       bool                    is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_platdata {
-       struct kwspi_registers *spireg;
-       bool is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_priv {
-       struct kwspi_registers *spireg;
-};
-
 static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 {
        struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -329,15 +177,6 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
        return 0;
 }
 
-static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
-                         const void *dout, void *din, unsigned long flags)
-{
-       struct udevice *bus = dev->parent;
-       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
-
-       return _spi_xfer(plat->spireg, bitlen, dout, din, flags);
-}
-
 static int mvebu_spi_claim_bus(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
@@ -351,6 +190,17 @@ static int mvebu_spi_claim_bus(struct udevice *dev)
        return 0;
 }
 
Quoted 13 lines

drivers/spi/kirkwood_spi.c static int mvebu_spi_claim_bus(struct udevice *dev) · line 202

Quoted 10 lines
drivers/spi/kirkwood_spi.c +10 -0
+static const struct dm_spi_ops mvebu_spi_ops = {
+       .claim_bus      = mvebu_spi_claim_bus,
+       .xfer           = mvebu_spi_xfer,
+       .set_speed      = mvebu_spi_set_speed,
+       .set_mode       = mvebu_spi_set_mode,
+       /*
+        * cs_info is not needed, since we require all chip selects to be
+        * in the device tree explicitly
+        */
+};

This was already added in commit 9985bdb1cea7 ("spi: kirkwood_spi.c:
Add driver model support").

But this one is full conversion with platdata, no non-dm code.

#9 lore raw

PATCH 4/34 spi: kirkwood: Full dm conversion

Quoted 345 lines · Jagan Teki
Quoted 329 lines · Chris Packham

Hi Jagan,

Quoted 326 lines · Jagan Teki

kirkwood now support dt along with platform data, respective boards need to switch into dm for the same.

---
 Makefile                                |   2 +-
 drivers/spi/Makefile                    |   2 +-
 drivers/spi/kirkwood_spi.c              | 229 +++++-------------------
 drivers/spi/spi.c                       |   4 +-
 include/dm/platform_data/spi_kirkwood.h |  15 ++
 5 files changed, 61 insertions(+), 191 deletions(-)
 create mode 100644 include/dm/platform_data/spi_kirkwood.h
Makefile +1 -1
index d06cb5c287..214f1bcdbf 100644
@@ -919,7 +919,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
        @echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(CONFIG_DAVINCI_SPI),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI),y),y)
        @echo "===================== WARNING ======================"
        @echo "This board uses SPI driver from drivers/spi/ without"
        @echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index cf5a5cccc0..3c74418992 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -29,7 +30,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/kirkwood_spi.c +25 -186
index 5dd1ad67cf..e9ca95697f 100644
@@ -13,31 +13,41 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/soc.h>
-#ifdef CONFIG_KIRKWOOD
-#include <asm/arch/mpp.h>
-#endif
 #include <asm/arch-mvebu/spi.h>
 
-static void _spi_cs_activate(struct kwspi_registers *reg)
+#include <dm/platform_data/spi_kirkwood.h>
+
+struct mvebu_spi_dev {
+       bool    is_errata_50mhz_ac;
+};
+
+struct mvebu_spi_priv {
+       struct kwspi_registers *spireg;
+};
+
+static void spi_cs_activate(struct kwspi_registers *reg)
 {
        setbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static void _spi_cs_deactivate(struct kwspi_registers *reg)
+static void spi_cs_deactivate(struct kwspi_registers *reg)
 {
        clrbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
-                    const void *dout, void *din, unsigned long flags)
+static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
+                         const void *dout, void *din, unsigned long flags)
 {
+       struct udevice *bus = dev->parent;
+       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+       struct kwspi_registers *reg = plat->spireg;
        unsigned int tmpdout, tmpdin;
        int tm, isread = 0;
 
-       debug("spi_xfer: dout %p din %p bitlen %u\n", dout, din, bitlen);
+       debug("%s: dout %p din %p bitlen %u\n", __func__, dout, din, bitlen);
 
        if (flags & SPI_XFER_BEGIN)
-               _spi_cs_activate(reg);
+               spi_cs_activate(reg);
 
        /*
         * handle data in 8-bit chunks
@@ -55,8 +65,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
 
                clrbits_le32(&reg->irq_cause, KWSPI_SMEMRDIRQ);
                writel(tmpdout, &reg->dout);    /* Write the data out */
-               debug("*** spi_xfer: ... %08x written, bitlen %d\n",
-                     tmpdout, bitlen);
+               debug("%s: ... %08x written, bitlen %d\n",
+                     __func__, tmpdout, bitlen);
 
                /*
                 * Wait for SPI transmit to get out
@@ -67,8 +77,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                        if (readl(&reg->irq_cause) & KWSPI_SMEMRDIRQ) {
                                isread = 1;
                                tmpdin = readl(&reg->din);
-                               debug("spi_xfer: din %p..%08x read\n",
-                                     din, tmpdin);
+                               debug("%s: din %p..%08x read\n",
+                                     __func__, din, tmpdin);
 
                                if (din) {
                                        *((u8 *)din) = (u8)tmpdin;
@@ -82,179 +92,17 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                                break;
                }
                if (tm >= KWSPI_TIMEOUT)
-                       printf("*** spi_xfer: Time out during SPI transfer\n");
+                       printf("%s: Time out during SPI transfer\n", __func__);
 
                debug("loopend bitlen %d\n", bitlen);
        }
 
        if (flags & SPI_XFER_END)
-               _spi_cs_deactivate(reg);
+               spi_cs_deactivate(reg);
 
        return 0;
 }
 
-#ifndef CONFIG_DM_SPI
-
-static struct kwspi_registers *spireg =
-       (struct kwspi_registers *)MVEBU_SPI_BASE;
-
-#ifdef CONFIG_KIRKWOOD
-static u32 cs_spi_mpp_back[2];
-#endif
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-                               unsigned int max_hz, unsigned int mode)
-{
-       struct spi_slave *slave;
-       u32 data;
-#ifdef CONFIG_KIRKWOOD
-       static const u32 kwspi_mpp_config[2][2] = {
-               { MPP0_SPI_SCn, 0 }, /* if cs == 0 */
-               { MPP7_SPI_SCn, 0 } /* if cs != 0 */
-       };
-#endif
-
-       if (!spi_cs_is_valid(bus, cs))
-               return NULL;
-
-       slave = spi_alloc_slave_base(bus, cs);
-       if (!slave)
-               return NULL;
-
-       writel(KWSPI_SMEMRDY, &spireg->ctrl);
-
-       /* calculate spi clock prescaller using max_hz */
-       data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
-       data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data;
-       data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data;
-
-       /* program spi clock prescaller using max_hz */
-       writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
-       debug("data = 0x%08x\n", data);
-
-       writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
-       writel(KWSPI_IRQMASK, &spireg->irq_mask);
-
-#ifdef CONFIG_KIRKWOOD
-       /* program mpp registers to select  SPI_CSn */
-       kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
-#endif
-
-       return slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-#ifdef CONFIG_KIRKWOOD
-       kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
-#endif
-       free(slave);
-}
-
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-u32 spi_mpp_backup[4];
-#endif
-
-__attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave)
-{
-       return 0;
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       u32 config;
-       u32 spi_mpp_config[4];
-
-       config = CONFIG_SYS_KW_SPI_MPP;
-
-       if (config & MOSI_MPP6)
-               spi_mpp_config[0] = MPP6_SPI_MOSI;
-       else
-               spi_mpp_config[0] = MPP1_SPI_MOSI;
-
-       if (config & SCK_MPP10)
-               spi_mpp_config[1] = MPP10_SPI_SCK;
-       else
-               spi_mpp_config[1] = MPP2_SPI_SCK;
-
-       if (config & MISO_MPP11)
-               spi_mpp_config[2] = MPP11_SPI_MISO;
-       else
-               spi_mpp_config[2] = MPP3_SPI_MISO;
-
-       spi_mpp_config[3] = 0;
-       spi_mpp_backup[3] = 0;
-
-       /* set new spi mpp and save current mpp config */
-       kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
-#endif
-
-       return board_spi_claim_bus(slave);
-}
-
-__attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave)
-{
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       kirkwood_mpp_conf(spi_mpp_backup, NULL);
-#endif
-
-       board_spi_release_bus(slave);
-}
-
-#ifndef CONFIG_SPI_CS_IS_VALID
-/*
- * you can define this function board specific
- * define above CONFIG in board specific config file and
- * provide the function in board specific src file
- */
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-       return bus == 0 && (cs == 0 || cs == 1);
-}
-#endif
-
-void spi_init(void)
-{
-}
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-       _spi_cs_activate(spireg);
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-       _spi_cs_deactivate(spireg);
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
-            const void *dout, void *din, unsigned long flags)
-{
-       return _spi_xfer(spireg, bitlen, dout, din, flags);
-}
-
-#else
-
-/* Here now the DM part */
-
-struct mvebu_spi_dev {
-       bool                    is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_platdata {
-       struct kwspi_registers *spireg;
-       bool is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_priv {
-       struct kwspi_registers *spireg;
-};
-
 static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 {
        struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -329,15 +177,6 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
        return 0;
 }
 
-static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
-                         const void *dout, void *din, unsigned long flags)
-{
-       struct udevice *bus = dev->parent;
-       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
-
-       return _spi_xfer(plat->spireg, bitlen, dout, din, flags);
-}
-
 static int mvebu_spi_claim_bus(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
@@ -351,6 +190,17 @@ static int mvebu_spi_claim_bus(struct udevice *dev)
        return 0;
 }
 
Quoted 13 lines

drivers/spi/kirkwood_spi.c static int mvebu_spi_claim_bus(struct udevice *dev) · line 202

Quoted 10 lines
drivers/spi/kirkwood_spi.c +10 -0
+static const struct dm_spi_ops mvebu_spi_ops = {
+       .claim_bus      = mvebu_spi_claim_bus,
+       .xfer           = mvebu_spi_xfer,
+       .set_speed      = mvebu_spi_set_speed,
+       .set_mode       = mvebu_spi_set_mode,
+       /*
+        * cs_info is not needed, since we require all chip selects to be
+        * in the device tree explicitly
+        */
+};

This was already added in commit 9985bdb1cea7 ("spi: kirkwood_spi.c:
Add driver model support").

Quoted 1 line

But this one is full conversion with platdata, no non-dm code.

Sorry should have trimmed the response.

I was just referring to the addtion of mvebu_spi_ops. The removal of the rest of the code is fine but there is still a compile error because mvebu_spi_ops is defined twice.

author
#10 lore raw

PATCH 4/34 spi: kirkwood: Full dm conversion

Quoted 347 lines · Chris Packham
Quoted 345 lines · Jagan Teki
Quoted 342 lines · Chris Packham

Hi Jagan,

Quoted 326 lines · Jagan Teki

kirkwood now support dt along with platform data, respective boards need to switch into dm for the same.

---
 Makefile                                |   2 +-
 drivers/spi/Makefile                    |   2 +-
 drivers/spi/kirkwood_spi.c              | 229 +++++-------------------
 drivers/spi/spi.c                       |   4 +-
 include/dm/platform_data/spi_kirkwood.h |  15 ++
 5 files changed, 61 insertions(+), 191 deletions(-)
 create mode 100644 include/dm/platform_data/spi_kirkwood.h
Makefile +1 -1
index d06cb5c287..214f1bcdbf 100644
@@ -919,7 +919,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
        @echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(CONFIG_DAVINCI_SPI),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI),y),y)
        @echo "===================== WARNING ======================"
        @echo "This board uses SPI driver from drivers/spi/ without"
        @echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index cf5a5cccc0..3c74418992 100644
@@ -7,6 +7,7 @@
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -29,7 +30,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
drivers/spi/kirkwood_spi.c +25 -186
index 5dd1ad67cf..e9ca95697f 100644
@@ -13,31 +13,41 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/soc.h>
-#ifdef CONFIG_KIRKWOOD
-#include <asm/arch/mpp.h>
-#endif
 #include <asm/arch-mvebu/spi.h>
 
-static void _spi_cs_activate(struct kwspi_registers *reg)
+#include <dm/platform_data/spi_kirkwood.h>
+
+struct mvebu_spi_dev {
+       bool    is_errata_50mhz_ac;
+};
+
+struct mvebu_spi_priv {
+       struct kwspi_registers *spireg;
+};
+
+static void spi_cs_activate(struct kwspi_registers *reg)
 {
        setbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static void _spi_cs_deactivate(struct kwspi_registers *reg)
+static void spi_cs_deactivate(struct kwspi_registers *reg)
 {
        clrbits_le32(&reg->ctrl, KWSPI_CSN_ACT);
 }
 
-static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
-                    const void *dout, void *din, unsigned long flags)
+static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
+                         const void *dout, void *din, unsigned long flags)
 {
+       struct udevice *bus = dev->parent;
+       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
+       struct kwspi_registers *reg = plat->spireg;
        unsigned int tmpdout, tmpdin;
        int tm, isread = 0;
 
-       debug("spi_xfer: dout %p din %p bitlen %u\n", dout, din, bitlen);
+       debug("%s: dout %p din %p bitlen %u\n", __func__, dout, din, bitlen);
 
        if (flags & SPI_XFER_BEGIN)
-               _spi_cs_activate(reg);
+               spi_cs_activate(reg);
 
        /*
         * handle data in 8-bit chunks
@@ -55,8 +65,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
 
                clrbits_le32(&reg->irq_cause, KWSPI_SMEMRDIRQ);
                writel(tmpdout, &reg->dout);    /* Write the data out */
-               debug("*** spi_xfer: ... %08x written, bitlen %d\n",
-                     tmpdout, bitlen);
+               debug("%s: ... %08x written, bitlen %d\n",
+                     __func__, tmpdout, bitlen);
 
                /*
                 * Wait for SPI transmit to get out
@@ -67,8 +77,8 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                        if (readl(&reg->irq_cause) & KWSPI_SMEMRDIRQ) {
                                isread = 1;
                                tmpdin = readl(&reg->din);
-                               debug("spi_xfer: din %p..%08x read\n",
-                                     din, tmpdin);
+                               debug("%s: din %p..%08x read\n",
+                                     __func__, din, tmpdin);
 
                                if (din) {
                                        *((u8 *)din) = (u8)tmpdin;
@@ -82,179 +92,17 @@ static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen,
                                break;
                }
                if (tm >= KWSPI_TIMEOUT)
-                       printf("*** spi_xfer: Time out during SPI transfer\n");
+                       printf("%s: Time out during SPI transfer\n", __func__);
 
                debug("loopend bitlen %d\n", bitlen);
        }
 
        if (flags & SPI_XFER_END)
-               _spi_cs_deactivate(reg);
+               spi_cs_deactivate(reg);
 
        return 0;
 }
 
-#ifndef CONFIG_DM_SPI
-
-static struct kwspi_registers *spireg =
-       (struct kwspi_registers *)MVEBU_SPI_BASE;
-
-#ifdef CONFIG_KIRKWOOD
-static u32 cs_spi_mpp_back[2];
-#endif
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-                               unsigned int max_hz, unsigned int mode)
-{
-       struct spi_slave *slave;
-       u32 data;
-#ifdef CONFIG_KIRKWOOD
-       static const u32 kwspi_mpp_config[2][2] = {
-               { MPP0_SPI_SCn, 0 }, /* if cs == 0 */
-               { MPP7_SPI_SCn, 0 } /* if cs != 0 */
-       };
-#endif
-
-       if (!spi_cs_is_valid(bus, cs))
-               return NULL;
-
-       slave = spi_alloc_slave_base(bus, cs);
-       if (!slave)
-               return NULL;
-
-       writel(KWSPI_SMEMRDY, &spireg->ctrl);
-
-       /* calculate spi clock prescaller using max_hz */
-       data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
-       data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data;
-       data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data;
-
-       /* program spi clock prescaller using max_hz */
-       writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
-       debug("data = 0x%08x\n", data);
-
-       writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
-       writel(KWSPI_IRQMASK, &spireg->irq_mask);
-
-#ifdef CONFIG_KIRKWOOD
-       /* program mpp registers to select  SPI_CSn */
-       kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
-#endif
-
-       return slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-#ifdef CONFIG_KIRKWOOD
-       kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
-#endif
-       free(slave);
-}
-
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-u32 spi_mpp_backup[4];
-#endif
-
-__attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave)
-{
-       return 0;
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       u32 config;
-       u32 spi_mpp_config[4];
-
-       config = CONFIG_SYS_KW_SPI_MPP;
-
-       if (config & MOSI_MPP6)
-               spi_mpp_config[0] = MPP6_SPI_MOSI;
-       else
-               spi_mpp_config[0] = MPP1_SPI_MOSI;
-
-       if (config & SCK_MPP10)
-               spi_mpp_config[1] = MPP10_SPI_SCK;
-       else
-               spi_mpp_config[1] = MPP2_SPI_SCK;
-
-       if (config & MISO_MPP11)
-               spi_mpp_config[2] = MPP11_SPI_MISO;
-       else
-               spi_mpp_config[2] = MPP3_SPI_MISO;
-
-       spi_mpp_config[3] = 0;
-       spi_mpp_backup[3] = 0;
-
-       /* set new spi mpp and save current mpp config */
-       kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
-#endif
-
-       return board_spi_claim_bus(slave);
-}
-
-__attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave)
-{
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-#if defined(CONFIG_SYS_KW_SPI_MPP)
-       kirkwood_mpp_conf(spi_mpp_backup, NULL);
-#endif
-
-       board_spi_release_bus(slave);
-}
-
-#ifndef CONFIG_SPI_CS_IS_VALID
-/*
- * you can define this function board specific
- * define above CONFIG in board specific config file and
- * provide the function in board specific src file
- */
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-       return bus == 0 && (cs == 0 || cs == 1);
-}
-#endif
-
-void spi_init(void)
-{
-}
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-       _spi_cs_activate(spireg);
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-       _spi_cs_deactivate(spireg);
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
-            const void *dout, void *din, unsigned long flags)
-{
-       return _spi_xfer(spireg, bitlen, dout, din, flags);
-}
-
-#else
-
-/* Here now the DM part */
-
-struct mvebu_spi_dev {
-       bool                    is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_platdata {
-       struct kwspi_registers *spireg;
-       bool is_errata_50mhz_ac;
-};
-
-struct mvebu_spi_priv {
-       struct kwspi_registers *spireg;
-};
-
 static int mvebu_spi_set_speed(struct udevice *bus, uint hz)
 {
        struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
@@ -329,15 +177,6 @@ static int mvebu_spi_set_mode(struct udevice *bus, uint mode)
        return 0;
 }
 
-static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
-                         const void *dout, void *din, unsigned long flags)
-{
-       struct udevice *bus = dev->parent;
-       struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
-
-       return _spi_xfer(plat->spireg, bitlen, dout, din, flags);
-}
-
 static int mvebu_spi_claim_bus(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
@@ -351,6 +190,17 @@ static int mvebu_spi_claim_bus(struct udevice *dev)
        return 0;
 }
 

drivers/spi/kirkwood_spi.c static int mvebu_spi_claim_bus(struct udevice *dev) · line 202

Quoted 10 lines
drivers/spi/kirkwood_spi.c +10 -0
+static const struct dm_spi_ops mvebu_spi_ops = {
+       .claim_bus      = mvebu_spi_claim_bus,
+       .xfer           = mvebu_spi_xfer,
+       .set_speed      = mvebu_spi_set_speed,
+       .set_mode       = mvebu_spi_set_mode,
+       /*
+        * cs_info is not needed, since we require all chip selects to be
+        * in the device tree explicitly
+        */
+};

This was already added in commit 9985bdb1cea7 ("spi: kirkwood_spi.c:
Add driver model support").

Quoted 7 lines
Quoted 1 line

But this one is full conversion with platdata, no non-dm code.

Sorry should have trimmed the response.

I was just referring to the addtion of mvebu_spi_ops. The removal of the rest of the code is fine but there is still a compile error because mvebu_spi_ops is defined twice.

Yes, saw that twise defined will fix in v2.

author
#11 lore raw

PATCH 5/34 spi: ti_qspi: Full dm conversion

In reply to Jagan Teki

ti_qspi now support dt along with platform data, respective boards need to switch into dm for the same.

Cc Tom Rini <[email protected]>
Cc Vitaly Andrianov <[email protected]>
Cc Peter Howard <[email protected]>
---
 Makefile                               |   2 +-
 drivers/spi/Makefile                   |   2 +-
 drivers/spi/spi.c                      |   3 +-
 drivers/spi/ti_qspi.c                  | 490 +++++++++----------------
 include/dm/platform_data/spi_ti_qspi.h |  19 +
 5 files changed, 200 insertions(+), 316 deletions(-)
 create mode 100644 include/dm/platform_data/spi_ti_qspi.h
Makefile +1 -1
index 214f1bcdbf..efa68e7343 100644
@@ -919,7 +919,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 	@echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI),y),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) $(CONFIG_TI_QSPI),y),y)
 	@echo "===================== WARNING ======================"
 	@echo "This board uses SPI driver from drivers/spi/ without"
 	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index 3c74418992..748d9a90ab 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
+obj-$(CONFIG_TI_QSPI) += ti_qspi.o
 else
 obj-y += spi.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi_legacy.o
@@ -52,7 +53,6 @@ obj-$(CONFIG_TEGRA114_SPI) += tegra114_spi.o
 obj-$(CONFIG_TEGRA20_SFLASH) += tegra20_sflash.o
 obj-$(CONFIG_TEGRA20_SLINK) += tegra20_slink.o
 obj-$(CONFIG_TEGRA210_QSPI) += tegra210_qspi.o
-obj-$(CONFIG_TI_QSPI) += ti_qspi.o
 obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o
 obj-$(CONFIG_ZYNQ_SPI) += zynq_spi.o
 obj-$(CONFIG_ZYNQ_QSPI) += zynq_qspi.o
drivers/spi/spi.c +2 -1
index 5181d5b83f..500853fc95 100644
@@ -41,7 +41,8 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 
 #if !defined(CONFIG_DM_SPI) && \
 	defined(CONFIG_DAVINCI_SPI) || \
-	defined(CONFIG_KIRKWOOD_SPI)
+	defined(CONFIG_KIRKWOOD_SPI) || \
+	defined(CONFIG_TI_QSPI)
 void spi_cs_activate(struct spi_slave *slave)
 {
 }
drivers/spi/ti_qspi.c +177 -313

658 lines not on this page · raw message

include/dm/platform_data/spi_ti_qspi.h new file +19 -0
new file mode 100644
index 0000000000..3f5355284e
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2018 Jagan Teki <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __spi_ti_qspi_h
+#define __spi_ti_qspi_h
+
+struct ti_qspi_platdata {
+	struct ti_qspi_regs *base;
+	void *ctrl_mod_mmap;
+	ulong fclk;
+	void *memory_map;
+	uint max_hz;
+	u32 num_cs;
+};
+
+#endif /* __spi_ti_qspi_h */
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#12 lore raw

PATCH 6/34 spi: mpc8xxx: Use short type names

In reply to Jagan Teki

From: Mario Six <[email protected]>

The function signatures in the driver are quite long as is. Use short type names (uint etc.) to make them more readable.

---
 drivers/spi/mpc8xxx_spi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/mpc8xxx_spi.c +5 -7
index 8d6d86d2b0..0c77f95159 100644
@@ -20,8 +20,7 @@
 
 #define SPI_TIMEOUT	1000
 
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-		unsigned int max_hz, unsigned int mode)
+struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode)
 {
 	struct spi_slave *slave;
 
@@ -68,17 +67,16 @@ int spi_claim_bus(struct spi_slave *slave)
 
 void spi_release_bus(struct spi_slave *slave)
 {
-
 }
 
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
-		void *din, unsigned long flags)
+int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
+	     ulong flags)
 {
 	volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
-	unsigned int tmpdout, tmpdin, event;
+	uint tmpdout, tmpdin, event;
 	int numBlks = DIV_ROUND_UP(bitlen, 32);
 	int tm, isRead = 0;
-	unsigned char charSize = 32;
+	uchar charSize = 32;
 
 	debug("spi_xfer: slave %u:%u dout %08X din %08X bitlen %u\n",
 	      slave->bus, slave->cs, *(uint *) dout, *(uint *) din, bitlen);
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#13 lore raw

PATCH 7/34 spi: mpc8xxx: Fix comments

In reply to Jagan Teki

From: Mario Six <[email protected]>

There are some comments on the same line as the code they document. Put comments above the code lines they document, so the line length is not unnecessarily increased.

---
 drivers/spi/mpc8xxx_spi.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/spi/mpc8xxx_spi.c +14 -8
index 0c77f95159..3016cfe2ca 100644
@@ -53,11 +53,14 @@ void spi_init(void)
 	 * some registers
 	 */
 	spi->mode = SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN;
-	spi->mode = (spi->mode & 0xfff0ffff) | BIT(16); /* Use SYSCLK / 8
-							     (16.67MHz typ.) */
-	spi->event = 0xffffffff;	/* Clear all SPI events */
-	spi->mask = 0x00000000;	/* Mask  all SPI interrupts */
-	spi->com = 0;		/* LST bit doesn't do anything, so disregard */
+	/* Use SYSCLK / 8 (16.67MHz typ.) */
+	spi->mode = (spi->mode & 0xfff0ffff) | BIT(16);
+	/* Clear all SPI events */
+	spi->event = 0xffffffff;
+	/* Mask  all SPI interrupts */
+	spi->mask = 0x00000000;
+	/* LST bit doesn't do anything, so disregard */
+	spi->com = 0;
 }
 
 int spi_claim_bus(struct spi_slave *slave)
@@ -84,9 +87,10 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	if (flags & SPI_XFER_BEGIN)
 		spi_cs_activate(slave);
 
-	spi->event = 0xffffffff;	/* Clear all SPI events */
+	/* Clear all SPI events */
+	spi->event = 0xffffffff;
 
-	/* handle data in 32-bit chunks */
+	/* Handle data in 32-bit chunks */
 	while (numBlks--) {
 		tmpdout = 0;
 		charSize = (bitlen >= 32 ? 32 : bitlen);
@@ -120,7 +124,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 
 		spi->mode |= SPI_MODE_EN;
 
-		spi->tx = tmpdout;	/* Write the data out */
+		/* Write the data out */
+		spi->tx = tmpdout;
+
 		debug("*** spi_xfer: ... %08x written\n", tmpdout);
 
 		/*
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#14 lore raw

PATCH 8/34 spi: mpc8xxx: Rename camel-case variables

In reply to Jagan Teki

From: Mario Six <[email protected]>

There are three variables that have camel-case names, which is not the preferred naming style.

Give those variables more compliant names instead.

---
 drivers/spi/mpc8xxx_spi.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/spi/mpc8xxx_spi.c +11 -11
index 3016cfe2ca..0393765b6f 100644
@@ -77,9 +77,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 {
 	volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
 	uint tmpdout, tmpdin, event;
-	int numBlks = DIV_ROUND_UP(bitlen, 32);
-	int tm, isRead = 0;
-	uchar charSize = 32;
+	int num_blks = DIV_ROUND_UP(bitlen, 32);
+	int tm, is_read = 0;
+	uchar char_size = 32;
 
 	debug("spi_xfer: slave %u:%u dout %08X din %08X bitlen %u\n",
 	      slave->bus, slave->cs, *(uint *) dout, *(uint *) din, bitlen);
@@ -91,12 +91,12 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	spi->event = 0xffffffff;
 
 	/* Handle data in 32-bit chunks */
-	while (numBlks--) {
+	while (num_blks--) {
 		tmpdout = 0;
-		charSize = (bitlen >= 32 ? 32 : bitlen);
+		char_size = (bitlen >= 32 ? 32 : bitlen);
 
 		/* Shift data so it's msb-justified */
-		tmpdout = *(u32 *) dout >> (32 - charSize);
+		tmpdout = *(u32 *) dout >> (32 - char_size);
 
 		/* The LEN field of the SPMODE register is set as follows:
 		 *
@@ -134,15 +134,15 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * or time out (1 second = 1000 ms)
 		 * The NE event must be read and cleared first
 		 */
-		for (tm = 0, isRead = 0; tm < SPI_TIMEOUT; ++tm) {
+		for (tm = 0, is_read = 0; tm < SPI_TIMEOUT; ++tm) {
 			event = spi->event;
 			if (event & SPI_EV_NE) {
 				tmpdin = spi->rx;
 				spi->event |= SPI_EV_NE;
-				isRead = 1;
+				is_read = 1;
 
-				*(u32 *) din = (tmpdin << (32 - charSize));
-				if (charSize == 32) {
+				*(u32 *) din = (tmpdin << (32 - char_size));
+				if (char_size == 32) {
 					/* Advance output buffer by 32 bits */
 					din += 4;
 				}
@@ -153,7 +153,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 			 * in the future put an arbitrary delay after writing
 			 * the device.  Arbitrary delays suck, though...
 			 */
-			if (isRead && (event & SPI_EV_NF))
+			if (is_read && (event & SPI_EV_NF))
 				break;
 		}
 		if (tm >= SPI_TIMEOUT)
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#15 lore raw

PATCH 9/34 spi: mpc8xxx: Fix space after cast

In reply to Jagan Teki

From: Mario Six <[email protected]>

Fix all "superfluous space after case" style errors.

---
 drivers/spi/mpc8xxx_spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/mpc8xxx_spi.c +3 -3
index 0393765b6f..1424e7febe 100644
@@ -82,7 +82,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	uchar char_size = 32;
 
 	debug("spi_xfer: slave %u:%u dout %08X din %08X bitlen %u\n",
-	      slave->bus, slave->cs, *(uint *) dout, *(uint *) din, bitlen);
+	      slave->bus, slave->cs, *(uint *)dout, *(uint *)din, bitlen);
 
 	if (flags & SPI_XFER_BEGIN)
 		spi_cs_activate(slave);
@@ -96,7 +96,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		char_size = (bitlen >= 32 ? 32 : bitlen);
 
 		/* Shift data so it's msb-justified */
-		tmpdout = *(u32 *) dout >> (32 - char_size);
+		tmpdout = *(u32 *)dout >> (32 - char_size);
 
 		/* The LEN field of the SPMODE register is set as follows:
 		 *
@@ -141,7 +141,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 				spi->event |= SPI_EV_NE;
 				is_read = 1;
 
-				*(u32 *) din = (tmpdin << (32 - char_size));
+				*(u32 *)din = (tmpdin << (32 - char_size));
 				if (char_size == 32) {
 					/* Advance output buffer by 32 bits */
 					din += 4;
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#16 lore raw

PATCH 10/34 spi: mpc8xxx: Fix function names in strings

In reply to Jagan Teki

From: Mario Six <[email protected]>

Replace the function name with a "%s" format string and the __func__ variable in debug statements (as proposed by checkpatch).

---
 drivers/spi/mpc8xxx_spi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/spi/mpc8xxx_spi.c +5 -4
index 1424e7febe..91b639f1e6 100644
@@ -81,7 +81,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	int tm, is_read = 0;
 	uchar char_size = 32;
 
-	debug("spi_xfer: slave %u:%u dout %08X din %08X bitlen %u\n",
+	debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__,
 	      slave->bus, slave->cs, *(uint *)dout, *(uint *)din, bitlen);
 
 	if (flags & SPI_XFER_BEGIN)
@@ -127,7 +127,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		/* Write the data out */
 		spi->tx = tmpdout;
 
-		debug("*** spi_xfer: ... %08x written\n", tmpdout);
+		debug("*** %s: ... %08x written\n", __func__, tmpdout);
 
 		/*
 		 * Wait for SPI transmit to get out
@@ -157,9 +157,10 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 				break;
 		}
 		if (tm >= SPI_TIMEOUT)
-			puts("*** spi_xfer: Time out during SPI transfer");
+			debug("*** %s: Time out during SPI transfer\n",
+			      __func__);
 
-		debug("*** spi_xfer: transfer ended. Value=%08x\n", tmpdin);
+		debug("*** %s: transfer ended. Value=%08x\n", __func__, tmpdin);
 	}
 
 	if (flags & SPI_XFER_END)
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#17 lore raw

PATCH 11/34 spi: mpc8xxx: Replace defines with enums

In reply to Jagan Teki

From: Mario Six <[email protected]>

Replace pre-processor defines with proper enums, and use the BIT macro where applicable.

---
 drivers/spi/mpc8xxx_spi.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/spi/mpc8xxx_spi.c +19 -7
index 91b639f1e6..7b2ab1e4af 100644
@@ -10,13 +10,25 @@
 #include <spi.h>
 #include <asm/mpc8xxx_spi.h>
 
-#define SPI_EV_NE	(0x80000000 >> 22)	/* Receiver Not Empty */
-#define SPI_EV_NF	(0x80000000 >> 23)	/* Transmitter Not Full */
-
-#define SPI_MODE_LOOP	(0x80000000 >> 1)	/* Loopback mode */
-#define SPI_MODE_REV	(0x80000000 >> 5)	/* Reverse mode - MSB first */
-#define SPI_MODE_MS	(0x80000000 >> 6)	/* Always master */
-#define SPI_MODE_EN	(0x80000000 >> 7)	/* Enable interface */
+enum {
+	SPI_EV_NE = BIT(31 - 22),	/* Receiver Not Empty */
+	SPI_EV_NF = BIT(31 - 23),	/* Transmitter Not Full */
+};
+
+enum {
+	SPI_MODE_LOOP  = BIT(31 - 1),	/* Loopback mode */
+	SPI_MODE_CI    = BIT(31 - 2),	/* Clock invert */
+	SPI_MODE_CP    = BIT(31 - 3),	/* Clock phase */
+	SPI_MODE_DIV16 = BIT(31 - 4),	/* Divide clock source by 16 */
+	SPI_MODE_REV   = BIT(31 - 5),	/* Reverse mode - MSB first */
+	SPI_MODE_MS    = BIT(31 - 6),	/* Always master */
+	SPI_MODE_EN    = BIT(31 - 7),	/* Enable interface */
+
+	SPI_MODE_LEN_MASK = 0xf00000,
+	SPI_MODE_PM_MASK = 0xf0000,
+
+	SPI_COM_LST = BIT(31 - 9),
+};
 
 #define SPI_TIMEOUT	1000
 
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#18 lore raw

PATCH 12/34 spi: mpc8xxx: Use IO accessors

In reply to Jagan Teki

From: Mario Six <[email protected]>

Accesses to the register map are currently done by directly reading and writing the structure.

Switch to the appropriate IO accessors instead.

---
 drivers/spi/mpc8xxx_spi.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/spi/mpc8xxx_spi.c +19 -19
index 7b2ab1e4af..da9e1e3f98 100644
@@ -58,21 +58,21 @@ void spi_free_slave(struct spi_slave *slave)
 
 void spi_init(void)
 {
-	volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
+	spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
 
 	/*
 	 * SPI pins on the MPC83xx are not muxed, so all we do is initialize
 	 * some registers
 	 */
-	spi->mode = SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN;
+	out_be32(&spi->mode, SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN);
 	/* Use SYSCLK / 8 (16.67MHz typ.) */
-	spi->mode = (spi->mode & 0xfff0ffff) | BIT(16);
+	clrsetbits_be32(&spi->mode, 0x000f0000, BIT(16));
 	/* Clear all SPI events */
-	spi->event = 0xffffffff;
+	setbits_be32(&spi->event, 0xffffffff);
 	/* Mask  all SPI interrupts */
-	spi->mask = 0x00000000;
+	clrbits_be32(&spi->mask, 0xffffffff);
 	/* LST bit doesn't do anything, so disregard */
-	spi->com = 0;
+	out_be32(&spi->com, 0);
 }
 
 int spi_claim_bus(struct spi_slave *slave)
@@ -87,7 +87,7 @@ void spi_release_bus(struct spi_slave *slave)
 int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	     ulong flags)
 {
-	volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi;
+	spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
 	uint tmpdout, tmpdin, event;
 	int num_blks = DIV_ROUND_UP(bitlen, 32);
 	int tm, is_read = 0;
@@ -100,7 +100,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		spi_cs_activate(slave);
 
 	/* Clear all SPI events */
-	spi->event = 0xffffffff;
+	setbits_be32(&spi->event, 0xffffffff);
 
 	/* Handle data in 32-bit chunks */
 	while (num_blks--) {
@@ -118,26 +118,26 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * len > 16               0
 		 */
 
-		spi->mode &= ~SPI_MODE_EN;
+		clrbits_be32(&spi->mode, SPI_MODE_EN);
 
 		if (bitlen <= 16) {
 			if (bitlen <= 4)
-				spi->mode = (spi->mode & 0xff0fffff) |
-					    (3 << 20);
+				clrsetbits_be32(&spi->mode, 0x00f00000,
+						(3 << 20));
 			else
-				spi->mode = (spi->mode & 0xff0fffff) |
-					    ((bitlen - 1) << 20);
+				clrsetbits_be32(&spi->mode, 0x00f00000,
+						((bitlen - 1) << 20));
 		} else {
-			spi->mode = (spi->mode & 0xff0fffff);
+			clrbits_be32(&spi->mode, 0x00f00000);
 			/* Set up the next iteration if sending > 32 bits */
 			bitlen -= 32;
 			dout += 4;
 		}
 
-		spi->mode |= SPI_MODE_EN;
+		setbits_be32(&spi->mode, SPI_MODE_EN);
 
 		/* Write the data out */
-		spi->tx = tmpdout;
+		out_be32(&spi->tx, tmpdout);
 
 		debug("*** %s: ... %08x written\n", __func__, tmpdout);
 
@@ -147,10 +147,10 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * The NE event must be read and cleared first
 		 */
 		for (tm = 0, is_read = 0; tm < SPI_TIMEOUT; ++tm) {
-			event = spi->event;
+			event = in_be32(&spi->event);
 			if (event & SPI_EV_NE) {
-				tmpdin = spi->rx;
-				spi->event |= SPI_EV_NE;
+				tmpdin = in_be32(&spi->rx);
+				setbits_be32(&spi->event, SPI_EV_NE);
 				is_read = 1;
 
 				*(u32 *)din = (tmpdin << (32 - char_size));
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#19 lore raw

PATCH 13/34 spi: mpc8xxx: Simplify if

In reply to Jagan Teki

From: Mario Six <[email protected]>

Instead of having a nested if block, just have two branches within the overarching if block to eliminate one nesting level.

---
 drivers/spi/mpc8xxx_spi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/mpc8xxx_spi.c +5 -7
index da9e1e3f98..ca34570901 100644
@@ -120,13 +120,11 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 
 		clrbits_be32(&spi->mode, SPI_MODE_EN);
 
-		if (bitlen <= 16) {
-			if (bitlen <= 4)
-				clrsetbits_be32(&spi->mode, 0x00f00000,
-						(3 << 20));
-			else
-				clrsetbits_be32(&spi->mode, 0x00f00000,
-						((bitlen - 1) << 20));
+		if (bitlen <= 4) {
+			clrsetbits_be32(&spi->mode, 0x00f00000, (3 << 20));
+		} else if (bitlen <= 16) {
+			clrsetbits_be32(&spi->mode, 0x00f00000,
+					((bitlen - 1) << 20));
 		} else {
 			clrbits_be32(&spi->mode, 0x00f00000);
 			/* Set up the next iteration if sending > 32 bits */
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#20 lore raw

PATCH 14/34 spi: mpc8xxx: Get rid of is_read

In reply to Jagan Teki

From: Mario Six <[email protected]>

Get rid of the is_read variable, and just keep the state of the "not empty" and "not full" events in two boolean variables within the loop body.

---
 drivers/spi/mpc8xxx_spi.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/spi/mpc8xxx_spi.c +7 -5
index ca34570901..962ef710f8 100644
@@ -90,7 +90,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
 	uint tmpdout, tmpdin, event;
 	int num_blks = DIV_ROUND_UP(bitlen, 32);
-	int tm, is_read = 0;
+	int tm;
 	uchar char_size = 32;
 
 	debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__,
@@ -144,12 +144,14 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * or time out (1 second = 1000 ms)
 		 * The NE event must be read and cleared first
 		 */
-		for (tm = 0, is_read = 0; tm < SPI_TIMEOUT; ++tm) {
+		for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
 			event = in_be32(&spi->event);
-			if (event & SPI_EV_NE) {
+			bool have_ne = event & SPI_EV_NE;
+			bool have_nf = event & SPI_EV_NF;
+
+			if (have_ne) {
 				tmpdin = in_be32(&spi->rx);
 				setbits_be32(&spi->event, SPI_EV_NE);
-				is_read = 1;
 
 				*(u32 *)din = (tmpdin << (32 - char_size));
 				if (char_size == 32) {
@@ -163,7 +165,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 			 * in the future put an arbitrary delay after writing
 			 * the device.  Arbitrary delays suck, though...
 			 */
-			if (is_read && (event & SPI_EV_NF))
+			if (have_ne && have_nf)
 				break;
 		}
 		if (tm >= SPI_TIMEOUT)
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#21 lore raw

PATCH 15/34 spi: mpc8xxx: Simplify logic a bit

In reply to Jagan Teki

From: Mario Six <[email protected]>

We do nothing in the loop if the "not empty" event was not detected. To simplify the logic, check if this is the case, and skip the execution of the loop early to reduce the nesting level and flag checking.

---
 drivers/spi/mpc8xxx_spi.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/spi/mpc8xxx_spi.c +13 -10
index 962ef710f8..a2e698ea17 100644
@@ -149,25 +149,28 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 			bool have_ne = event & SPI_EV_NE;
 			bool have_nf = event & SPI_EV_NF;
 
-			if (have_ne) {
-				tmpdin = in_be32(&spi->rx);
-				setbits_be32(&spi->event, SPI_EV_NE);
-
-				*(u32 *)din = (tmpdin << (32 - char_size));
-				if (char_size == 32) {
-					/* Advance output buffer by 32 bits */
-					din += 4;
-				}
+			if (!have_ne)
+				continue;
+
+			tmpdin = in_be32(&spi->rx);
+			setbits_be32(&spi->event, SPI_EV_NE);
+
+			*(u32 *)din = (tmpdin << (32 - char_size));
+			if (char_size == 32) {
+				/* Advance output buffer by 32 bits */
+				din += 4;
 			}
+
 			/*
 			 * Only bail when we've had both NE and NF events.
 			 * This will cause timeouts on RO devices, so maybe
 			 * in the future put an arbitrary delay after writing
 			 * the device.  Arbitrary delays suck, though...
 			 */
-			if (have_ne && have_nf)
+			if (have_nf)
 				break;
 		}
+
 		if (tm >= SPI_TIMEOUT)
 			debug("*** %s: Time out during SPI transfer\n",
 			      __func__);
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#22 lore raw

PATCH 16/34 spi: mpc8xxx: Reduce scope of loop variables

In reply to Jagan Teki

From: Mario Six <[email protected]>

The transmission loop starts with setting some variables, which are only used inside the loop. Reduce the scope to the loop to make the declaration and initialization of these variables coincide.

In the case of char_size this also always initializes the variable immediately with the final value actually used in the loop (instead of the placeholder value 32).

---
 drivers/spi/mpc8xxx_spi.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/spi/mpc8xxx_spi.c +5 -6
index a2e698ea17..2a0f3cc06a 100644
@@ -88,10 +88,8 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	     ulong flags)
 {
 	spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi;
-	uint tmpdout, tmpdin, event;
+	u32 tmpdin;
 	int num_blks = DIV_ROUND_UP(bitlen, 32);
-	int tm;
-	uchar char_size = 32;
 
 	debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__,
 	      slave->bus, slave->cs, *(uint *)dout, *(uint *)din, bitlen);
@@ -104,8 +102,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 
 	/* Handle data in 32-bit chunks */
 	while (num_blks--) {
-		tmpdout = 0;
-		char_size = (bitlen >= 32 ? 32 : bitlen);
+		int tm;
+		u32 tmpdout = 0;
+		uchar char_size = (bitlen >= 32 ? 32 : bitlen);
 
 		/* Shift data so it's msb-justified */
 		tmpdout = *(u32 *)dout >> (32 - char_size);
@@ -145,7 +144,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * The NE event must be read and cleared first
 		 */
 		for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
-			event = in_be32(&spi->event);
+			u32 event = in_be32(&spi->event);
 			bool have_ne = event & SPI_EV_NE;
 			bool have_nf = event & SPI_EV_NF;
 
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#23 lore raw

PATCH 17/34 spi: mpc8xxx: Make code more readable

In reply to Jagan Teki

From: Mario Six <[email protected]>

Introduce the to_prescale_mod and set_char_len inline functions to make the code more readable.

Note that the added "if (bitlen > 16)" check does not change the semantics of the current code, and hence only preserves the current error (this will be fixed in a later patch in the series).

---
 drivers/spi/mpc8xxx_spi.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/spi/mpc8xxx_spi.c +19 -8
index 2a0f3cc06a..83fd8b3cc1 100644
@@ -30,6 +30,16 @@ enum {
 	SPI_COM_LST = BIT(31 - 9),
 };
 
+static inline u32 to_prescale_mod(u32 val)
+{
+	return (min(val, (u32)15) << 16);
+}
+
+static void set_char_len(spi8xxx_t *spi, u32 val)
+{
+	clrsetbits_be32(&spi->mode, SPI_MODE_LEN_MASK, (val << 20));
+}
+
 #define SPI_TIMEOUT	1000
 
 struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode)
@@ -66,7 +76,7 @@ void spi_init(void)
 	 */
 	out_be32(&spi->mode, SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN);
 	/* Use SYSCLK / 8 (16.67MHz typ.) */
-	clrsetbits_be32(&spi->mode, 0x000f0000, BIT(16));
+	clrsetbits_be32(&spi->mode, SPI_MODE_PM_MASK, to_prescale_mod(1));
 	/* Clear all SPI events */
 	setbits_be32(&spi->event, 0xffffffff);
 	/* Mask  all SPI interrupts */
@@ -119,13 +129,14 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 
 		clrbits_be32(&spi->mode, SPI_MODE_EN);
 
-		if (bitlen <= 4) {
-			clrsetbits_be32(&spi->mode, 0x00f00000, (3 << 20));
-		} else if (bitlen <= 16) {
-			clrsetbits_be32(&spi->mode, 0x00f00000,
-					((bitlen - 1) << 20));
-		} else {
-			clrbits_be32(&spi->mode, 0x00f00000);
+		if (bitlen <= 4)
+			set_char_len(spi, 3);
+		else if (bitlen <= 16)
+			set_char_len(spi, bitlen - 1);
+		else
+			set_char_len(spi, 0);
+
+		if (bitlen > 16) {
 			/* Set up the next iteration if sending > 32 bits */
 			bitlen -= 32;
 			dout += 4;
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#24 lore raw

PATCH 18/34 spi: mpc8xxx: Rename variable

In reply to Jagan Teki

From: Mario Six <[email protected]>

The variable "char_size" holds the number of bits to be transferred in the current loop iteration. A better name would be "xfer_bitlen", which we rename this variable to.

---
 drivers/spi/mpc8xxx_spi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/mpc8xxx_spi.c +4 -4
index 83fd8b3cc1..63d956a295 100644
@@ -114,10 +114,10 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 	while (num_blks--) {
 		int tm;
 		u32 tmpdout = 0;
-		uchar char_size = (bitlen >= 32 ? 32 : bitlen);
+		uchar xfer_bitlen = (bitlen >= 32 ? 32 : bitlen);
 
 		/* Shift data so it's msb-justified */
-		tmpdout = *(u32 *)dout >> (32 - char_size);
+		tmpdout = *(u32 *)dout >> (32 - xfer_bitlen);
 
 		/* The LEN field of the SPMODE register is set as follows:
 		 *
@@ -165,8 +165,8 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 			tmpdin = in_be32(&spi->rx);
 			setbits_be32(&spi->event, SPI_EV_NE);
 
-			*(u32 *)din = (tmpdin << (32 - char_size));
-			if (char_size == 32) {
+			*(u32 *)din = (tmpdin << (32 - xfer_bitlen));
+			if (xfer_bitlen == 32) {
 				/* Advance output buffer by 32 bits */
 				din += 4;
 			}
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#25 lore raw

PATCH 19/34 spi: mpc8xxx: Document LEN setting better

In reply to Jagan Teki

From: Mario Six <[email protected]>

Instead of having a table right before the code implementing the length setting for documentation, have inline comments for the if branches actually implementing the length setting described table's entries (which is readable thanks to the set_char_len function).

---
 drivers/spi/mpc8xxx_spi.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/spi/mpc8xxx_spi.c +5 -11
index 63d956a295..1dd5bd9799 100644
@@ -119,21 +119,15 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		/* Shift data so it's msb-justified */
 		tmpdout = *(u32 *)dout >> (32 - xfer_bitlen);
 
-		/* The LEN field of the SPMODE register is set as follows:
-		 *
-		 * Bit length             setting
-		 * len <= 4               3
-		 * 4 < len <= 16          len - 1
-		 * len > 16               0
-		 */
-
 		clrbits_be32(&spi->mode, SPI_MODE_EN);
 
-		if (bitlen <= 4)
+		/* Set up length for this transfer */
+
+		if (bitlen <= 4) /* 4 bits or less */
 			set_char_len(spi, 3);
-		else if (bitlen <= 16)
+		else if (bitlen <= 16) /*@most 16 bits */
 			set_char_len(spi, bitlen - 1);
-		else
+		else /* more than 16 bits -> full 32 bit transfer */
 			set_char_len(spi, 0);
 
 		if (bitlen > 16) {
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#26 lore raw

PATCH 20/34 spi: mpc8xxx: Re-order transfer setup

In reply to Jagan Teki

From: Mario Six <[email protected]>

Minize the time the adapter is disabled (via SPI_MODE_EN clearing/setting) to just the character length setting, and only set up the temporary data writing variable right before we need it, so there is a more clear distinction between setting up the SPI adapter, and setting up the data to be written.

---
 drivers/spi/mpc8xxx_spi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/spi/mpc8xxx_spi.c +5 -5
index 1dd5bd9799..1e7c0144c2 100644
@@ -116,9 +116,6 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		u32 tmpdout = 0;
 		uchar xfer_bitlen = (bitlen >= 32 ? 32 : bitlen);
 
-		/* Shift data so it's msb-justified */
-		tmpdout = *(u32 *)dout >> (32 - xfer_bitlen);
-
 		clrbits_be32(&spi->mode, SPI_MODE_EN);
 
 		/* Set up length for this transfer */
@@ -130,14 +127,17 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		else /* more than 16 bits -> full 32 bit transfer */
 			set_char_len(spi, 0);
 
+		setbits_be32(&spi->mode, SPI_MODE_EN);
+
+		/* Shift data so it's msb-justified */
+		tmpdout = *(u32 *)dout >> (32 - xfer_bitlen);
+
 		if (bitlen > 16) {
 			/* Set up the next iteration if sending > 32 bits */
 			bitlen -= 32;
 			dout += 4;
 		}
 
-		setbits_be32(&spi->mode, SPI_MODE_EN);
-
 		/* Write the data out */
 		out_be32(&spi->tx, tmpdout);
 
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#27 lore raw

PATCH 21/34 spi: mpc8xxx: Fix if check

In reply to Jagan Teki

From: Mario Six <[email protected]>

Decreasing the bit length and increasing the write data pointer should be done when there are more than 32 bit of data, not 16 bit.

This did not produce incorrect behavior, because the only time where the two checks produce different outcomes is the case of 16 < bitlen < 32, and in this case the subsequent transmission is the last one regardless, hence the additional bit length decrease and write data pointer increase has no effect anyway.

Still, the correct check is the check for "bitlen > 32", so correct this behavior.

---
 drivers/spi/mpc8xxx_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/mpc8xxx_spi.c +1 -1
index 1e7c0144c2..e09e91c8e9 100644
@@ -132,7 +132,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		/* Shift data so it's msb-justified */
 		tmpdout = *(u32 *)dout >> (32 - xfer_bitlen);
 
-		if (bitlen > 16) {
+		if (bitlen > 32) {
 			/* Set up the next iteration if sending > 32 bits */
 			bitlen -= 32;
 			dout += 4;
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#28 lore raw

PATCH 22/34 spi: mpc8xxx: Use get_timer

In reply to Jagan Teki

From: Mario Six <[email protected]>

The comment before the transmission loop in conjunction with the definition of SPI_TIMEOUT as 1000 implies that the loop is supposed to have a timeout value of 1000 ms. But since there is no mdelay(1) or similar in the loop body, the loop just runs 1000 times, without regard for the time elapsed.

To correct this, use the standard get_timer functionality to properly time out the loop after 1000 ms.

---
 drivers/spi/mpc8xxx_spi.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/spi/mpc8xxx_spi.c +7 -4
index e09e91c8e9..63e1a150f8 100644
@@ -112,9 +112,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 
 	/* Handle data in 32-bit chunks */
 	while (num_blks--) {
-		int tm;
 		u32 tmpdout = 0;
 		uchar xfer_bitlen = (bitlen >= 32 ? 32 : bitlen);
+		ulong start;
 
 		clrbits_be32(&spi->mode, SPI_MODE_EN);
 
@@ -148,7 +148,8 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 		 * or time out (1 second = 1000 ms)
 		 * The NE event must be read and cleared first
 		 */
-		for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
+		start = get_timer(0);
+		do {
 			u32 event = in_be32(&spi->event);
 			bool have_ne = event & SPI_EV_NE;
 			bool have_nf = event & SPI_EV_NF;
@@ -173,9 +174,11 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din,
 			 */
 			if (have_nf)
 				break;
-		}
 
-		if (tm >= SPI_TIMEOUT)
+			mdelay(1);
+		} while (get_timer(start) < SPI_TIMEOUT);
+
+		if (get_timer(start) >= SPI_TIMEOUT)
 			debug("*** %s: Time out during SPI transfer\n",
 			      __func__);
 
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#29 lore raw

PATCH 23/34 spi: mpc8xxx: Convert to DM

In reply to Jagan Teki

From: Mario Six <[email protected]>

Support DM in the MPC8xxx SPI driver, and remove the legacy SPI interface.

[jagan: build for board which doesn't enable DM_SPI]
---
 Makefile                  |   3 +-
 drivers/spi/Makefile      |   2 +-
 drivers/spi/mpc8xxx_spi.c | 144 ++++++++++++++++++++++++++++----------
 drivers/spi/spi.c         |   1 +
 4 files changed, 111 insertions(+), 39 deletions(-)
Makefile +2 -1
index efa68e7343..7c1d934493 100644
@@ -919,7 +919,8 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 	@echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) $(CONFIG_TI_QSPI),y),y)
+ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) $(CONFIG_MPC8XXX_SPI) \
+	       $(CONFIG_TI_QSPI),y),y)
 	@echo "===================== WARNING ======================"
 	@echo "This board uses SPI driver from drivers/spi/ without"
 	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index 748d9a90ab..19aa95b2ca 100644
@@ -8,6 +8,7 @@ ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
+obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -33,7 +34,6 @@ obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
 obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
-obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
 obj-$(CONFIG_MXC_SPI) += mxc_spi.o
drivers/spi/mpc8xxx_spi.c +107 -37

208 lines not on this page · raw message

drivers/spi/spi.c +1 -0
index 500853fc95..8116193d27 100644
@@ -42,6 +42,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 #if !defined(CONFIG_DM_SPI) && \
 	defined(CONFIG_DAVINCI_SPI) || \
 	defined(CONFIG_KIRKWOOD_SPI) || \
+	defined(CONFIG_MPC8XXX_SPI) || \
 	defined(CONFIG_TI_QSPI)
 void spi_cs_activate(struct spi_slave *slave)
 {
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#30 lore raw

PATCH 24/34 spi: Zap cf_spi driver-related code

In reply to Jagan Teki

Dropped
- cf_espi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active usage
- no dm conversion
- driver-model migration expiry

---
 configs/M52277EVB_defconfig                   |   6 -
 configs/M52277EVB_stmicro_defconfig           |   7 -
 configs/M54418TWR_defconfig                   |   7 -
 configs/M54418TWR_nand_mii_defconfig          |   6 -
 configs/M54418TWR_nand_rmii_defconfig         |   6 -
 configs/M54418TWR_nand_rmii_lowfreq_defconfig |   6 -
 configs/M54418TWR_serial_mii_defconfig        |   7 -
 configs/M54418TWR_serial_rmii_defconfig       |   7 -
 configs/M54451EVB_defconfig                   |   6 -
 configs/M54451EVB_stmicro_defconfig           |   7 -
 configs/M54455EVB_a66_defconfig               |   6 -
 configs/M54455EVB_defconfig                   |   6 -
 configs/M54455EVB_i66_defconfig               |   6 -
 configs/M54455EVB_intel_defconfig             |   6 -
 configs/M54455EVB_stm33_defconfig             |   7 -
 configs/stmark2_defconfig                     |   8 -
 drivers/spi/Kconfig                           |   6 -
 drivers/spi/Makefile                          |   1 -
 drivers/spi/cf_spi.c                          | 335 ------------------
 19 files changed, 446 deletions(-)
 delete mode 100644 drivers/spi/cf_spi.c
configs/M52277EVB_defconfig +0 -6
index efa5e7102b..4cfde17e50 100644
@@ -9,8 +9,6 @@ CONFIG_BOOTDELAY=3
 CONFIG_SYS_PROMPT="-> "
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_I2C=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_DATE=y
@@ -22,7 +20,3 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M52277EVB_stmicro_defconfig +0 -7
index 3628729a48..362ede7458 100644
@@ -8,20 +8,13 @@ CONFIG_BOOTDELAY=3
 # CONFIG_AUTO_COMPLETE is not set
 CONFIG_CMD_IMLS=y
 CONFIG_CMD_I2C=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_DATE=y
 CONFIG_CMD_JFFS2=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 # CONFIG_NET is not set
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54418TWR_defconfig +0 -7
index f69f405d5a..6632d03736 100644
@@ -12,16 +12,9 @@ CONFIG_SYS_PROMPT="-> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54418TWR_nand_mii_defconfig +0 -6
index 04ca3a8114..b15fe3093a 100644
@@ -12,15 +12,9 @@ CONFIG_SYS_PROMPT="-> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54418TWR_nand_rmii_defconfig +0 -6
index f6acf6019d..59a37c7c22 100644
@@ -12,15 +12,9 @@ CONFIG_SYS_PROMPT="-> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54418TWR_nand_rmii_lowfreq_defconfig +0 -6
index 6b631d6d4b..5dce1ddfac 100644
@@ -12,15 +12,9 @@ CONFIG_SYS_PROMPT="-> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54418TWR_serial_mii_defconfig +0 -7
index b2266a0577..42389a7151 100644
@@ -12,16 +12,9 @@ CONFIG_SYS_PROMPT="-> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54418TWR_serial_rmii_defconfig +0 -7
index f69f405d5a..6632d03736 100644
@@ -12,16 +12,9 @@ CONFIG_SYS_PROMPT="-> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54451EVB_defconfig +0 -6
index 8448b6cfbf..e19174583f 100644
@@ -12,8 +12,6 @@ CONFIG_CMD_IMLS=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -26,8 +24,4 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54451EVB_stmicro_defconfig +0 -7
index ce5f65666c..af1c356697 100644
@@ -11,22 +11,15 @@ CONFIG_CMD_IMLS=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_DATE=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54455EVB_a66_defconfig +0 -6
index f9be1c3773..fa3971b798 100644
@@ -12,8 +12,6 @@ CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -30,8 +28,4 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54455EVB_defconfig +0 -6
index abb69a966a..ea715f33f6 100644
@@ -13,8 +13,6 @@ CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -31,8 +29,4 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54455EVB_i66_defconfig +0 -6
index 6050df5d51..0aecf69e74 100644
@@ -12,8 +12,6 @@ CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -30,8 +28,4 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54455EVB_intel_defconfig +0 -6
index 686c00e318..2f2b793c22 100644
@@ -12,8 +12,6 @@ CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -30,8 +28,4 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/M54455EVB_stm33_defconfig +0 -7
index fc19de50d1..f8d8c79e2a 100644
@@ -12,8 +12,6 @@ CONFIG_CMD_IDE=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -24,14 +22,9 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_JFFS2=y
 CONFIG_ISO_PARTITION=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
configs/stmark2_defconfig +0 -8
index 48e851d4a4..53997bb58f 100644
@@ -12,19 +12,11 @@ CONFIG_SYS_PROMPT="stmark2 $ "
 # CONFIG_CMD_IMPORTENV is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_LOADS is not set
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nor0=spi-flash.0"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-flash.0:1m(u-boot),7m(kernel),-(rootfs)"
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 # CONFIG_NET is not set
 CONFIG_MTD_DEVICE=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_ISSI=y
-CONFIG_SPI_FLASH_MTD=y
-CONFIG_SPI=y
-CONFIG_CF_SPI=y
 CONFIG_REGEX=y
drivers/spi/Kconfig +0 -6
index 516188ea88..1f37f1083d 100644
@@ -273,12 +273,6 @@ config SOFT_SPI
 	 Enable Soft SPI driver. This driver is to use GPIO simulate
 	 the SPI protocol.
 
-config CF_SPI
-	bool "ColdFire SPI driver"
-	help
-	  Enable the ColdFire SPI driver. This driver can be used on
-	  some m68k SoCs.
-
 config FSL_ESPI
 	bool "Freescale eSPI driver"
 	help
drivers/spi/Makefile +0 -1
index 19aa95b2ca..890e919f49 100644
@@ -25,7 +25,6 @@ obj-$(CONFIG_BCM63XX_HSSPI) += bcm63xx_hsspi.o
 obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
 obj-$(CONFIG_BCMSTB_SPI) += bcmstb_spi.o
 obj-$(CONFIG_CADENCE_QSPI) += cadence_qspi.o cadence_qspi_apb.o
-obj-$(CONFIG_CF_SPI) += cf_spi.o
 obj-$(CONFIG_DESIGNWARE_SPI) += designware_spi.o
 obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
drivers/spi/cf_spi.c deleted +0 -335

335 lines not on this page · raw message

Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#31 lore raw

PATCH 25/34 spi: Zap lpc32xx_ssp driver-related code

In reply to Jagan Teki

Dropped
- lpc32xx_ssp driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- multiple pings for asking dm-conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 configs/devkit3250_defconfig |   3 -
 configs/work_92105_defconfig |   3 -
 drivers/spi/Kconfig          |   5 --
 drivers/spi/Makefile         |   1 -
 drivers/spi/lpc32xx_ssp.c    | 134 -----------------------------------
 include/configs/devkit3250.h |   5 --
 include/configs/work_92105.h |   5 --
 scripts/config_whitelist.txt |   1 -
 8 files changed, 157 deletions(-)
 delete mode 100644 drivers/spi/lpc32xx_ssp.c
configs/devkit3250_defconfig +0 -3
index b739f27803..7473f9c202 100644
@@ -19,7 +19,6 @@ CONFIG_CMD_IMLS=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_NAND=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
@@ -41,8 +40,6 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_ADDR_ENABLE=y
 CONFIG_PHY_ADDR=31
 CONFIG_SYS_NS16550=y
-CONFIG_SPI=y
-CONFIG_LPC32XX_SSP=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_OF_LIBFDT=y
configs/work_92105_defconfig +0 -3
index 105e51a400..988e7999cc 100644
@@ -25,7 +25,6 @@ CONFIG_CMD_EEPROM=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_NAND=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -37,5 +36,3 @@ CONFIG_ENV_IS_IN_NAND=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_ADDR_ENABLE=y
 CONFIG_SYS_NS16550=y
-CONFIG_SPI=y
-CONFIG_LPC32XX_SSP=y
drivers/spi/Kconfig +0 -5
index 1f37f1083d..bf134ef437 100644
@@ -317,11 +317,6 @@ config KIRKWOOD_SPI
 	  Enable support for SPI on various Marvell SoCs, such as
 	  Kirkwood and Armada 375.
 
-config LPC32XX_SSP
-	bool "LPC32XX SPI Driver"
-	help
-	  Enable support for SPI on LPC32xx
-
 config MPC8XX_SPI
 	bool "MPC8XX SPI Driver"
 	depends on MPC8xx
drivers/spi/Makefile +0 -1
index 890e919f49..7d676988fd 100644
@@ -31,7 +31,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_LPC32XX_SSP) += lpc32xx_ssp.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
drivers/spi/lpc32xx_ssp.c deleted +0 -134

134 lines not on this page · raw message

include/configs/devkit3250.h +0 -5
index 2f8c655b2c..e1f729a854 100644
@@ -58,11 +58,6 @@
  */
 #define CONFIG_LPC32XX_GPIO
 
-/*
- * SSP/SPI
- */
-#define CONFIG_LPC32XX_SSP_TIMEOUT	100000
-
 /*
  * Ethernet
  */
include/configs/work_92105.h +0 -5
index 67b5e9aa11..9d9a53ef09 100644
@@ -109,11 +109,6 @@
 
 #define CONFIG_LPC32XX_GPIO
 
-/*
- * SSP/SPI/DISPLAY
- */
-
-#define CONFIG_LPC32XX_SSP_TIMEOUT 100000
 /*
  * Environment
  */
scripts/config_whitelist.txt +0 -1
index abfb0ff89f..ff25315363 100644
@@ -1172,7 +1172,6 @@ CONFIG_LPC32XX_NAND_SLC_WDR_CLKS
 CONFIG_LPC32XX_NAND_SLC_WHOLD
 CONFIG_LPC32XX_NAND_SLC_WSETUP
 CONFIG_LPC32XX_NAND_SLC_WWIDTH
-CONFIG_LPC32XX_SSP_TIMEOUT
 CONFIG_LPC_BASE
 CONFIG_LPC_IO_BASE
 CONFIG_LPUART
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#32 lore raw

PATCH 26/34 spi: Zap mxs_spi driver-related code

In reply to Jagan Teki

Dropped
- mxs_spi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 configs/bg0900_defconfig                |   7 -
 configs/mx28evk_auart_console_defconfig |   6 -
 configs/mx28evk_defconfig               |   6 -
 configs/mx28evk_nand_defconfig          |   6 -
 configs/mx28evk_spi_defconfig           |   7 -
 drivers/spi/Kconfig                     |   6 -
 drivers/spi/Makefile                    |   1 -
 drivers/spi/mxs_spi.c                   | 358 ------------------------
 8 files changed, 397 deletions(-)
 delete mode 100644 drivers/spi/mxs_spi.c
configs/bg0900_defconfig +0 -7
index 6de81621cd..67f4c772ee 100644
@@ -21,8 +21,6 @@ CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_NAND_TRIMFFS=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
@@ -31,11 +29,6 @@ CONFIG_DOS_PARTITION=y
 # CONFIG_MMC is not set
 CONFIG_NAND=y
 CONFIG_NAND_MXS=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_BAR=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_MII=y
 CONFIG_CONS_INDEX=0
-CONFIG_SPI=y
-CONFIG_MXS_SPI=y
 CONFIG_OF_LIBFDT=y
configs/mx28evk_auart_console_defconfig +0 -6
index d0572212f1..65988ac46d 100644
@@ -21,8 +21,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND_TRIMFFS=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -42,12 +40,8 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_MMC_MXS=y
 CONFIG_NAND=y
 CONFIG_NAND_MXS=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_SST=y
 CONFIG_MII=y
 CONFIG_CONS_INDEX=0
-CONFIG_SPI=y
-CONFIG_MXS_SPI=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
configs/mx28evk_defconfig +0 -6
index ab59d7599b..4e0889288d 100644
@@ -21,8 +21,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND_TRIMFFS=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -42,12 +40,8 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_MMC_MXS=y
 CONFIG_NAND=y
 CONFIG_NAND_MXS=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_SST=y
 CONFIG_MII=y
 CONFIG_CONS_INDEX=0
-CONFIG_SPI=y
-CONFIG_MXS_SPI=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
configs/mx28evk_nand_defconfig +0 -6
index 6b774cf248..e92ddecd03 100644
@@ -20,8 +20,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND_TRIMFFS=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -41,12 +39,8 @@ CONFIG_ENV_IS_IN_NAND=y
 CONFIG_MMC_MXS=y
 CONFIG_NAND=y
 CONFIG_NAND_MXS=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_SST=y
 CONFIG_MII=y
 CONFIG_CONS_INDEX=0
-CONFIG_SPI=y
-CONFIG_MXS_SPI=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
configs/mx28evk_spi_defconfig +0 -7
index 0a77e6e9f7..479f90837b 100644
@@ -20,8 +20,6 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND_TRIMFFS=y
-CONFIG_CMD_SF=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_MII=y
@@ -37,16 +35,11 @@ CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=gpmi-nand"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:3m(bootloader)ro,512k(environment),512k(redundant-environment),4m(kernel),512k(fdt),8m(ramdisk),-(filesystem)"
 CONFIG_CMD_UBI=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MMC_MXS=y
 CONFIG_NAND=y
 CONFIG_NAND_MXS=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_SST=y
 CONFIG_MII=y
 CONFIG_CONS_INDEX=0
-CONFIG_SPI=y
-CONFIG_MXS_SPI=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
drivers/spi/Kconfig +0 -6
index bf134ef437..30a19fc510 100644
@@ -334,12 +334,6 @@ config MXC_SPI
 	  Enable the MXC SPI controller driver. This driver can be used
 	  on various i.MX SoCs such as i.MX31/35/51/6/7.
 
-config MXS_SPI
-	bool "MXS SPI Driver"
-	help
-	  Enable the MXS SPI controller driver. This driver can be used
-	  on the i.MX23 and i.MX28 SoCs.
-
 config OMAP3_SPI
 	bool "McSPI driver for OMAP"
 	help
drivers/spi/Makefile +0 -1
index 7d676988fd..c4c9d2f393 100644
@@ -35,7 +35,6 @@ obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
 obj-$(CONFIG_MXC_SPI) += mxc_spi.o
-obj-$(CONFIG_MXS_SPI) += mxs_spi.o
 obj-$(CONFIG_ATCSPI200_SPI) += atcspi200_spi.o
 obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_PIC32_SPI) += pic32_spi.o
drivers/spi/mxs_spi.c deleted +0 -358

358 lines not on this page · raw message

Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#33 lore raw

PATCH 27/34 spi: Zap sh_spi driver-related code

In reply to Jagan Teki

Dropped
- sh_spi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 configs/sh7752evb_defconfig  |   7 -
 configs/sh7753evb_defconfig  |   7 -
 configs/sh7757lcr_defconfig  |   6 -
 drivers/spi/Kconfig          |   6 -
 drivers/spi/Makefile         |   1 -
 drivers/spi/sh_spi.c         | 249 -----------------------------------
 drivers/spi/sh_spi.h         |  67 ----------
 include/configs/sh7752evb.h  |   5 -
 include/configs/sh7753evb.h  |   5 -
 include/configs/sh7757lcr.h  |   5 -
 scripts/config_whitelist.txt |   1 -
 11 files changed, 359 deletions(-)
 delete mode 100644 drivers/spi/sh_spi.c
 delete mode 100644 drivers/spi/sh_spi.h
configs/sh7752evb_defconfig +0 -7
index b34709d1ea..fecaf04172 100644
@@ -18,7 +18,6 @@ CONFIG_CMD_MD5SUM=y
 # CONFIG_CMD_LOADB is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SDRAM=y
-CONFIG_CMD_SF=y
 # CONFIG_CMD_ECHO is not set
 # CONFIG_CMD_ITEST is not set
 # CONFIG_CMD_SOURCE is not set
@@ -29,14 +28,8 @@ CONFIG_CMD_PING=y
 CONFIG_CMD_EXT2=y
 CONFIG_MAC_PARTITION=y
 CONFIG_DOS_PARTITION=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MMC=y
 CONFIG_SH_MMCIF=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_MACRONIX=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SH_ETHER=y
 CONFIG_SCIF_CONSOLE=y
-CONFIG_SPI=y
-CONFIG_SH_SPI=y
 CONFIG_USE_PRIVATE_LIBGCC=y
configs/sh7753evb_defconfig +0 -7
index 857e90b86a..58df710c70 100644
@@ -17,7 +17,6 @@ CONFIG_CMD_MD5SUM=y
 # CONFIG_CMD_LOADB is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SDRAM=y
-CONFIG_CMD_SF=y
 # CONFIG_CMD_ECHO is not set
 # CONFIG_CMD_ITEST is not set
 # CONFIG_CMD_SOURCE is not set
@@ -28,14 +27,8 @@ CONFIG_CMD_PING=y
 CONFIG_CMD_EXT2=y
 CONFIG_MAC_PARTITION=y
 CONFIG_DOS_PARTITION=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MMC=y
 CONFIG_SH_MMCIF=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_MACRONIX=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SH_ETHER=y
 CONFIG_SCIF_CONSOLE=y
-CONFIG_SPI=y
-CONFIG_SH_SPI=y
 CONFIG_USE_PRIVATE_LIBGCC=y
configs/sh7757lcr_defconfig +0 -6
index 8314435b93..9939e3b150 100644
@@ -20,7 +20,6 @@ CONFIG_CMD_MD5SUM=y
 # CONFIG_CMD_LOADB is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SDRAM=y
-CONFIG_CMD_SF=y
 # CONFIG_CMD_ECHO is not set
 # CONFIG_CMD_ITEST is not set
 # CONFIG_CMD_SOURCE is not set
@@ -31,13 +30,8 @@ CONFIG_CMD_PING=y
 CONFIG_CMD_EXT2=y
 CONFIG_MAC_PARTITION=y
 CONFIG_DOS_PARTITION=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_MMC=y
 CONFIG_SH_MMCIF=y
-CONFIG_SPI_FLASH=y
-CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SH_ETHER=y
 CONFIG_SCIF_CONSOLE=y
-CONFIG_SPI=y
-CONFIG_SH_SPI=y
 CONFIG_USE_PRIVATE_LIBGCC=y
drivers/spi/Kconfig +0 -6
index 30a19fc510..93c45aa481 100644
@@ -293,12 +293,6 @@ config DAVINCI_SPI
 	help
 	  Enable the Davinci SPI driver
 
-config SH_SPI
-	bool "SuperH SPI driver"
-	help
-	  Enable the SuperH SPI controller driver. This driver can be used
-	  on various SuperH SoCs, such as SH7757.
-
 config SH_QSPI
 	bool "Renesas Quad SPI driver"
 	help
drivers/spi/Makefile +0 -1
index c4c9d2f393..b531ebbf83 100644
@@ -42,7 +42,6 @@ obj-$(CONFIG_PL022_SPI) += pl022_spi.o
 obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o
 obj-$(CONFIG_ROCKCHIP_SPI) += rk_spi.o
 obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o
-obj-$(CONFIG_SH_SPI) += sh_spi.o
 obj-$(CONFIG_SH_QSPI) += sh_qspi.o
 obj-$(CONFIG_STM32_QSPI) += stm32_qspi.o
 obj-$(CONFIG_SUN4I_SPI) += sun4i_spi.o
drivers/spi/sh_spi.c deleted +0 -249

249 lines not on this page · raw message

drivers/spi/sh_spi.h deleted +0 -67

67 lines not on this page · raw message

include/configs/sh7752evb.h +0 -5
index 1f29e3d221..a93ee16a77 100644
@@ -49,14 +49,9 @@
 #define CONFIG_SH_ETHER_PHY_MODE PHY_INTERFACE_MODE_RGMII
 #define CONFIG_PHY_VITESSE
 
-#define SH7752EVB_ETHERNET_MAC_BASE_SPI	0x00090000
-#define SH7752EVB_SPI_SECTOR_SIZE	(64 * 1024)
-#define SH7752EVB_ETHERNET_MAC_BASE	SH7752EVB_ETHERNET_MAC_BASE_SPI
 #define SH7752EVB_ETHERNET_MAC_SIZE	17
 #define SH7752EVB_ETHERNET_NUM_CH	2
 
-/* SPI */
-#define CONFIG_SH_SPI_BASE		0xfe002000
 
 /* MMCIF */
 #define CONFIG_SH_MMCIF_ADDR		0xffcb0000
include/configs/sh7753evb.h +0 -5
index 0693fb5a3c..b86e781b95 100644
@@ -49,14 +49,9 @@
 #define CONFIG_SH_ETHER_PHY_MODE PHY_INTERFACE_MODE_RGMII
 #define CONFIG_PHY_VITESSE
 
-#define SH7753EVB_ETHERNET_MAC_BASE_SPI	0x00090000
-#define SH7753EVB_SPI_SECTOR_SIZE	(64 * 1024)
-#define SH7753EVB_ETHERNET_MAC_BASE	SH7753EVB_ETHERNET_MAC_BASE_SPI
 #define SH7753EVB_ETHERNET_MAC_SIZE	17
 #define SH7753EVB_ETHERNET_NUM_CH	2
 
-/* SPI */
-#define CONFIG_SH_SPI_BASE		0xfe002000
 
 /* MMCIF */
 #define CONFIG_SH_MMCIF_ADDR		0xffcb0000
include/configs/sh7757lcr.h +0 -5
index 05b2f01c15..8886a4a005 100644
@@ -50,17 +50,12 @@
 #define CONFIG_BITBANGMII_MULTI
 #define CONFIG_SH_ETHER_PHY_MODE PHY_INTERFACE_MODE_MII
 
-#define SH7757LCR_ETHERNET_MAC_BASE_SPI	0x000b0000
-#define SH7757LCR_SPI_SECTOR_SIZE	(64 * 1024)
-#define SH7757LCR_ETHERNET_MAC_BASE	SH7757LCR_ETHERNET_MAC_BASE_SPI
 #define SH7757LCR_ETHERNET_MAC_SIZE	17
 #define SH7757LCR_ETHERNET_NUM_CH	2
 
 /* Gigabit Ether */
 #define SH7757LCR_GIGA_ETHERNET_NUM_CH	2
 
-/* SPI */
-#define CONFIG_SH_SPI_BASE		0xfe002000
 
 /* MMCIF */
 #define CONFIG_SH_MMCIF_ADDR		0xffcb0000
scripts/config_whitelist.txt +0 -1
index ff25315363..89fa5593c6 100644
@@ -1769,7 +1769,6 @@ CONFIG_SH_QSPI_BASE
 CONFIG_SH_SCIF_CLK_FREQ
 CONFIG_SH_SDHI_FREQ
 CONFIG_SH_SDRAM_OFFSET
-CONFIG_SH_SPI_BASE
 CONFIG_SIEMENS_MACH_TYPE
 CONFIG_SIMU
 CONFIG_SKIP_LOCAL_MAC_RANDOMIZATION
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#34 lore raw

PATCH 28/34 spi: Zap soft_spi_legacy driver-related code

In reply to Jagan Teki

Dropped
- soft_spi_legacy driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- driver-model migration expiry

---
 configs/zipitz2_defconfig     |   1 -
 drivers/spi/Kconfig           |  12 +--
 drivers/spi/Makefile          |   1 -
 drivers/spi/soft_spi_legacy.c | 168 ----------------------------------
 include/configs/MPC8349EMDS.h |   3 -
 include/configs/zipitz2.h     |   7 --
 6 files changed, 6 insertions(+), 186 deletions(-)
 delete mode 100644 drivers/spi/soft_spi_legacy.c
configs/zipitz2_defconfig +0 -1
index 509adcffd9..edfa94eb0d 100644
@@ -11,7 +11,6 @@ CONFIG_HUSH_PARSER=y
 # CONFIG_AUTO_COMPLETE is not set
 CONFIG_SYS_PROMPT="$ "
 CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_CACHE=y
drivers/spi/Kconfig +6 -6
index 93c45aa481..dab48ccbfc 100644
@@ -189,6 +189,12 @@ config SANDBOX_SPI
 		};
 	  };
 
+config SOFT_SPI
+	bool "Soft SPI driver"
+	help
+	 Enable Soft SPI driver. This driver is to use GPIO simulate
+	 the SPI protocol.
+
 config STM32_QSPI
 	bool "STM32F7 QSPI driver"
 	depends on STM32F7
@@ -267,12 +273,6 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
-config SOFT_SPI
-	bool "Soft SPI driver"
-	help
-	 Enable Soft SPI driver. This driver is to use GPIO simulate
-	 the SPI protocol.
-
 config FSL_ESPI
 	bool "Freescale eSPI driver"
 	help
drivers/spi/Makefile +0 -1
index b531ebbf83..49e614e124 100644
@@ -15,7 +15,6 @@ obj-$(CONFIG_SPI_MEM) += spi-mem.o
 obj-$(CONFIG_TI_QSPI) += ti_qspi.o
 else
 obj-y += spi.o
-obj-$(CONFIG_SOFT_SPI) += soft_spi_legacy.o
 endif
 
 obj-$(CONFIG_ALTERA_SPI) += altera_spi.o
drivers/spi/soft_spi_legacy.c deleted +0 -168

168 lines not on this page · raw message

include/configs/MPC8349EMDS.h +0 -3
index bda477cc16..a54f4ca251 100644
@@ -320,9 +320,6 @@
 #define CONFIG_SYS_FSL_I2C2_OFFSET	0x3100
 #define CONFIG_SYS_I2C_NOPROBES		{ {0, 0x69} }
 
-/* SPI */
-#undef CONFIG_SOFT_SPI			/* SPI bit-banged */
-
 /* GPIOs.  Used as SPI chip selects */
 #define CONFIG_SYS_GPIO1_PRELIM
 #define CONFIG_SYS_GPIO1_DIR		0xC0000000  /* SPI CS on 0, LED on 1 */
include/configs/zipitz2.h +0 -7
index 24fea68a11..72717e89bb 100644
@@ -58,22 +58,15 @@
 /*
  * SPI and LCD
  */
-#ifdef	CONFIG_CMD_SPI
-#define	CONFIG_SOFT_SPI
 #define	CONFIG_LCD_ROTATION
 #define	CONFIG_PXA_LCD
 #define	CONFIG_LMS283GF05
 
-#define	SPI_DELAY	udelay(10)
-#define	SPI_SDA(val)	zipitz2_spi_sda(val)
-#define	SPI_SCL(val)	zipitz2_spi_scl(val)
-#define	SPI_READ	zipitz2_spi_read()
 #ifndef	__ASSEMBLY__
 void zipitz2_spi_sda(int);
 void zipitz2_spi_scl(int);
 unsigned char zipitz2_spi_read(void);
 #endif
-#endif
 
 #define	CONFIG_SYS_DEVICE_NULLDEV	1
 
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#35 lore raw

PATCH 29/34 spi: Zap mpc8xx_spi driver-related code

In reply to Jagan Teki

Dropped
- mpc8xx_spi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 cmd/eeprom.c             |   4 +-
 common/board_r.c         |   7 -
 drivers/spi/Kconfig      |   6 -
 drivers/spi/Makefile     |   1 -
 drivers/spi/mpc8xx_spi.c | 335 ---------------------------------------
 include/common.h         |   7 -
 6 files changed, 2 insertions(+), 358 deletions(-)
 delete mode 100644 drivers/spi/mpc8xx_spi.c
cmd/eeprom.c +2 -2
index 4052cf494a..a5b5d02073 100644
@@ -67,7 +67,7 @@ __weak int eeprom_write_enable(unsigned dev_addr, int state)
 void eeprom_init(int bus)
 {
 	/* SPI EEPROM */
-#if defined(CONFIG_MPC8XX_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
+#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 	spi_init_f();
 #endif
 
@@ -130,7 +130,7 @@ static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
 	int ret = 0;
 
 	/* SPI */
-#if defined(CONFIG_MPC8XX_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
+#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
 	if (read)
 		spi_read(addr, alen, buffer, len);
 	else
common/board_r.c +0 -7
index c55e33eec2..3ccef5467b 100644
@@ -382,13 +382,6 @@ static int initr_flash(void)
 #if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI)
 static int initr_spi(void)
 {
-	/* MPC8xx does this here */
-#ifdef CONFIG_MPC8XX_SPI
-#if !defined(CONFIG_ENV_IS_IN_EEPROM)
-	spi_init_f();
-#endif
-	spi_init_r();
-#endif
 	return 0;
 }
 #endif
drivers/spi/Kconfig +0 -6
index dab48ccbfc..3aff989a0e 100644
@@ -311,12 +311,6 @@ config KIRKWOOD_SPI
 	  Enable support for SPI on various Marvell SoCs, such as
 	  Kirkwood and Armada 375.
 
-config MPC8XX_SPI
-	bool "MPC8XX SPI Driver"
-	depends on MPC8xx
-	help
-	  Enable support for SPI on MPC8XX
-
 config MPC8XXX_SPI
 	bool "MPC8XXX SPI Driver"
 	help
drivers/spi/Makefile +0 -1
index 49e614e124..09e22dc233 100644
@@ -30,7 +30,6 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
-obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
 obj-$(CONFIG_MXC_SPI) += mxc_spi.o
drivers/spi/mpc8xx_spi.c deleted +0 -335

335 lines not on this page · raw message

include/common.h +0 -7
index 8b9f859c07..ea92426b02 100644
@@ -279,13 +279,6 @@ int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned c
 # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
 #endif
 
-#if defined(CONFIG_MPC8XX_SPI)
-extern void spi_init_f (void);
-extern void spi_init_r (void);
-extern ssize_t spi_read	 (uchar *, int, uchar *, int);
-extern ssize_t spi_write (uchar *, int, uchar *, int);
-#endif
-
 /* $(BOARD)/$(BOARD).c */
 int board_early_init_f (void);
 int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#36 lore raw

PATCH 30/34 spi: Zap mxc_spi driver-related code

In reply to Jagan Teki

Dropped
- mxc_spi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 Makefile              |   2 +-
 drivers/spi/Makefile  |   2 +-
 drivers/spi/mxc_spi.c | 123 ++----------------------------------------
 drivers/spi/spi.c     |   1 +
 4 files changed, 6 insertions(+), 122 deletions(-)
Makefile +1 -1
index 7c1d934493..3be3bb3118 100644
@@ -920,7 +920,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 endif
 ifeq ($(CONFIG_DM_SPI),)
 ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) $(CONFIG_MPC8XXX_SPI) \
-	       $(CONFIG_TI_QSPI),y),y)
+	       $(CONFIG_MXC_SPI) $(CONFIG_TI_QSPI),y),y)
 	@echo "===================== WARNING ======================"
 	@echo "This board uses SPI driver from drivers/spi/ without"
 	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index 09e22dc233..549d104016 100644
@@ -9,6 +9,7 @@ obj-y += spi-uclass.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
+obj-$(CONFIG_MXC_SPI) += mxc_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -32,7 +33,6 @@ obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
-obj-$(CONFIG_MXC_SPI) += mxc_spi.o
 obj-$(CONFIG_ATCSPI200_SPI) += atcspi200_spi.o
 obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_PIC32_SPI) += pic32_spi.o
drivers/spi/mxc_spi.c +3 -120

150 lines not on this page · raw message

drivers/spi/spi.c +1 -0
index 8116193d27..5c13f85841 100644
@@ -43,6 +43,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 	defined(CONFIG_DAVINCI_SPI) || \
 	defined(CONFIG_KIRKWOOD_SPI) || \
 	defined(CONFIG_MPC8XXX_SPI) || \
+	defined(CONFIG_MXC_SPI) || \
 	defined(CONFIG_TI_QSPI)
 void spi_cs_activate(struct spi_slave *slave)
 {
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#37 lore raw

PATCH 31/34 spi: Zap omap3_spi driver-related code

In reply to Jagan Teki

Dropped
- omap3_spi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 Makefile                |   2 +-
 drivers/spi/Makefile    |   2 +-
 drivers/spi/omap3_spi.c | 126 ----------------------------------------
 drivers/spi/spi.c       |   1 +
 4 files changed, 3 insertions(+), 128 deletions(-)
Makefile +1 -1
index 3be3bb3118..00f0117b16 100644
@@ -920,7 +920,7 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 endif
 ifeq ($(CONFIG_DM_SPI),)
 ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) $(CONFIG_MPC8XXX_SPI) \
-	       $(CONFIG_MXC_SPI) $(CONFIG_TI_QSPI),y),y)
+	       $(CONFIG_MXC_SPI) $(CONFIG_OMAP3_SPI) $(CONFIG_TI_QSPI),y),y)
 	@echo "===================== WARNING ======================"
 	@echo "This board uses SPI driver from drivers/spi/ without"
 	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index 549d104016..7de209830e 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
 obj-$(CONFIG_MXC_SPI) += mxc_spi.o
+obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_SANDBOX) += spi-emul-uclass.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SPI_MEM) += spi-mem.o
@@ -34,7 +35,6 @@ obj-$(CONFIG_ICH_SPI) +=  ich.o
 obj-$(CONFIG_MT7621_SPI) += mt7621_spi.o
 obj-$(CONFIG_MVEBU_A3700_SPI) += mvebu_a3700_spi.o
 obj-$(CONFIG_ATCSPI200_SPI) += atcspi200_spi.o
-obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_PIC32_SPI) += pic32_spi.o
 obj-$(CONFIG_PL022_SPI) += pl022_spi.o
 obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o
drivers/spi/omap3_spi.c +0 -126

141 lines not on this page · raw message

drivers/spi/spi.c +1 -0
index 5c13f85841..7f5863f904 100644
@@ -44,6 +44,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 	defined(CONFIG_KIRKWOOD_SPI) || \
 	defined(CONFIG_MPC8XXX_SPI) || \
 	defined(CONFIG_MXC_SPI) || \
+	defined(CONFIG_OMAP3_SPI) || \
 	defined(CONFIG_TI_QSPI)
 void spi_cs_activate(struct spi_slave *slave)
 {
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#38 lore raw

PATCH 32/34 spi: Zap atmel_spi driver-related code

In reply to Jagan Teki

Dropped
- atmel_spi driver
- SPI, SPI flash CONFIG-items
- CMD_SPI, CMD_SF..etc

Dropped becuase
- no active updates
- no dm conversion
- no reponse for dm converted patch
- driver-model migration expiry

---
 Makefile                |   5 +-
 drivers/spi/Makefile    |   2 +-
 drivers/spi/atmel_spi.c | 198 ----------------------------------------
 drivers/spi/spi.c       |   1 +
 4 files changed, 5 insertions(+), 201 deletions(-)
Makefile +3 -2
index 00f0117b16..502a8e15f8 100644
@@ -919,8 +919,9 @@ ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
 	@echo "===================================================="
 endif
 ifeq ($(CONFIG_DM_SPI),)
-ifeq ($(filter $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) $(CONFIG_MPC8XXX_SPI) \
-	       $(CONFIG_MXC_SPI) $(CONFIG_OMAP3_SPI) $(CONFIG_TI_QSPI),y),y)
+ifeq ($(filter $(CONFIG_ATMEL_SPI) $(CONFIG_DAVINCI_SPI) $(CONFIG_KIRKWOOD_SPI) \
+	       $(CONFIG_MPC8XXX_SPI) $(CONFIG_MXC_SPI) $(CONFIG_OMAP3_SPI) \
+	       $(CONFIG_TI_QSPI),y),y)
 	@echo "===================== WARNING ======================"
 	@echo "This board uses SPI driver from drivers/spi/ without"
 	@echo "enabling CONFIG_DM_SPI. Please enable CONFIG_DM_SPI"
drivers/spi/Makefile +1 -1
index 7de209830e..1c2d8c0d15 100644
@@ -6,6 +6,7 @@
 # There are many options which enable SPI, so make this library available
 ifdef CONFIG_DM_SPI
 obj-y += spi-uclass.o
+obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
@@ -21,7 +22,6 @@ endif
 
 obj-$(CONFIG_ALTERA_SPI) += altera_spi.o
 obj-$(CONFIG_ATH79_SPI) += ath79_spi.o
-obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 obj-$(CONFIG_BCM63XX_HSSPI) += bcm63xx_hsspi.o
 obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
 obj-$(CONFIG_BCMSTB_SPI) += bcmstb_spi.o
drivers/spi/atmel_spi.c +0 -198

214 lines not on this page · raw message

drivers/spi/spi.c +1 -0
index 7f5863f904..3fc4db1dba 100644
@@ -40,6 +40,7 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 }
 
 #if !defined(CONFIG_DM_SPI) && \
+	defined(CONFIG_ATMEL_SPI) || \
 	defined(CONFIG_DAVINCI_SPI) || \
 	defined(CONFIG_KIRKWOOD_SPI) || \
 	defined(CONFIG_MPC8XXX_SPI) || \
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#39 lore raw

PATCH 33/34 spi: fsl_dspi: Drop non-dm code

In reply to Jagan Teki

Look like all defconfigs are using DM_SPI, but it may grow the size if enable it globally. but due to DM_SPI migration policy remove non-dm code, and will discuss footprint issues if any?

---
 drivers/spi/fsl_dspi.c | 132 -----------------------------------------
 1 file changed, 132 deletions(-)
drivers/spi/fsl_dspi.c +0 -132
index 764c94215e..2e1cf22eb0 100644
@@ -97,13 +97,6 @@ struct fsl_dspi_priv {
 	struct dspi *regs;
 };
 
-#ifndef CONFIG_DM_SPI
-struct fsl_dspi {
-	struct spi_slave slave;
-	struct fsl_dspi_priv priv;
-};
-#endif
-
 __weak void cpu_dspi_port_conf(void)
 {
 }
@@ -389,131 +382,7 @@ static int fsl_dspi_cfg_speed(struct fsl_dspi_priv *priv, uint speed)
 
 	return 0;
 }
-#ifndef CONFIG_DM_SPI
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-	if (((cs >= 0) && (cs < 8)) && ((bus >= 0) && (bus < 8)))
-		return 1;
-	else
-		return 0;
-}
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-				  unsigned int max_hz, unsigned int mode)
-{
-	struct fsl_dspi *dspi;
-	uint mcr_cfg_val;
-
-	dspi = spi_alloc_slave(struct fsl_dspi, bus, cs);
-	if (!dspi)
-		return NULL;
-
-	cpu_dspi_port_conf();
-
-#ifdef CONFIG_SYS_FSL_DSPI_BE
-	dspi->priv.flags |= DSPI_FLAG_REGMAP_ENDIAN_BIG;
-#endif
-
-	dspi->priv.regs = (struct dspi *)MMAP_DSPI;
-
-#ifdef CONFIG_M68K
-	dspi->priv.bus_clk = gd->bus_clk;
-#else
-	dspi->priv.bus_clk = mxc_get_clock(MXC_DSPI_CLK);
-#endif
-	dspi->priv.speed_hz = FSL_DSPI_DEFAULT_SCK_FREQ;
-
-	/* default: all CS signals inactive state is high */
-	mcr_cfg_val = DSPI_MCR_MSTR | DSPI_MCR_PCSIS_MASK |
-		DSPI_MCR_CRXF | DSPI_MCR_CTXF;
-	fsl_dspi_init_mcr(&dspi->priv, mcr_cfg_val);
-
-	for (i = 0; i < FSL_DSPI_MAX_CHIPSELECT; i++)
-		dspi->priv.ctar_val[i] = DSPI_CTAR_DEFAULT_VALUE;
-
-#ifdef CONFIG_SYS_DSPI_CTAR0
-	if (FSL_DSPI_MAX_CHIPSELECT > 0)
-		dspi->priv.ctar_val[0] = CONFIG_SYS_DSPI_CTAR0;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR1
-	if (FSL_DSPI_MAX_CHIPSELECT > 1)
-		dspi->priv.ctar_val[1] = CONFIG_SYS_DSPI_CTAR1;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR2
-	if (FSL_DSPI_MAX_CHIPSELECT > 2)
-		dspi->priv.ctar_val[2] = CONFIG_SYS_DSPI_CTAR2;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR3
-	if (FSL_DSPI_MAX_CHIPSELECT > 3)
-		dspi->priv.ctar_val[3] = CONFIG_SYS_DSPI_CTAR3;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR4
-	if (FSL_DSPI_MAX_CHIPSELECT > 4)
-		dspi->priv.ctar_val[4] = CONFIG_SYS_DSPI_CTAR4;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR5
-	if (FSL_DSPI_MAX_CHIPSELECT > 5)
-		dspi->priv.ctar_val[5] = CONFIG_SYS_DSPI_CTAR5;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR6
-	if (FSL_DSPI_MAX_CHIPSELECT > 6)
-		dspi->priv.ctar_val[6] = CONFIG_SYS_DSPI_CTAR6;
-#endif
-#ifdef CONFIG_SYS_DSPI_CTAR7
-	if (FSL_DSPI_MAX_CHIPSELECT > 7)
-		dspi->priv.ctar_val[7] = CONFIG_SYS_DSPI_CTAR7;
-#endif
 
-	fsl_dspi_cfg_speed(&dspi->priv, max_hz);
-
-	/* configure transfer mode */
-	fsl_dspi_cfg_ctar_mode(&dspi->priv, cs, mode);
-
-	/* configure active state of CSX */
-	fsl_dspi_cfg_cs_active_state(&dspi->priv, cs, mode);
-
-	return &dspi->slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-	free(slave);
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-	uint sr_val;
-	struct fsl_dspi *dspi = (struct fsl_dspi *)slave;
-
-	cpu_dspi_claim_bus(slave->bus, slave->cs);
-
-	fsl_dspi_clr_fifo(&dspi->priv);
-
-	/* check module TX and RX status */
-	sr_val = dspi_read32(dspi->priv.flags, &dspi->priv.regs->sr);
-	if ((sr_val & DSPI_SR_TXRXS) != DSPI_SR_TXRXS) {
-		debug("DSPI RX/TX not ready!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-	struct fsl_dspi *dspi = (struct fsl_dspi *)slave;
-
-	dspi_halt(&dspi->priv, 1);
-	cpu_dspi_release_bus(slave->bus.slave->cs);
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
-	     void *din, unsigned long flags)
-{
-	struct fsl_dspi *dspi = (struct fsl_dspi *)slave;
-	return dspi_xfer(&dspi->priv, slave->cs, bitlen, dout, din, flags);
-}
-#else
 static int fsl_dspi_child_pre_probe(struct udevice *dev)
 {
 	struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
@@ -720,4 +589,3 @@ U_BOOT_DRIVER(fsl_dspi) = {
 	.child_pre_probe = fsl_dspi_child_pre_probe,
 	.bind = fsl_dspi_bind,
 };
-#endif
Signature · 1 line
2.18.0.321.gffc6fa0e3
author
#40 lore raw

PATCH 34/34 dm: MIGRATION: spi: Update SPI driver status

In reply to Jagan Teki

Update the spi driver dm-conversion status.

---
 doc/driver-model/MIGRATION.txt | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
doc/driver-model/MIGRATION.txt +1 -16
index 5ebefd608b..cfa71cc133 100644
@@ -30,25 +30,10 @@ Status: In progress
 Deadline: 2018.09
 
 No dm conversion yet:
-	drivers/spi/cf_spi.c
 	drivers/spi/fsl_espi.c
-	drivers/spi/lpc32xx_ssp.c
-	drivers/spi/mpc8xx_spi.c
-	drivers/spi/mpc8xxx_spi.c
-	drivers/spi/mxs_spi.c
-	drivers/spi/sh_qspi.c
-	drivers/spi/sh_spi.c
-	drivers/spi/soft_spi_legacy.c
 
 Partially converted:
-	drivers/spi/atcspi200_spi.c
-	drivers/spi/davinci_spi.c
-	drivers/spi/fsl_dspi.c
-	drivers/spi/fsl_qspi.c
-	drivers/spi/kirkwood_spi.c
-	drivers/spi/mxc_spi.c
-	drivers/spi/omap3_spi.c
-	drivers/spi/ti_qspi.c
+	drivers/spi/sh_qspi.c
 
 --
 Jagan Teki <[email protected]>
Signature · 1 line
2.18.0.321.gffc6fa0e3