All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin Hundebøll" <mnhu-rjjw5hvvQKZaa/9Udqfwiw@public.gmane.org>
To: <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "Martin Hundebøll" <mnhu-rjjw5hvvQKZaa/9Udqfwiw@public.gmane.org>,
	"Mark Brown" <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: [PATCH] spi: core: use gpio_request_one for configured gpio cs
Date: Mon, 24 Jul 2017 11:53:27 +0200	[thread overview]
Message-ID: <20170724095327.18602-1-mnhu@prevas.dk> (raw)

Some gpio controllers requires lines to be configured as outputs to make
subsequent calls to `gpio_set_value()` have any effect.

Add a call to `gpio_request_one()` for configured gpio chip-selects to
make it work on (at least) mvebu gpio controllers.

Signed-off-by: Martin Hundebøll <mnhu-rjjw5hvvQKZaa/9Udqfwiw@public.gmane.org>
---
 drivers/spi/spi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0725c78b0de6..b7bfc52525aa 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2010,8 +2010,13 @@ static int of_spi_register_master(struct spi_controller *ctlr)
 	for (i = 0; i < ctlr->num_chipselect; i++)
 		cs[i] = -ENOENT;
 
-	for (i = 0; i < nb; i++)
+	for (i = 0; i < nb; i++) {
 		cs[i] = of_get_named_gpio(np, "cs-gpios", i);
+		if (gpio_is_valid(cs[i]) &&
+		    gpio_request_one(cs[i], 0, "spi-cs") < 0)
+			dev_warn(&master->dev,
+				 "gpio_request_one failed for chipselect %i\n", i);
+	}
 
 	return 0;
 }
-- 
2.13.3

--
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

             reply	other threads:[~2017-07-24  9:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24  9:53 Martin Hundebøll [this message]
     [not found] ` <20170724095327.18602-1-mnhu-rjjw5hvvQKZaa/9Udqfwiw@public.gmane.org>
2017-07-24 10:49   ` [PATCH] spi: core: use gpio_request_one for configured gpio cs Andy Shevchenko
     [not found]     ` <CAHp75VdQbw9rkxq0tvYquacYViZqWKAqOTKHjLPtP=uZi8zzsg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-24 12:01       ` Mark Brown
2017-07-24 21:16         ` Chris Packham
     [not found]           ` <e668b7529837444085b9df3a563c3fe3-5g7mGxlPNYb6GjIOKuZY+ItlCAj8ZROq@public.gmane.org>
2017-07-24 21:26             ` Martin Hundebøll
2017-07-24 21:44               ` Chris Packham
     [not found]                 ` <3027e39333a24fa7a4ce540d96b0e6f3-5g7mGxlPNYb6GjIOKuZY+ItlCAj8ZROq@public.gmane.org>
2017-07-27  9:47                   ` Andy Shevchenko
2017-07-27 21:01                     ` Chris Packham
2017-07-24 21:28             ` Mark Brown
2017-07-24 12:02       ` Mark Brown
     [not found]         ` <20170724120249.mpyv7f3t4q3eihrg-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2017-07-24 12:26           ` Andy Shevchenko

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=20170724095327.18602-1-mnhu@prevas.dk \
    --to=mnhu-rjjw5hvvqkzaa/9udqfwiw@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-spi-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 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.