lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1277707655-3468-1-git-send-email-lamiaposta71@gmail.com>
Date:	Mon, 28 Jun 2010 08:47:35 +0200
From:	Raffaele Recalcati <lamiaposta71@...il.com>
To:	davinci-linux-open-source@...ux.davincidsp.com
Cc:	Raffaele Recalcati <raffaele.recalcati@...cino.it>,
	Davide Bonfanti <davide.bonfanti@...cino.it>,
	Russell King <linux@....linux.org.uk>,
	Sandeep Paulraj <s-paulraj@...com>,
	Cyril Chemparathy <cyril@...com>,
	Miguel Aguilar <miguel.aguilar@...gerun.com>,
	Thomas Koeller <thomas.koeller@...lerweb.com>,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	Grant Likely <grant.likely@...retlab.ca>,
	Philby John <pjohn@...mvista.com>,
	Sudhakar Rajashekhara <sudhakar.raj@...com>,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	spi-devel-general@...ts.sourceforge.net
Subject: [PATCH] spi: davinci: Added support for chip select using gpio

From: Raffaele Recalcati <raffaele.recalcati@...cino.it>

    It is not everytime possible, due to hardware constraints,
    to use the hw chip select available on spi port.
    So I add this possibility using a gpio as chip select.
    If controller_data variable is not null it is
    the gpio to be used as chip select.
    The default case is compatible with evmdm365.
    This patch has been developed against the
    http://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git
    git tree and has been tested on bmx board (similar to dm365 evm but with
    gpio as spi chip select).

Signed-off-by: Raffaele Recalcati <raffaele.recalcati@...cino.it>
Signed-off-by: Davide Bonfanti <davide.bonfanti@...cino.it>
---
 arch/arm/mach-davinci/dm365.c |   10 ++++++----
 drivers/spi/davinci_spi.c     |   27 ++++++++++++++++++---------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index a146849..42fd4a4 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -677,10 +677,12 @@ void __init dm365_init_spi0(unsigned chipselect_mask,
 	davinci_cfg_reg(DM365_SPI0_SDO);
 
 	/* not all slaves will be wired up */
-	if (chipselect_mask & BIT(0))
-		davinci_cfg_reg(DM365_SPI0_SDENA0);
-	if (chipselect_mask & BIT(1))
-		davinci_cfg_reg(DM365_SPI0_SDENA1);
+	if  (!((unsigned long) info->controller_data)) {
+		if (chipselect_mask & BIT(0))
+			davinci_cfg_reg(DM365_SPI0_SDENA0);
+		if (chipselect_mask & BIT(1))
+			davinci_cfg_reg(DM365_SPI0_SDENA1);
+	}
 
 	spi_register_board_info(info, len);
 
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 95afb6b..621ae46 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -29,6 +29,7 @@
 #include <linux/spi/spi_bitbang.h>
 #include <linux/slab.h>
 
+#include <mach/gpio.h>
 #include <mach/spi.h>
 #include <mach/edma.h>
 
@@ -270,18 +271,26 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
 	pdata = davinci_spi->pdata;
 
 	/*
-	 * Board specific chip select logic decides the polarity and cs
-	 * line for the controller
-	 */
+	* Board specific chip select logic decides the polarity and cs
+	* line for the controller
+	*/
 	if (value == BITBANG_CS_INACTIVE) {
-		set_io_bits(davinci_spi->base + SPIDEF, CS_DEFAULT);
-
-		data1_reg_val |= CS_DEFAULT << SPIDAT1_CSNR_SHIFT;
-		iowrite32(data1_reg_val, davinci_spi->base + SPIDAT1);
-
+		if  ((unsigned long) spi->controller_data) {
+			gpio_set_value(spi->controller_data, \
+				!(spi->mode & SPI_CS_HIGH));
+		} else {
+			set_io_bits(davinci_spi->base + SPIDEF, CS_DEFAULT);
+
+			data1_reg_val |= CS_DEFAULT << SPIDAT1_CSNR_SHIFT;
+			iowrite32(data1_reg_val, davinci_spi->base + SPIDAT1);
+		}
 		while ((ioread32(davinci_spi->base + SPIBUF)
-					& SPIBUF_RXEMPTY_MASK) == 0)
+				& SPIBUF_RXEMPTY_MASK) == 0)
 			cpu_relax();
+	} else {
+		if  ((unsigned long) spi->controller_data)
+			gpio_set_value(spi->controller_data, \
+				(spi->mode & SPI_CS_HIGH));
 	}
 }
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ