summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-01-11 09:14:15 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-01-11 09:14:15 +0000
commitddfc10f66842ecbc1f4b04b2828f273f4f0b7509 (patch)
treef1f76dfa145aa78f30d2d4de8e03025a8d64620e /target
parent3e74da52450a49b41e3c56b9d7936cdfd20258ef (diff)
ar71xx: pb44_spi: introduce pb44_spi_{en,dis}able helpers
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29708 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r--target/linux/ar71xx/files/drivers/spi/pb44_spi.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/target/linux/ar71xx/files/drivers/spi/pb44_spi.c b/target/linux/ar71xx/files/drivers/spi/pb44_spi.c
index ee5209905..61c22f5b3 100644
--- a/target/linux/ar71xx/files/drivers/spi/pb44_spi.c
+++ b/target/linux/ar71xx/files/drivers/spi/pb44_spi.c
@@ -86,10 +86,8 @@ static void pb44_spi_chipselect(struct spi_device *spi, int is_active)
}
-static int pb44_spi_setup_cs(struct spi_device *spi)
+static void pb44_spi_enable(struct ar71xx_spi *sp)
{
- struct ar71xx_spi *sp = spidev_to_sp(spi);
-
/* enable GPIO mode */
pb44_spi_wr(sp, SPI_REG_FS, SPI_FS_GPIO);
@@ -97,8 +95,22 @@ static int pb44_spi_setup_cs(struct spi_device *spi)
sp->reg_ctrl = pb44_spi_rr(sp, SPI_REG_CTRL);
sp->ioc_base = pb44_spi_rr(sp, SPI_REG_IOC);
- /* TODO: setup speed? */
pb44_spi_wr(sp, SPI_REG_CTRL, 0x43);
+}
+
+static void pb44_spi_disable(struct ar71xx_spi *sp)
+{
+ /* restore CTRL register */
+ pb44_spi_wr(sp, SPI_REG_CTRL, sp->reg_ctrl);
+ /* disable GPIO mode */
+ pb44_spi_wr(sp, SPI_REG_FS, 0);
+}
+
+static int pb44_spi_setup_cs(struct spi_device *spi)
+{
+ struct ar71xx_spi *sp = spidev_to_sp(spi);
+
+ pb44_spi_enable(sp);
if (spi->chip_select) {
unsigned long gpio = (unsigned long) spi->controller_data;
@@ -133,10 +145,7 @@ static void pb44_spi_cleanup_cs(struct spi_device *spi)
gpio_free(gpio);
}
- /* restore CTRL register */
- pb44_spi_wr(sp, SPI_REG_CTRL, sp->reg_ctrl);
- /* disable GPIO mode */
- pb44_spi_wr(sp, SPI_REG_FS, 0);
+ pb44_spi_disable(sp);
}
static int pb44_spi_setup(struct spi_device *spi)