diff options
author | Ben Dooks <ben-linux@fluff.org> | 2007-11-28 19:21:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-29 12:24:52 -0500 |
commit | 438ae1ae7bef17026127b66b1ee16efde93bbcb0 (patch) | |
tree | dd310b28edb8715473a3086c642f674e39f2a2b6 /drivers/spi/spi_s3c24xx_gpio.c | |
parent | 3ac40b9b5e62528d407e0e780b65c21c0247bc7c (diff) |
S3C24XX: ensure we only configure valid GPIOs
If we specify an GPIO which cannot be used for the purpose, then assume
that the GPIO is not to be used and do not try and configure it. This can
be the case where the SPI bus is TX only.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/spi_s3c24xx_gpio.c')
-rw-r--r-- | drivers/spi/spi_s3c24xx_gpio.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/spi/spi_s3c24xx_gpio.c b/drivers/spi/spi_s3c24xx_gpio.c index 0fa25e2e80fe..d59105dc308b 100644 --- a/drivers/spi/spi_s3c24xx_gpio.c +++ b/drivers/spi/spi_s3c24xx_gpio.c | |||
@@ -96,6 +96,7 @@ static void s3c2410_spigpio_chipselect(struct spi_device *dev, int value) | |||
96 | 96 | ||
97 | static int s3c2410_spigpio_probe(struct platform_device *dev) | 97 | static int s3c2410_spigpio_probe(struct platform_device *dev) |
98 | { | 98 | { |
99 | struct s3c2410_spigpio_info *info; | ||
99 | struct spi_master *master; | 100 | struct spi_master *master; |
100 | struct s3c2410_spigpio *sp; | 101 | struct s3c2410_spigpio *sp; |
101 | int ret; | 102 | int ret; |
@@ -113,7 +114,7 @@ static int s3c2410_spigpio_probe(struct platform_device *dev) | |||
113 | platform_set_drvdata(dev, sp); | 114 | platform_set_drvdata(dev, sp); |
114 | 115 | ||
115 | /* copy in the plkatform data */ | 116 | /* copy in the plkatform data */ |
116 | sp->info = dev->dev.platform_data; | 117 | info = sp->info = dev->dev.platform_data; |
117 | 118 | ||
118 | /* setup spi bitbang adaptor */ | 119 | /* setup spi bitbang adaptor */ |
119 | sp->bitbang.master = spi_master_get(master); | 120 | sp->bitbang.master = spi_master_get(master); |
@@ -124,13 +125,18 @@ static int s3c2410_spigpio_probe(struct platform_device *dev) | |||
124 | sp->bitbang.txrx_word[SPI_MODE_2] = s3c2410_spigpio_txrx_mode2; | 125 | sp->bitbang.txrx_word[SPI_MODE_2] = s3c2410_spigpio_txrx_mode2; |
125 | sp->bitbang.txrx_word[SPI_MODE_3] = s3c2410_spigpio_txrx_mode3; | 126 | sp->bitbang.txrx_word[SPI_MODE_3] = s3c2410_spigpio_txrx_mode3; |
126 | 127 | ||
127 | /* set state of spi pins */ | 128 | /* set state of spi pins, always assume that the clock is |
128 | s3c2410_gpio_setpin(sp->info->pin_clk, 0); | 129 | * available, but do check the MOSI and MISO. */ |
129 | s3c2410_gpio_setpin(sp->info->pin_mosi, 0); | 130 | s3c2410_gpio_setpin(info->pin_clk, 0); |
131 | s3c2410_gpio_cfgpin(info->pin_clk, S3C2410_GPIO_OUTPUT); | ||
130 | 132 | ||
131 | s3c2410_gpio_cfgpin(sp->info->pin_clk, S3C2410_GPIO_OUTPUT); | 133 | if (info->pin_mosi < S3C2410_GPH10) { |
132 | s3c2410_gpio_cfgpin(sp->info->pin_mosi, S3C2410_GPIO_OUTPUT); | 134 | s3c2410_gpio_setpin(info->pin_mosi, 0); |
133 | s3c2410_gpio_cfgpin(sp->info->pin_miso, S3C2410_GPIO_INPUT); | 135 | s3c2410_gpio_cfgpin(info->pin_mosi, S3C2410_GPIO_OUTPUT); |
136 | } | ||
137 | |||
138 | if (info->pin_miso != S3C2410_GPA0 && info->pin_miso < S3C2410_GPH10) | ||
139 | s3c2410_gpio_cfgpin(info->pin_miso, S3C2410_GPIO_INPUT); | ||
134 | 140 | ||
135 | ret = spi_bitbang_start(&sp->bitbang); | 141 | ret = spi_bitbang_start(&sp->bitbang); |
136 | if (ret) | 142 | if (ret) |