Re: [PATCH] spi: erase pointer to drvdata on removal
Hi Mark, Grant, > On Mon, 14 Jan 2013 02:51:45 +, Mark Brown > wrote: > > On Thu, Nov 01, 2012 at 02:05:36PM -0400, Vivien Didelot wrote: > > > As for i2c-core, let the SPI core handle the removal of the > > > device's > > > drvdata, after a remove() or a probe() failure. > > > > Any driver that notices this change is buggy, the driver shouldn't > > use a drvdata value that it didn't set. I had thought this stuff > > had > > all been removed from I2C and either dropped or factored out into > > the > > driver core... > > Looks to me like __device_release_driver() in drivers/base/dd.c > already > does this. > > g. You are right, I figured this out after the resend of this patch, see my reply here: https://lkml.org/lkml/2012/12/4/224 -Vivien -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
[PATCH 2/2] spi: spi-mpc512x-psc: add support for gpio chip selects
Currently the driver only uses one internal chip select. Add support for gpio chip selects configured by gpio specifiers in the device tree. Signed-off-by: Anatolij Gustschin --- drivers/spi/spi-mpc512x-psc.c | 80 ++--- 1 files changed, 75 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 89480b2..4b2f391 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,8 @@ struct mpc512x_psc_spi { spinlock_t lock;/* Message queue lock */ struct completion done; + int num_cs; + int chipselects[0]; }; /* controller state */ @@ -277,6 +280,7 @@ static int mpc512x_psc_spi_setup(struct spi_device *spi) { struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); struct mpc512x_psc_spi_cs *cs = spi->controller_state; + int gpio = mps->chipselects[spi->chip_select]; unsigned long flags; if (spi->bits_per_word % 8) @@ -292,6 +296,9 @@ static int mpc512x_psc_spi_setup(struct spi_device *spi) cs->bits_per_word = spi->bits_per_word; cs->speed_hz = spi->max_speed_hz; + if (gpio_is_valid(gpio)) + gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); + spin_lock_irqsave(&mps->lock, flags); if (!mps->busy) mpc512x_psc_spi_deactivate_cs(spi); @@ -405,6 +412,27 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id) return IRQ_NONE; } +static void mpc512x_spi_cs_control(struct spi_device *spi, bool on) +{ + struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); + int gpio = mps->chipselects[spi->chip_select]; + + gpio_set_value(gpio, on); +} + +static int mpc512x_spi_cs_num(struct device *dev) +{ + int num_cs, ret; + + ret = of_property_read_u32(dev->of_node, "num-cs", &num_cs); + if (ret < 0) { + dev_warn(dev, "no num-cs property\n"); + return of_gpio_named_count(dev->of_node, "cs-gpios"); + } + + return num_cs; +} + /* bus_num is used only for the case dev->platform_data == NULL */ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, u32 size, unsigned int irq, @@ -415,8 +443,17 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, struct spi_master *master; int ret; void *tempp; + int i = 0, max_cs_num = 0; + int use_internal_cs = 0; + int num_cs; + + num_cs = mpc512x_spi_cs_num(dev); + if (!num_cs) + use_internal_cs = 1; - master = spi_alloc_master(dev, sizeof *mps); + dev_dbg(dev, "using %d gpio chipselects\n", num_cs); + + master = spi_alloc_master(dev, sizeof(*mps) + sizeof(int) * num_cs); if (master == NULL) return -ENOMEM; @@ -425,12 +462,14 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, mps->irq = irq; if (pdata == NULL) { - dev_err(dev, "probe called without platform data, no " - "cs_control function will be called\n"); - mps->cs_control = NULL; mps->sysclk = 0; master->bus_num = bus_num; - master->num_chipselect = 255; + if (use_internal_cs) { + mps->cs_control = NULL; + master->num_chipselect = 1; + } else { + mps->cs_control = mpc512x_spi_cs_control; + } } else { mps->cs_control = pdata->cs_control; mps->sysclk = pdata->sysclk; @@ -438,6 +477,28 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, master->num_chipselect = pdata->max_chipselect; } + if (!pdata && !use_internal_cs) { + for (i = 0; i < num_cs; i++) { + int cs_gpio = of_get_named_gpio(dev->of_node, + "cs-gpios", i); + + dev_dbg(dev, "cs %d: gpio %d\n", i, cs_gpio); + mps->chipselects[i] = cs_gpio; + if (!gpio_is_valid(cs_gpio)) + continue; + + max_cs_num = max(max_cs_num, cs_gpio); + ret = gpio_request(mps->chipselects[i], + "psc-spi cs"); + if (ret) { + dev_err(dev, "can't get CS gpio: %d\n", ret); + goto free_cs_gpios; + } + } + master->num_chipselect = max_cs_num; + mps->num_cs = num_cs; + } + maste
[PATCH 1/2] spi: spi-mpc512x-psc: init mode bits supported by the driver
The driver should setup mode bits it supports, otherwise adding an SPI device might fail even if the driver supports the requested SPI mode. Signed-off-by: Anatolij Gustschin --- drivers/spi/spi-mpc512x-psc.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 88e5441..89480b2 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -438,6 +438,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, master->num_chipselect = pdata->max_chipselect; } + master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; master->setup = mpc512x_psc_spi_setup; master->transfer = mpc512x_psc_spi_transfer; master->cleanup = mpc512x_psc_spi_cleanup; -- 1.7.5.4 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [PATCH v2 01/10] spi: tegra: Do not use clock name to get clock
On Fri, 11 Jan 2013 13:58:28 -0700, Stephen Warren wrote: > On 01/11/2013 01:01 AM, Prashant Gaikwad wrote: > > Since Tegra spi devices do not have multiple clocks, no need to use > > clock name to get the clock. > > Cc'ing in the SPI maintainers as an FYI and for Acks; this patch needs > to go through the Tegra tree due to dependencies. Acked-by: Grant Likely No problem merging it via the Tegra tree. g. -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [PATCH] spi: erase pointer to drvdata on removal
On Mon, 14 Jan 2013 02:51:45 +, Mark Brown wrote: > On Thu, Nov 01, 2012 at 02:05:36PM -0400, Vivien Didelot wrote: > > As for i2c-core, let the SPI core handle the removal of the device's > > drvdata, after a remove() or a probe() failure. > > Any driver that notices this change is buggy, the driver shouldn't > use a drvdata value that it didn't set. I had thought this stuff had > all been removed from I2C and either dropped or factored out into the > driver core... Looks to me like __device_release_driver() in drivers/base/dd.c already does this. g. -- Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd. -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
[SPAM] 代/开――发/票
您好: 现本公司有一部分专用税――票代开; 贵公司如有需要,欢迎您的来电与我联系: 负责人:张先生(0)15989349144 -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [PATCH] MAINTAINERS: Add myself as a backup maintainer for SPI
On Mon, Jan 14, 2013 at 2:32 AM, Mark Brown wrote: > Grant said he would find it helpful for me to continue handling some of > the legwork for SPI so add myself to MAINTAINERS so I get CCed on > patches. > > Signed-off-by: Mark Brown Acked-by: Grant Likely > --- > MAINTAINERS |1 + > 1 file changed, 1 insertion(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index ae9f8b8..6332eff 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -7391,6 +7391,7 @@ F:drivers/clk/spear/ > > SPI SUBSYSTEM > M: Grant Likely > +M: Mark Brown > L: spi-devel-general@lists.sourceforge.net > Q: http://patchwork.kernel.org/project/spi-devel-general/list/ > T: git git://git.secretlab.ca/git/linux-2.6.git > -- > 1.7.10.4 > -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 ___ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general