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 27/32] spi: mxc: Drop non-dm code
Date: Sun, 25 Nov 2018 22:58:48 +0530	[thread overview]
Message-ID: <20181125172853.20491-28-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20181125172853.20491-1-jagan@amarulasolutions.com>

Drop the non-dm code, those board which uses non-dm need
to define DM_SPI. u-boot build trigger the warning for
the same.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 Makefile              |   2 +-
 drivers/spi/Makefile  |   2 +-
 drivers/spi/mxc_spi.c | 123 ++----------------------------------------
 3 files changed, 5 insertions(+), 122 deletions(-)

diff --git a/Makefile b/Makefile
index 7c1d934493..3be3bb3118 100644
--- a/Makefile
+++ b/Makefile
@@ -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"
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 49e614e124..c682b014e7 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -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
@@ -33,7 +34,6 @@ 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
 obj-$(CONFIG_ATCSPI200_SPI) += atcspi200_spi.o
 obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_PIC32_SPI) += pic32_spi.o
diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index b2636909ce..f6c6685e7e 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -57,26 +57,6 @@ static inline struct mxc_spi_slave *to_mxc_spi_slave(struct spi_slave *slave)
 	return container_of(slave, struct mxc_spi_slave, slave);
 }
 
-static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
-{
-	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, 1);
-	} else {
-		if (mxcs->gpio > 0)
-			gpio_set_value(mxcs->gpio, mxcs->ss_pol);
-	}
-}
-
-static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs)
-{
-	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, 0);
-	} else {
-		if (mxcs->gpio > 0)
-			gpio_set_value(mxcs->gpio, !(mxcs->ss_pol));
-	}
-}
-
 u32 get_cspi_div(u32 div)
 {
 	int i;
@@ -345,7 +325,7 @@ static int mxc_spi_xfer_internal(struct mxc_spi_slave *mxcs,
 		return -EINVAL;
 
 	if (flags & SPI_XFER_BEGIN)
-		mxc_spi_cs_activate(mxcs);
+		dm_gpio_set_value(&mxcs->ss, 1);
 
 	while (n_bytes > 0) {
 		if (n_bytes < MAX_SPI_BYTES)
@@ -366,9 +346,8 @@ static int mxc_spi_xfer_internal(struct mxc_spi_slave *mxcs,
 		n_bytes -= blk_size;
 	}
 
-	if (flags & SPI_XFER_END) {
-		mxc_spi_cs_deactivate(mxcs);
-	}
+	if (flags & SPI_XFER_END)
+		dm_gpio_set_value(&mxcs->ss, 0);
 
 	return 0;
 }
@@ -391,101 +370,6 @@ static int mxc_spi_claim_bus_internal(struct mxc_spi_slave *mxcs, int cs)
 	return 0;
 }
 
-#ifndef CONFIG_DM_SPI
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
-		void *din, unsigned long flags)
-{
-	struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
-
-	return mxc_spi_xfer_internal(mxcs, bitlen, dout, din, flags);
-}
-
-/*
- * Some SPI devices require active chip-select over multiple
- * transactions, we achieve this using a GPIO. Still, the SPI
- * controller has to be configured to use one of its own chipselects.
- * To use this feature you have to implement board_spi_cs_gpio() to assign
- * a gpio value for each cs (-1 if cs doesn't need to use gpio).
- * You must use some unused on this SPI controller cs between 0 and 3.
- */
-static int setup_cs_gpio(struct mxc_spi_slave *mxcs,
-			 unsigned int bus, unsigned int cs)
-{
-	int ret;
-
-	mxcs->gpio = board_spi_cs_gpio(bus, cs);
-	if (mxcs->gpio == -1)
-		return 0;
-
-	gpio_request(mxcs->gpio, "spi-cs");
-	ret = gpio_direction_output(mxcs->gpio, !(mxcs->ss_pol));
-	if (ret) {
-		printf("mxc_spi: cannot setup gpio %d\n", mxcs->gpio);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static unsigned long spi_bases[] = {
-	MXC_SPI_BASE_ADDRESSES
-};
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-			unsigned int max_hz, unsigned int mode)
-{
-	struct mxc_spi_slave *mxcs;
-	int ret;
-
-	if (bus >= ARRAY_SIZE(spi_bases))
-		return NULL;
-
-	if (max_hz == 0) {
-		printf("Error: desired clock is 0\n");
-		return NULL;
-	}
-
-	mxcs = spi_alloc_slave(struct mxc_spi_slave, bus, cs);
-	if (!mxcs) {
-		puts("mxc_spi: SPI Slave not allocated !\n");
-		return NULL;
-	}
-
-	mxcs->ss_pol = (mode & SPI_CS_HIGH) ? 1 : 0;
-
-	ret = setup_cs_gpio(mxcs, bus, cs);
-	if (ret < 0) {
-		free(mxcs);
-		return NULL;
-	}
-
-	mxcs->base = spi_bases[bus];
-	mxcs->max_hz = max_hz;
-	mxcs->mode = mode;
-
-	return &mxcs->slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-	struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
-
-	free(mxcs);
-}
-
-int spi_claim_bus(struct spi_slave *slave)
-{
-	struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
-
-	return mxc_spi_claim_bus_internal(mxcs, slave->cs);
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-	/* TODO: Shut the controller down */
-}
-#else
-
 static int mxc_spi_probe(struct udevice *bus)
 {
 	struct mxc_spi_slave *plat = bus->platdata;
@@ -575,4 +459,3 @@ U_BOOT_DRIVER(mxc_spi) = {
 	.platdata_auto_alloc_size = sizeof(struct mxc_spi_slave),
 	.probe	= mxc_spi_probe,
 };
-#endif
-- 
2.18.0.321.gffc6fa0e3

  parent 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 ` [U-Boot] [PATCH v2 01/32] spi: davinci: Full dm conversion Jagan Teki
2018-11-26 13:32   ` 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 ` Jagan Teki [this message]
2018-11-25 17:28 ` [U-Boot] [PATCH v2 28/32] spi: omap3: Drop non-dm code 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-28-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.