* [PATCH] spi: sh-msiof: request and set cs-gpio direction to output
@ 2016-07-18 8:57 ` Ulrich Hecht
0 siblings, 0 replies; 5+ messages in thread
From: Ulrich Hecht @ 2016-07-18 8:57 UTC (permalink / raw)
To: geert+renesas
Cc: broonie, linux-spi, linux-renesas-soc, wsa, magnus.damm, Ulrich Hecht
Required for the CS signal to actually be visible to the device.
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
drivers/spi/spi-sh-msiof.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index a7934ab..d4b5772 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -536,15 +536,35 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
!!(spi->mode & SPI_LSB_FIRST),
!!(spi->mode & SPI_CS_HIGH));
- if (spi->cs_gpio >= 0)
- gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
+ if (spi->cs_gpio >= 0 && !spi_get_ctldata(spi)) {
+ int status = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
+
+ if (status)
+ return status;
+ status = gpio_direction_output(spi->cs_gpio,
+ !(spi->mode & SPI_CS_HIGH));
+ if (status) {
+ gpio_free(spi->cs_gpio);
+ return status;
+ }
+
+ spi_set_ctldata(spi, (void *)spi->cs_gpio);
+ }
pm_runtime_put(&p->pdev->dev);
return 0;
}
+static void sh_msiof_spi_cleanup(struct spi_device *spi)
+{
+ if (spi->cs_gpio >= 0)
+ gpio_free(spi->cs_gpio);
+
+ spi_set_ctldata(spi, NULL);
+}
+
static int sh_msiof_prepare_message(struct spi_master *master,
struct spi_message *msg)
{
@@ -1232,6 +1252,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node;
master->num_chipselect = p->info->num_chipselect;
master->setup = sh_msiof_spi_setup;
+ master->cleanup = sh_msiof_spi_cleanup;
master->prepare_message = sh_msiof_prepare_message;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
master->auto_runtime_pm = true;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] spi: sh-msiof: request and set cs-gpio direction to output
@ 2016-07-18 8:57 ` Ulrich Hecht
0 siblings, 0 replies; 5+ messages in thread
From: Ulrich Hecht @ 2016-07-18 8:57 UTC (permalink / raw)
To: geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ
Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA,
wsa-z923LK4zBo2bacvFa/9K2g, magnus.damm-Re5JQEeQqe8AvxtiuMwx3w,
Ulrich Hecht
Required for the CS signal to actually be visible to the device.
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/spi/spi-sh-msiof.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index a7934ab..d4b5772 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -536,15 +536,35 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
!!(spi->mode & SPI_LSB_FIRST),
!!(spi->mode & SPI_CS_HIGH));
- if (spi->cs_gpio >= 0)
- gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
+ if (spi->cs_gpio >= 0 && !spi_get_ctldata(spi)) {
+ int status = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
+
+ if (status)
+ return status;
+ status = gpio_direction_output(spi->cs_gpio,
+ !(spi->mode & SPI_CS_HIGH));
+ if (status) {
+ gpio_free(spi->cs_gpio);
+ return status;
+ }
+
+ spi_set_ctldata(spi, (void *)spi->cs_gpio);
+ }
pm_runtime_put(&p->pdev->dev);
return 0;
}
+static void sh_msiof_spi_cleanup(struct spi_device *spi)
+{
+ if (spi->cs_gpio >= 0)
+ gpio_free(spi->cs_gpio);
+
+ spi_set_ctldata(spi, NULL);
+}
+
static int sh_msiof_prepare_message(struct spi_master *master,
struct spi_message *msg)
{
@@ -1232,6 +1252,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node;
master->num_chipselect = p->info->num_chipselect;
master->setup = sh_msiof_spi_setup;
+ master->cleanup = sh_msiof_spi_cleanup;
master->prepare_message = sh_msiof_prepare_message;
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
master->auto_runtime_pm = true;
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: sh-msiof: request and set cs-gpio direction to output
2016-07-18 8:57 ` Ulrich Hecht
(?)
@ 2016-07-18 12:09 ` Geert Uytterhoeven
2016-09-01 10:08 ` Wolfram Sang
-1 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2016-07-18 12:09 UTC (permalink / raw)
To: Ulrich Hecht
Cc: Geert Uytterhoeven, Mark Brown, linux-spi, Linux-Renesas,
Wolfram Sang, Magnus Damm
Hi Ulrich,
On Mon, Jul 18, 2016 at 10:57 AM, Ulrich Hecht
<ulrich.hecht+renesas@gmail.com> wrote:
> Required for the CS signal to actually be visible to the device.
>
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Thanks, I can confirm this indeed makes cs-gpios work with MSIOF on
Koelsch, hence
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> drivers/spi/spi-sh-msiof.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index a7934ab..d4b5772 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -536,15 +536,35 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
Is there any specific reason you don't do this in .probe(), like spi-efm32
does?
> !!(spi->mode & SPI_LSB_FIRST),
> !!(spi->mode & SPI_CS_HIGH));
>
> - if (spi->cs_gpio >= 0)
> - gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
> + if (spi->cs_gpio >= 0 && !spi_get_ctldata(spi)) {
> + int status = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
devm_gpio_request()...
> +
> + if (status)
> + return status;
>
> + status = gpio_direction_output(spi->cs_gpio,
> + !(spi->mode & SPI_CS_HIGH));
> + if (status) {
> + gpio_free(spi->cs_gpio);
> + return status;
> + }
... or even better, devm_gpio_request_one(), as it allows configuring direction
and initial level in one go.
> +
> + spi_set_ctldata(spi, (void *)spi->cs_gpio);
> + }
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: sh-msiof: request and set cs-gpio direction to output
@ 2016-09-01 10:08 ` Wolfram Sang
0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2016-09-01 10:08 UTC (permalink / raw)
To: Geert Uytterhoeven, Ulrich Hecht
Cc: Mark Brown, linux-spi, Linux-Renesas, Magnus Damm
[-- Attachment #1: Type: text/plain, Size: 2464 bytes --]
On Mon, Jul 18, 2016 at 02:09:03PM +0200, Geert Uytterhoeven wrote:
> Hi Ulrich,
>
> On Mon, Jul 18, 2016 at 10:57 AM, Ulrich Hecht
> <ulrich.hecht+renesas@gmail.com> wrote:
> > Required for the CS signal to actually be visible to the device.
> >
> > Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
>
> Thanks, I can confirm this indeed makes cs-gpios work with MSIOF on
> Koelsch, hence
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
This one doesn't show up in renesas-drivers. What about V2?
Thanks!
>
> > ---
> > drivers/spi/spi-sh-msiof.c | 25 +++++++++++++++++++++++--
> > 1 file changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> > index a7934ab..d4b5772 100644
> > --- a/drivers/spi/spi-sh-msiof.c
> > +++ b/drivers/spi/spi-sh-msiof.c
> > @@ -536,15 +536,35 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
>
> Is there any specific reason you don't do this in .probe(), like spi-efm32
> does?
>
> > !!(spi->mode & SPI_LSB_FIRST),
> > !!(spi->mode & SPI_CS_HIGH));
> >
> > - if (spi->cs_gpio >= 0)
> > - gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
> > + if (spi->cs_gpio >= 0 && !spi_get_ctldata(spi)) {
> > + int status = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
>
> devm_gpio_request()...
>
> > +
> > + if (status)
> > + return status;
> >
> > + status = gpio_direction_output(spi->cs_gpio,
> > + !(spi->mode & SPI_CS_HIGH));
> > + if (status) {
> > + gpio_free(spi->cs_gpio);
> > + return status;
> > + }
>
> ... or even better, devm_gpio_request_one(), as it allows configuring direction
> and initial level in one go.
>
> > +
> > + spi_set_ctldata(spi, (void *)spi->cs_gpio);
> > + }
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: sh-msiof: request and set cs-gpio direction to output
@ 2016-09-01 10:08 ` Wolfram Sang
0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2016-09-01 10:08 UTC (permalink / raw)
To: Geert Uytterhoeven, Ulrich Hecht
Cc: Mark Brown, linux-spi, Linux-Renesas, Magnus Damm
[-- Attachment #1: Type: text/plain, Size: 2554 bytes --]
On Mon, Jul 18, 2016 at 02:09:03PM +0200, Geert Uytterhoeven wrote:
> Hi Ulrich,
>
> On Mon, Jul 18, 2016 at 10:57 AM, Ulrich Hecht
> <ulrich.hecht+renesas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > Required for the CS signal to actually be visible to the device.
> >
> > Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Thanks, I can confirm this indeed makes cs-gpios work with MSIOF on
> Koelsch, hence
> Tested-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
This one doesn't show up in renesas-drivers. What about V2?
Thanks!
>
> > ---
> > drivers/spi/spi-sh-msiof.c | 25 +++++++++++++++++++++++--
> > 1 file changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> > index a7934ab..d4b5772 100644
> > --- a/drivers/spi/spi-sh-msiof.c
> > +++ b/drivers/spi/spi-sh-msiof.c
> > @@ -536,15 +536,35 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
>
> Is there any specific reason you don't do this in .probe(), like spi-efm32
> does?
>
> > !!(spi->mode & SPI_LSB_FIRST),
> > !!(spi->mode & SPI_CS_HIGH));
> >
> > - if (spi->cs_gpio >= 0)
> > - gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
> > + if (spi->cs_gpio >= 0 && !spi_get_ctldata(spi)) {
> > + int status = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
>
> devm_gpio_request()...
>
> > +
> > + if (status)
> > + return status;
> >
> > + status = gpio_direction_output(spi->cs_gpio,
> > + !(spi->mode & SPI_CS_HIGH));
> > + if (status) {
> > + gpio_free(spi->cs_gpio);
> > + return status;
> > + }
>
> ... or even better, devm_gpio_request_one(), as it allows configuring direction
> and initial level in one go.
>
> > +
> > + spi_set_ctldata(spi, (void *)spi->cs_gpio);
> > + }
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-01 10:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 8:57 [PATCH] spi: sh-msiof: request and set cs-gpio direction to output Ulrich Hecht
2016-07-18 8:57 ` Ulrich Hecht
2016-07-18 12:09 ` Geert Uytterhoeven
2016-09-01 10:08 ` Wolfram Sang
2016-09-01 10:08 ` Wolfram Sang
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.