aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2009-01-06 17:41:44 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:19 -0500
commitee9c1fbfe130a20e0f23d1693d6427dac97239bc (patch)
tree83cb9804fb49a71d609b846feaea10974e3d704b /drivers
parent5ee36c989831ab720eee282521462cce0a3c4900 (diff)
spi: use generic gpio calls in spi_s3c24xx_gpio
Change the spi_s3c2410 driver to use the generic gpio calls that are now available. 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')
-rw-r--r--drivers/spi/spi_s3c24xx.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 256d18395a23..b3ebc1d0f85f 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -19,6 +19,7 @@
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/gpio.h>
22 23
23#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
24#include <linux/spi/spi_bitbang.h> 25#include <linux/spi/spi_bitbang.h>
@@ -27,7 +28,6 @@
27#include <asm/dma.h> 28#include <asm/dma.h>
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29 30
30#include <mach/regs-gpio.h>
31#include <plat/regs-spi.h> 31#include <plat/regs-spi.h>
32#include <mach/spi.h> 32#include <mach/spi.h>
33 33
@@ -66,7 +66,7 @@ static inline struct s3c24xx_spi *to_hw(struct spi_device *sdev)
66 66
67static void s3c24xx_spi_gpiocs(struct s3c2410_spi_info *spi, int cs, int pol) 67static void s3c24xx_spi_gpiocs(struct s3c2410_spi_info *spi, int cs, int pol)
68{ 68{
69 s3c2410_gpio_setpin(spi->pin_cs, pol); 69 gpio_set_value(spi->pin_cs, pol);
70} 70}
71 71
72static void s3c24xx_spi_chipsel(struct spi_device *spi, int value) 72static void s3c24xx_spi_chipsel(struct spi_device *spi, int value)
@@ -248,8 +248,13 @@ static void s3c24xx_spi_initialsetup(struct s3c24xx_spi *hw)
248 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN); 248 writeb(SPPIN_DEFAULT, hw->regs + S3C2410_SPPIN);
249 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON); 249 writeb(SPCON_DEFAULT, hw->regs + S3C2410_SPCON);
250 250
251 if (hw->pdata && hw->pdata->gpio_setup) 251 if (hw->pdata) {
252 hw->pdata->gpio_setup(hw->pdata, 1); 252 if (hw->set_cs == s3c24xx_spi_gpiocs)
253 gpio_direction_output(hw->pdata->pin_cs, 1);
254
255 if (hw->pdata->gpio_setup)
256 hw->pdata->gpio_setup(hw->pdata, 1);
257 }
253} 258}
254 259
255static int __init s3c24xx_spi_probe(struct platform_device *pdev) 260static int __init s3c24xx_spi_probe(struct platform_device *pdev)
@@ -343,18 +348,27 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
343 goto err_no_clk; 348 goto err_no_clk;
344 } 349 }
345 350
346 s3c24xx_spi_initialsetup(hw);
347
348 /* setup any gpio we can */ 351 /* setup any gpio we can */
349 352
350 if (!pdata->set_cs) { 353 if (!pdata->set_cs) {
351 hw->set_cs = s3c24xx_spi_gpiocs; 354 if (pdata->pin_cs < 0) {
355 dev_err(&pdev->dev, "No chipselect pin\n");
356 goto err_register;
357 }
352 358
353 s3c2410_gpio_setpin(pdata->pin_cs, 1); 359 err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev));
354 s3c2410_gpio_cfgpin(pdata->pin_cs, S3C2410_GPIO_OUTPUT); 360 if (err) {
361 dev_err(&pdev->dev, "Failed to get gpio for cs\n");
362 goto err_register;
363 }
364
365 hw->set_cs = s3c24xx_spi_gpiocs;
366 gpio_direction_output(pdata->pin_cs, 1);
355 } else 367 } else
356 hw->set_cs = pdata->set_cs; 368 hw->set_cs = pdata->set_cs;
357 369
370 s3c24xx_spi_initialsetup(hw);
371
358 /* register our spi controller */ 372 /* register our spi controller */
359 373
360 err = spi_bitbang_start(&hw->bitbang); 374 err = spi_bitbang_start(&hw->bitbang);
@@ -366,6 +380,9 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
366 return 0; 380 return 0;
367 381
368 err_register: 382 err_register:
383 if (hw->set_cs == s3c24xx_spi_gpiocs)
384 gpio_free(pdata->pin_cs);
385
369 clk_disable(hw->clk); 386 clk_disable(hw->clk);
370 clk_put(hw->clk); 387 clk_put(hw->clk);
371 388
@@ -401,6 +418,9 @@ static int __exit s3c24xx_spi_remove(struct platform_device *dev)
401 free_irq(hw->irq, hw); 418 free_irq(hw->irq, hw);
402 iounmap(hw->regs); 419 iounmap(hw->regs);
403 420
421 if (hw->set_cs == s3c24xx_spi_gpiocs)
422 gpio_free(hw->pdata->pin_cs);
423
404 release_resource(hw->ioarea); 424 release_resource(hw->ioarea);
405 kfree(hw->ioarea); 425 kfree(hw->ioarea);
406 426