From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [PATCH] mcspi: Add support for GPIO chip select lines Date: Thu, 23 Dec 2010 14:38:57 -0700 Message-ID: References: <1b68c6791001272033q60dd31dbif4de285cd9bac83d@mail.gmail.com> <1292954195-20204-2-git-send-email-bgamari.foss@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: beagleboard , linux-omap , David Brownell , Eric Miao , Michael Hennerich , spi-devel-general To: Ben Gamari Return-path: In-Reply-To: <1292954195-20204-2-git-send-email-bgamari.foss@gmail.com> Sender: linux-omap-owner@vger.kernel.org List-Id: linux-spi.vger.kernel.org On Tue, Dec 21, 2010 at 10:56 AM, Ben Gamari w= rote: > This mechanism is in large part stolen from the s3c64xx-spi module. T= o > use this functionality, one simply must define a set_level function t= o > 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 chi= p > select lines. > > Signed-off-by: Ben Gamari I'd rather see the spi driver modified to use the gpio api directly. The drivers are already tending in that direction and it doesn't require machine specific set_level functions to be defined. g. > --- > =A0arch/arm/plat-omap/include/plat/mcspi.h | =A0 14 ++++++++++++++ > =A0drivers/spi/omap2_mcspi.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 14 +++= ++++++----- > =A02 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 @@ > =A0#ifndef _OMAP2_MCSPI_H > =A0#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 init= ialize one > + * in the machine init code and make spi_board_info.controller_data = point to > + * it. > + */ > +struct omap2_mcspi_csinfo { > + =A0 =A0 =A0 =A0unsigned line; > + =A0 =A0 =A0 =A0void (*set_level)(unsigned line_id, int lvl); > +}; > + > =A0struct omap2_mcspi_platform_config { > =A0 =A0 =A0 =A0unsigned short =A0num_cs; > =A0}; > 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 @@ > =A0#include > > =A0#include > +#include > > =A0#include > =A0#include > @@ -235,11 +236,14 @@ static void omap2_mcspi_set_enable(const struct= spi_device *spi, int enable) > > =A0static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_ac= tive) > =A0{ > - =A0 =A0 =A0 u32 l; > - > - =A0 =A0 =A0 l =3D mcspi_cached_chconf0(spi); > - =A0 =A0 =A0 MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active); > - =A0 =A0 =A0 mcspi_write_chconf0(spi, l); > + =A0 =A0 =A0 if (spi->controller_data) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct omap2_mcspi_csinfo *csinfo =3D s= pi->controller_data; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (*csinfo->set_level)(csinfo->line, cs_a= ctive); > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 u32 l =3D mcspi_cached_chconf0(spi); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE= , cs_active); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mcspi_write_chconf0(spi, l); > + =A0 =A0 =A0 } > =A0} > > =A0static void omap2_mcspi_set_master_mode(struct spi_master *master) > -- > 1.7.1 > > --=20 Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" i= n the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html