All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 01/32] spi: davinci: Full dm conversion
Date: Sun, 25 Nov 2018 22:58:22 +0530	[thread overview]
Message-ID: <20181125172853.20491-2-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20181125172853.20491-1-jagan@amarulasolutions.com>

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

Cc: Adam Ford <aford173@gmail.com>
Cc: Vitaly Andrianov <vitalya@ti.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Peter Howard <phoward@gme.net.au>
Cc: Tom Rini <trini@konsulko.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 Makefile                  |   9 +++
 drivers/spi/Makefile      |   2 +-
 drivers/spi/davinci_spi.c | 157 --------------------------------------
 drivers/spi/spi.c         |  38 +++++++++
 4 files changed, 48 insertions(+), 158 deletions(-)

diff --git a/Makefile b/Makefile
index 552687db53..d06cb5c287 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 7242ea7e40..cf5a5cccc0 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -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
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 4d2c106440..c1646f6cdc 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -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
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 22910de0dd..4d1ade797b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -38,3 +38,41 @@ void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
 
 	return ptr;
 }
+
+/**
+ * These are non-dm spi core operations, will remove once all driver
+ * converted into full driver model.
+ */
+__weak void spi_cs_activate(struct spi_slave *slave)
+{
+}
+
+__weak void spi_cs_deactivate(struct spi_slave *slave)
+{
+}
+
+__weak struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+					 unsigned int max_hz,
+					 unsigned int mode)
+{
+	return NULL;
+}
+
+__weak void spi_free_slave(struct spi_slave *slave)
+{
+}
+
+__weak int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+		    const void *dout, void *din, unsigned long flags)
+{
+	return 0;
+}
+
+__weak int spi_claim_bus(struct spi_slave *slave)
+{
+	return 0;
+}
+
+__weak void spi_release_bus(struct spi_slave *slave)
+{
+}
-- 
2.18.0.321.gffc6fa0e3

  reply	other threads:[~2018-11-25 17:28 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-25 17:28 [U-Boot] [PATCH v2 00/32] spi: DM_SPI migration timeout, remainder(2) Jagan Teki
2018-11-25 17:28 ` Jagan Teki [this message]
2018-11-26 13:32   ` [U-Boot] [PATCH v2 01/32] spi: davinci: Full dm conversion Adam Ford
2018-11-26 18:19     ` Jagan Teki
2018-11-26 19:12       ` Adam Ford
2018-11-25 17:28 ` [U-Boot] [PATCH v2 02/32] spi: kirkwood: " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 03/32] spi: ti_qspi: " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 04/32] spi: mpc8xxx: Use short type names Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 05/32] spi: mpc8xxx: Fix comments Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 06/32] spi: mpc8xxx: Rename camel-case variables Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 07/32] spi: mpc8xxx: Fix space after cast Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 08/32] spi: mpc8xxx: Fix function names in strings Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 09/32] spi: mpc8xxx: Replace defines with enums Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 10/32] spi: mpc8xxx: Use IO accessors Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 11/32] spi: mpc8xxx: Simplify if Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 12/32] spi: mpc8xxx: Get rid of is_read Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 13/32] spi: mpc8xxx: Simplify logic a bit Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 14/32] spi: mpc8xxx: Reduce scope of loop variables Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 15/32] spi: mpc8xxx: Make code more readable Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 16/32] spi: mpc8xxx: Rename variable Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 17/32] spi: mpc8xxx: Document LEN setting better Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 18/32] spi: mpc8xxx: Re-order transfer setup Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 19/32] spi: mpc8xxx: Fix if check Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 20/32] spi: mpc8xxx: Use get_timer Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 21/32] spi: mpc8xxx: Convert to DM Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 22/32] spi: Zap cf_spi driver-related code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 23/32] spi: Zap lpc32xx_ssp " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 24/32] spi: Zap mxs_spi " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 25/32] spi: Zap sh_spi " Jagan Teki
2018-11-25 18:06   ` Marek Vasut
2018-11-27  6:05     ` Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 26/32] spi: Zap soft_spi_legacy " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 27/32] spi: mxc: Drop non-dm code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 28/32] spi: omap3: " Jagan Teki
2018-11-26 19:36   ` Adam Ford
2018-11-25 17:28 ` [U-Boot] [PATCH v2 29/32] spi: atmel: " Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 30/32] spi: Zap fsl_espi driver-related code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 31/32] spi: fsl_dspi: Drop non-dm code Jagan Teki
2018-11-25 17:28 ` [U-Boot] [PATCH v2 32/32] dm: MIGRATION: spi: Update SPI driver status Jagan Teki
2018-12-11  1:03   ` Simon Glass
2018-11-26  7:18 ` [U-Boot] [PATCH v2 00/32] spi: DM_SPI migration timeout, remainder(2) Peng Fan
2018-11-27  5:51   ` Jagan Teki
2018-11-27 12:10     ` Marek Vasut
2018-11-28  4:24       ` Heiko Schocher
2018-11-28  4:36         ` Tom Rini
2018-11-27 14:39     ` Stefano Babic
2018-11-27 16:13       ` Tom Rini
2018-11-28  9:33         ` Stefano Babic
2018-11-28 14:59           ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181125172853.20491-2-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.