From: Ben Gamari <bgamari.foss@gmail.com>
To: Raju Sana <venkat.rajuece@gmail.com>
Cc: beagleboard@googlegroups.com, linux-omap@vger.kernel.org,
spi-devel-general@lists.sourceforge.net,
Ben Gamari <bgamari.foss@gmail.com>
Subject: [PATCH] mcspi: Add support for GPIO chip select lines
Date: Tue, 30 Aug 2011 09:50:54 -0400 [thread overview]
Message-ID: <1314712254-27199-2-git-send-email-bgamari.foss@gmail.com> (raw)
In-Reply-To: <1314712254-27199-1-git-send-email-bgamari.foss@gmail.com>
Many applications require more chip select lines than the board or
processor allow. Introduce a mechanism to allow use of GPIO pins as
chip select lines with the McSPI controller. To use this
tionality,
one simply provides a table mapping CS line numbers to GPIO numbers
omap2_mcspi_platform_config.cs_gpios.
Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>
---
arch/arm/plat-omap/include/plat/mcspi.h | 1 +
drivers/spi/omap2_mcspi.c | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/arch/arm/plat-omap/include/plat/mcspi.h b/arch/arm/plat-omap/include/plat/mcspi.h
index 3d51b18..c5670f2 100644
--- a/arch/arm/plat-omap/include/plat/mcspi.h
+++ b/arch/arm/plat-omap/include/plat/mcspi.h
@@ -10,6 +10,7 @@
struct omap2_mcspi_platform_config {
unsigned short num_cs;
unsigned int regs_offset;
+ int *cs_gpios;
};
struct omap2_mcspi_dev_attr {
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index f41c906..20dec5d 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -36,6 +36,7 @@
#include <linux/pm_runtime.h>
#include <linux/spi/spi.h>
+#include <linux/gpio.h>
#include <plat/dma.h>
#include <plat/clock.h>
@@ -121,6 +122,7 @@ struct omap2_mcspi {
/* SPI1 has 4 channels, while SPI2 has 2 */
struct omap2_mcspi_dma *dma_channels;
struct device *dev;
+ int *cs_gpios;
};
struct omap2_mcspi_cs {
@@ -227,7 +229,11 @@ static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable)
static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active)
{
u32 l;
+ struct omap2_mcspi* mcspi = spi_master_get_devdata(spi->master);
+ if (mcspi->cs_gpios)
+ gpio_set_value(mcspi->cs_gpios[spi->chip_select], cs_active);
+ // TXS times out unless we force the CHCONF reg as well
l = mcspi_cached_chconf0(spi);
MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
mcspi_write_chconf0(spi, l);
@@ -1088,6 +1094,8 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
struct omap2_mcspi *mcspi;
struct resource *r;
int status = 0, i;
+ struct omap2_mcspi_platform_config* pconfig = pdev->dev.platform_data;
+ int num_dma;
master = spi_alloc_master(&pdev->dev, sizeof *mcspi);
if (master == NULL) {
@@ -1110,6 +1118,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
mcspi = spi_master_get_devdata(master);
mcspi->master = master;
+ if (pconfig && pconfig->cs_gpios) {
+ mcspi->cs_gpios = pconfig->cs_gpios;
+ num_dma = 1;
+ } else {
+ mcspi->cs_gpios = NULL;
+ num_dma = master->num_chipselect;
+ }
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (r == NULL) {
@@ -1139,14 +1154,14 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&mcspi->msg_queue);
INIT_LIST_HEAD(&omap2_mcspi_ctx[master->bus_num - 1].cs);
- mcspi->dma_channels = kcalloc(master->num_chipselect,
+ mcspi->dma_channels = kcalloc(num_dma,
sizeof(struct omap2_mcspi_dma),
GFP_KERNEL);
if (mcspi->dma_channels == NULL)
goto err2;
- for (i = 0; i < master->num_chipselect; i++) {
+ for (i = 0; i < num_dma; i++) {
char dma_ch_name[14];
struct resource *dma_res;
--
1.7.4.1
next prev parent reply other threads:[~2011-08-30 13:51 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-20 19:47 (no subject) Ben Gamari
2010-01-21 0:04 ` Ben Dooks
2010-01-21 0:04 ` (no subject) Ben Dooks
2010-01-21 0:04 ` Ben Dooks
2010-01-22 15:53 ` Re: Ben Gamari
2010-01-28 4:10 ` McSPI questions pertaining to GPIO chip select support Ben Gamari
2010-01-28 4:10 ` Ben Gamari
2010-01-28 4:15 ` Bill Gatliff
2010-01-28 4:25 ` Ben Gamari
2010-01-28 4:27 ` Bill Gatliff
2010-01-28 4:33 ` jassi brar
2010-12-21 17:56 ` [RFC PATCH] GPIO chip select support for McSPI Ben Gamari
[not found] ` <1b68c6791001272033q60dd31dbif4de285cd9bac83d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-29 0:32 ` McSPI questions pertaining to GPIO chip select support Ben Gamari
2010-01-29 1:09 ` jassi brar
[not found] ` <1b68c6791001281709l7d11da30lee486632e85b99cb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-29 1:58 ` Ben Gamari
2010-12-21 17:56 ` [RFC PATCH] GPIO chip select support for McSPI Ben Gamari
2010-12-21 17:56 ` [PATCH] mcspi: Add support for GPIO chip select lines Ben Gamari
2010-12-21 17:56 ` Ben Gamari
2010-12-23 19:59 ` Tony Lindgren
2010-12-23 21:38 ` Grant Likely
2010-12-23 23:09 ` Ben Gamari
2010-12-24 0:37 ` Grant Likely
2010-12-24 2:27 ` Ben Gamari
2010-12-24 3:28 ` Grant Likely
2010-12-24 6:05 ` Ben Gamari
2011-02-12 8:33 ` Grant Likely
2011-02-13 22:07 ` Ben Gamari
2011-08-30 10:14 ` McSPI questions pertaining to GPIO chip select support Raju Sana
2011-08-30 13:50 ` Ben Gamari
2011-08-30 13:50 ` Ben Gamari [this message]
2011-08-30 13:52 ` [PATCH] beagledaq: Hack in cs_gpios Ben Gamari
[not found] ` <1314712343-27367-1-git-send-email-bgamari.foss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-09-05 12:42 ` Raju Sana
-- strict thread matches above, loose matches on Subject: below --
2011-03-13 19:04 GPIO chip select support in McSPI Ben Gamari
2011-03-13 19:05 ` [PATCH] mcspi: Add support for GPIO chip select lines Ben Gamari
2011-03-14 19:27 ` Grant Likely
2011-03-15 2:06 ` Ben Gamari
2011-03-15 2:10 ` Grant Likely
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=1314712254-27199-2-git-send-email-bgamari.foss@gmail.com \
--to=bgamari.foss@gmail.com \
--cc=beagleboard@googlegroups.com \
--cc=linux-omap@vger.kernel.org \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=venkat.rajuece@gmail.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 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.