From: Raffaele Recalcati <lamiaposta71@gmail.com>
To: davinci-linux-open-source@linux.davincidsp.com
Cc: spi-devel-general@lists.sourceforge.net,
David Brownell <dbrownell@users.sourceforge.net>,
Russell King <linux@arm.linux.org.uk>,
Thomas Koeller <thomas.koeller@baslerweb.com>,
Sudhakar Rajashekhara <sudhakar.raj@ti.com>,
linux-kernel@vger.kernel.org, Sandeep Paulraj <s-paulraj@ti.com>,
Grant Likely <grant.likely@secretlab.ca>,
Davide Bonfanti <davide.bonfanti@bticino.it>,
Raffaele Recalcati <raffaele.recalcati@bticino.it>,
linux-arm-kernel@lists.infradead.org,
Cyril Chemparathy <cyril@ti.com>,
Philby John <pjohn@in.mvista.com>,
Miguel Aguilar <miguel.aguilar@ridgerun.com>
Subject: [PATCH] spi: davinci: Added support for chip select using gpio
Date: Mon, 28 Jun 2010 08:47:35 +0200 [thread overview]
Message-ID: <1277707655-3468-1-git-send-email-lamiaposta71@gmail.com> (raw)
From: Raffaele Recalcati <raffaele.recalcati@bticino.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@bticino.it>
Signed-off-by: Davide Bonfanti <davide.bonfanti@bticino.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
next reply other threads:[~2010-06-28 6:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-28 6:47 Raffaele Recalcati [this message]
2010-06-30 23:03 ` [PATCH] spi: davinci: Added support for chip select using gpio Grant Likely
2010-07-01 5:59 ` Rif: " raffaele.recalcati
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=1277707655-3468-1-git-send-email-lamiaposta71@gmail.com \
--to=lamiaposta71@gmail.com \
--cc=cyril@ti.com \
--cc=davide.bonfanti@bticino.it \
--cc=davinci-linux-open-source@linux.davincidsp.com \
--cc=dbrownell@users.sourceforge.net \
--cc=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=miguel.aguilar@ridgerun.com \
--cc=pjohn@in.mvista.com \
--cc=raffaele.recalcati@bticino.it \
--cc=s-paulraj@ti.com \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=sudhakar.raj@ti.com \
--cc=thomas.koeller@baslerweb.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).