* [PATCH][POWERPC] mpc83xx : allow SPI without cs.
@ 2009-05-13 7:50 Rini van Zetten
0 siblings, 0 replies; 4+ messages in thread
From: Rini van Zetten @ 2009-05-13 7:50 UTC (permalink / raw)
To: galak, spi-devel-general, Linuxppc-dev
This patch adds the possibility to have a spi device without a cs.
For example, the dts file should look something like this:
spi-controller {
gpios = <&pio1 1 0 /* cs0 */
0 /* cs1, no GPIO */
&pio2 2 0>; /* cs2 */
Signed-off-by: Rini van Zetten <rini@arvoo.nl>
---
drivers/spi/spi_mpc83xx.c | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index f4573a9..d06027e 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -687,9 +687,10 @@ static void mpc83xx_spi_cs_control(struct spi_device *spi, bool on)
struct mpc83xx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
u16 cs = spi->chip_select;
int gpio = pinfo->gpios[cs];
- bool alow = pinfo->alow_flags[cs];
-
- gpio_set_value(gpio, on ^ alow);
+ if ( gpio != -EEXIST ) {
+ bool alow = pinfo->alow_flags[cs];
+ gpio_set_value(gpio, on ^ alow);
+ }
}
static int of_mpc83xx_spi_get_chipselects(struct device *dev)
@@ -728,27 +729,28 @@ static int of_mpc83xx_spi_get_chipselects(struct device *dev)
enum of_gpio_flags flags;
gpio = of_get_gpio_flags(np, i, &flags);
- if (!gpio_is_valid(gpio)) {
+ if (gpio_is_valid(gpio)) {
+ ret = gpio_request(gpio, dev_name(dev));
+ if (ret) {
+ dev_err(dev, "can't request gpio #%d: %d\n", i, ret);
+ goto err_loop;
+ }
+ pinfo->gpios[i] = gpio;
+ pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW;
+
+ ret = gpio_direction_output(pinfo->gpios[i],
+ pinfo->alow_flags[i]);
+ if (ret) {
+ dev_err(dev, "can't set output direction for gpio "
+ "#%d: %d\n", i, ret);
+ goto err_loop;
+ }
+ } else if (gpio == -EEXIST) {
+ pinfo->gpios[i] = -EEXIST;
+ } else {
dev_err(dev, "invalid gpio #%d: %d\n", i, gpio);
goto err_loop;
}
-
- ret = gpio_request(gpio, dev_name(dev));
- if (ret) {
- dev_err(dev, "can't request gpio #%d: %d\n", i, ret);
- goto err_loop;
- }
-
- pinfo->gpios[i] = gpio;
- pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW;
-
- ret = gpio_direction_output(pinfo->gpios[i],
- pinfo->alow_flags[i]);
- if (ret) {
- dev_err(dev, "can't set output direction for gpio "
- "#%d: %d\n", i, ret);
- goto err_loop;
- }
}
pdata->max_chipselect = ngpios;
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][POWERPC] mpc83xx : allow SPI without cs.
2009-06-11 13:29 ` Kumar Gala
@ 2009-06-11 15:11 ` Rini van Zetten
0 siblings, 0 replies; 4+ messages in thread
From: Rini van Zetten @ 2009-06-11 15:11 UTC (permalink / raw)
To: Kumar Gala; +Cc: spi-devel-general, Andrew Morton, linuxppc-dev list
excuse me for my ignorance, but which -mm tree do you mean and where can I find it.
Regards,
Rini
Kumar Gala schreef:
>
> On Jun 11, 2009, at 4:10 AM, Rini van Zetten wrote:
>
>> This patch adds the possibility to have a spi device without a cs.
>>
>> For example, the dts file should look something like this:
>>
>> spi-controller {
>> gpios = <&pio1 1 0 /* cs0 */
>> 0 /* cs1, no GPIO */
>> &pio2 2 0>; /* cs2 */
>>
>>
>>
>> Signed-off-by: Rini van Zetten <rini@arvoo.nl>
>> ---
>> drivers/spi/spi_mpc83xx.c | 44
>> +++++++++++++++++++++++---------------------
>> 1 files changed, 23 insertions(+), 21 deletions(-)
>
> This patch needs to be respun against the -mm tree as a lot of other spi
> patches are queued up there that will cause this patch to not merge
> correctly.
>
> - k
--
Rini van Zetten
Senior Software Engineer
-------------------------
ARVOO Engineering B.V.
Tasveld 13
3417 XS Montfoort
The Netherlands
E-mail : <mailto:rini@arvoo.com> Rini van Zetten
Web : www.arvoo.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][POWERPC] mpc83xx : allow SPI without cs.
2009-06-11 9:10 Rini van Zetten
@ 2009-06-11 13:29 ` Kumar Gala
2009-06-11 15:11 ` Rini van Zetten
0 siblings, 1 reply; 4+ messages in thread
From: Kumar Gala @ 2009-06-11 13:29 UTC (permalink / raw)
To: Rini van Zetten; +Cc: spi-devel-general, Andrew Morton, linuxppc-dev list
On Jun 11, 2009, at 4:10 AM, Rini van Zetten wrote:
> This patch adds the possibility to have a spi device without a cs.
>
> For example, the dts file should look something like this:
>
> spi-controller {
> gpios = <&pio1 1 0 /* cs0 */
> 0 /* cs1, no GPIO */
> &pio2 2 0>; /* cs2 */
>
>
>
> Signed-off-by: Rini van Zetten <rini@arvoo.nl>
> ---
> drivers/spi/spi_mpc83xx.c | 44 ++++++++++++++++++++++
> +---------------------
> 1 files changed, 23 insertions(+), 21 deletions(-)
This patch needs to be respun against the -mm tree as a lot of other
spi patches are queued up there that will cause this patch to not
merge correctly.
- k
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH][POWERPC] mpc83xx : allow SPI without cs.
@ 2009-06-11 9:10 Rini van Zetten
2009-06-11 13:29 ` Kumar Gala
0 siblings, 1 reply; 4+ messages in thread
From: Rini van Zetten @ 2009-06-11 9:10 UTC (permalink / raw)
To: galak, spi-devel-general, Linuxppc-dev
This patch adds the possibility to have a spi device without a cs.
For example, the dts file should look something like this:
spi-controller {
gpios = <&pio1 1 0 /* cs0 */
0 /* cs1, no GPIO */
&pio2 2 0>; /* cs2 */
Signed-off-by: Rini van Zetten <rini@arvoo.nl>
---
drivers/spi/spi_mpc83xx.c | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index f4573a9..d06027e 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -687,9 +687,10 @@ static void mpc83xx_spi_cs_control(struct spi_device *spi, bool on)
struct mpc83xx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
u16 cs = spi->chip_select;
int gpio = pinfo->gpios[cs];
- bool alow = pinfo->alow_flags[cs];
-
- gpio_set_value(gpio, on ^ alow);
+ if ( gpio != -EEXIST ) {
+ bool alow = pinfo->alow_flags[cs];
+ gpio_set_value(gpio, on ^ alow);
+ }
}
static int of_mpc83xx_spi_get_chipselects(struct device *dev)
@@ -728,27 +729,28 @@ static int of_mpc83xx_spi_get_chipselects(struct device *dev)
enum of_gpio_flags flags;
gpio = of_get_gpio_flags(np, i, &flags);
- if (!gpio_is_valid(gpio)) {
+ if (gpio_is_valid(gpio)) {
+ ret = gpio_request(gpio, dev_name(dev));
+ if (ret) {
+ dev_err(dev, "can't request gpio #%d: %d\n", i, ret);
+ goto err_loop;
+ }
+ pinfo->gpios[i] = gpio;
+ pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW;
+
+ ret = gpio_direction_output(pinfo->gpios[i],
+ pinfo->alow_flags[i]);
+ if (ret) {
+ dev_err(dev, "can't set output direction for gpio "
+ "#%d: %d\n", i, ret);
+ goto err_loop;
+ }
+ } else if (gpio == -EEXIST) {
+ pinfo->gpios[i] = -EEXIST;
+ } else {
dev_err(dev, "invalid gpio #%d: %d\n", i, gpio);
goto err_loop;
}
-
- ret = gpio_request(gpio, dev_name(dev));
- if (ret) {
- dev_err(dev, "can't request gpio #%d: %d\n", i, ret);
- goto err_loop;
- }
-
- pinfo->gpios[i] = gpio;
- pinfo->alow_flags[i] = flags & OF_GPIO_ACTIVE_LOW;
-
- ret = gpio_direction_output(pinfo->gpios[i],
- pinfo->alow_flags[i]);
- if (ret) {
- dev_err(dev, "can't set output direction for gpio "
- "#%d: %d\n", i, ret);
- goto err_loop;
- }
}
pdata->max_chipselect = ngpios;
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-11 15:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-13 7:50 [PATCH][POWERPC] mpc83xx : allow SPI without cs Rini van Zetten
2009-06-11 9:10 Rini van Zetten
2009-06-11 13:29 ` Kumar Gala
2009-06-11 15:11 ` Rini van Zetten
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).