From: Ben Gamari <bgamari.foss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: beagleboard <beagleboard-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>,
linux-omap <linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
David Brownell
<dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
Eric Miao <eric.miao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Michael Henn
Subject: [PATCH] mcspi: Add support for GPIO chip select lines
Date: Tue, 21 Dec 2010 12:56:35 -0500 [thread overview]
Message-ID: <1292954195-20204-2-git-send-email-bgamari.foss__14677.334301132$1292954249$gmane$org@gmail.com> (raw)
In-Reply-To: <1b68c6791001272033q60dd31dbif4de285cd9bac83d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
This mechanism is in large part stolen from the s3c64xx-spi module. To
use this functionality, one simply must define a set_level function to
set the CS state and a omap2_mcspi_csinfo struct for each chip select in
the board file.
Each spi_board_info.controller_data should then be set
to point to the appropriate csinfo struct. This will cause the driver to
call the csinfo->set_level function instead of toggling the McSPI chip
select lines.
Signed-off-by: Ben Gamari <bgamari.foss-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/arm/plat-omap/include/plat/mcspi.h | 14 ++++++++++++++
drivers/spi/omap2_mcspi.c | 14 +++++++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/arch/arm/plat-omap/include/plat/mcspi.h b/arch/arm/plat-omap/include/plat/mcspi.h
index 1254e49..ab84b8d 100644
--- a/arch/arm/plat-omap/include/plat/mcspi.h
+++ b/arch/arm/plat-omap/include/plat/mcspi.h
@@ -1,6 +1,20 @@
#ifndef _OMAP2_MCSPI_H
#define _OMAP2_MCSPI_H
+/**
+ * struct omap2_mcspi_csinfo - Chip Select description
+ * @line: Custom 'identity' of the CS line
+ * @set_level: Function to set the state of a given CS line
+ *
+ * This is to allow use of GPIO lines as CS lines. Allocate and initialize one
+ * in the machine init code and make spi_board_info.controller_data point to
+ * it.
+ */
+struct omap2_mcspi_csinfo {
+ unsigned line;
+ void (*set_level)(unsigned line_id, int lvl);
+};
+
struct omap2_mcspi_platform_config {
unsigned short num_cs;
};
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index 2a651e6..92ccbd6 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -35,6 +35,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
+#include <linux/gpio.h>
#include <plat/dma.h>
#include <plat/clock.h>
@@ -235,11 +236,14 @@ 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;
-
- l = mcspi_cached_chconf0(spi);
- MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
- mcspi_write_chconf0(spi, l);
+ if (spi->controller_data) {
+ struct omap2_mcspi_csinfo *csinfo = spi->controller_data;
+ (*csinfo->set_level)(csinfo->line, cs_active);
+ } else {
+ u32 l = mcspi_cached_chconf0(spi);
+ MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active);
+ mcspi_write_chconf0(spi, l);
+ }
}
static void omap2_mcspi_set_master_mode(struct spi_master *master)
--
1.7.1
------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months. Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
next prev parent reply other threads:[~2010-12-21 17:56 UTC|newest]
Thread overview: 29+ 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
[not found] ` <1264651770-sup-5197@ben-laptop>
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
[not found] ` <1b68c6791001272033q60dd31dbif4de285cd9bac83d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-29 0:32 ` 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 ` Ben Gamari [this message]
[not found] ` <1292954195-20204-2-git-send-email-bgamari.foss@gmail.com>
2010-12-23 19:59 ` [PATCH] mcspi: Add support for GPIO chip select lines 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 ` [PATCH] mcspi: Add support for GPIO chip select lines Ben Gamari
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
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='1292954195-20204-2-git-send-email-bgamari.foss__14677.334301132$1292954249$gmane$org@gmail.com' \
--to=bgamari.foss-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=beagleboard-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=eric.miao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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).