diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-01-11 09:14:13 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-01-11 09:14:13 +0000 |
commit | ad96a5a37b3e11096362a5f807b02e6c47ed7b0e (patch) | |
tree | 6a1c4a0166a292c66d19cd2ba39344008bdebff0 /target | |
parent | 55412d0e9e1d477697fde1f67faf20eb9475af49 (diff) | |
download | master-187ad058-ad96a5a37b3e11096362a5f807b02e6c47ed7b0e.tar.gz master-187ad058-ad96a5a37b3e11096362a5f807b02e6c47ed7b0e.tar.bz2 master-187ad058-ad96a5a37b3e11096362a5f807b02e6c47ed7b0e.zip |
ar71xx: ar71xx_spi: save and restore regs from probe/remove
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29706 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/ar71xx/files/drivers/spi/ar71xx_spi.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/target/linux/ar71xx/files/drivers/spi/ar71xx_spi.c b/target/linux/ar71xx/files/drivers/spi/ar71xx_spi.c index f548cde6d4..be356aafb1 100644 --- a/target/linux/ar71xx/files/drivers/spi/ar71xx_spi.c +++ b/target/linux/ar71xx/files/drivers/spi/ar71xx_spi.c @@ -94,10 +94,8 @@ static void ar71xx_spi_chipselect(struct spi_device *spi, int value) } } -static void ar71xx_spi_setup_regs(struct spi_device *spi) +static void ar71xx_spi_setup_regs(struct ar71xx_spi *sp) { - struct ar71xx_spi *sp = spidev_to_sp(spi); - /* enable GPIO mode */ ar71xx_spi_wr(sp, SPI_REG_FS, SPI_FS_GPIO); @@ -108,10 +106,8 @@ static void ar71xx_spi_setup_regs(struct spi_device *spi) ar71xx_spi_wr(sp, SPI_REG_CTRL, 0x43); } -static void ar71xx_spi_restore_regs(struct spi_device *spi) +static void ar71xx_spi_restore_regs(struct ar71xx_spi *sp) { - struct ar71xx_spi *sp = spidev_to_sp(spi); - /* restore CTRL register */ ar71xx_spi_wr(sp, SPI_REG_CTRL, sp->reg_ctrl); /* disable GPIO mode */ @@ -120,24 +116,14 @@ static void ar71xx_spi_restore_regs(struct spi_device *spi) static int ar71xx_spi_setup(struct spi_device *spi) { - int status; - if (spi->bits_per_word > 32) return -EINVAL; - if (!spi->controller_state) - ar71xx_spi_setup_regs(spi); - - status = spi_bitbang_setup(spi); - if (status && !spi->controller_state) - ar71xx_spi_restore_regs(spi); - - return status; + return spi_bitbang_setup(spi); } static void ar71xx_spi_cleanup(struct spi_device *spi) { - ar71xx_spi_restore_regs(spi); spi_bitbang_cleanup(spi); } @@ -229,10 +215,13 @@ static int ar71xx_spi_probe(struct platform_device *pdev) goto err1; } + ar71xx_spi_setup_regs(sp); + ret = spi_bitbang_start(&sp->bitbang); if (!ret) return 0; + ar71xx_spi_restore_regs(sp); iounmap(sp->base); err1: platform_set_drvdata(pdev, NULL); @@ -246,6 +235,7 @@ static int ar71xx_spi_remove(struct platform_device *pdev) struct ar71xx_spi *sp = platform_get_drvdata(pdev); spi_bitbang_stop(&sp->bitbang); + ar71xx_spi_restore_regs(sp); iounmap(sp->base); platform_set_drvdata(pdev, NULL); spi_master_put(sp->bitbang.master); |