diff options
author | imp <imp@FreeBSD.org> | 2012-08-23 22:38:37 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2012-08-23 22:38:37 +0000 |
commit | c0d788882dc33b1a15e9927136adb29244527f31 (patch) | |
tree | ced20edb8855369eea5fcba126aa3a0625a70fce | |
parent | a159b060cc864692416bde7c21b051d073424e1c (diff) | |
download | FreeBSD-src-c0d788882dc33b1a15e9927136adb29244527f31.zip FreeBSD-src-c0d788882dc33b1a15e9927136adb29244527f31.tar.gz |
Fetch the chip select in the bridge driver, like all the other spi
bridges do.
-rw-r--r-- | sys/arm/at91/at91_spi.c | 14 | ||||
-rw-r--r-- | sys/dev/spibus/spi.h | 1 | ||||
-rw-r--r-- | sys/dev/spibus/spibus.c | 3 |
3 files changed, 9 insertions, 9 deletions
diff --git a/sys/arm/at91/at91_spi.c b/sys/arm/at91/at91_spi.c index f01e984..b0cde4a 100644 --- a/sys/arm/at91/at91_spi.c +++ b/sys/arm/at91/at91_spi.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91_pdcreg.h> #include <dev/spibus/spi.h> +#include <dev/spibus/spibusvar.h> #include "spibus_if.h" @@ -270,13 +271,16 @@ at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) { struct at91_spi_softc *sc; bus_addr_t addr; - int err, i, j, mode[4]; + int err, i, j, mode[4], cs; KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz, ("%s: TX/RX command sizes should be equal", __func__)); KASSERT(cmd->tx_data_sz == cmd->rx_data_sz, ("%s: TX/RX data sizes should be equal", __func__)); + /* get the proper chip select */ + spibus_get_cs(child, &cs); + sc = device_get_softc(dev); i = 0; @@ -291,9 +295,9 @@ at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) * PSCDEC = 0 has a range of 0..3 for chip select. We * don't support PSCDEC = 1 which has a range of 0..15. */ - if (cmd->cs < 0 || cmd->cs > 3) { + if (cs < 0 || cs > 3) { device_printf(dev, - "Invalid chip select %d requested by %s\n", cmd->cs, + "Invalid chip select %d requested by %s\n", cs, device_get_nameunit(child)); err = EINVAL; goto out; @@ -304,7 +308,7 @@ at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) * The AT91RM9200 couldn't do CS high for CS 0. Other chips can, but we * don't support that yet, or other spi modes. */ - if (at91_is_rm92() && cmd->cs == 0 && + if (at91_is_rm92() && cs == 0 && (cmd->flags & SPI_CHIP_SELECT_HIGH) != 0) { device_printf(dev, "Invalid chip select high requested by %s for cs 0.\n", @@ -313,7 +317,7 @@ at91_spi_transfer(device_t dev, device_t child, struct spi_command *cmd) goto out; } #endif - err = (RD4(sc, SPI_MR) & ~0x000f0000) | CS_TO_MR(cmd->cs); + err = (RD4(sc, SPI_MR) & ~0x000f0000) | CS_TO_MR(cs); WR4(sc, SPI_MR, err); /* diff --git a/sys/dev/spibus/spi.h b/sys/dev/spibus/spi.h index 4f89e94..170c906 100644 --- a/sys/dev/spibus/spi.h +++ b/sys/dev/spibus/spi.h @@ -1,7 +1,6 @@ /* $FreeBSD$ */ struct spi_command { - int cs; void *tx_cmd; uint32_t tx_cmd_sz; void *rx_cmd; diff --git a/sys/dev/spibus/spibus.c b/sys/dev/spibus/spibus.c index 0f8e359..43b4e7e 100644 --- a/sys/dev/spibus/spibus.c +++ b/sys/dev/spibus/spibus.c @@ -158,9 +158,6 @@ spibus_hinted_child(device_t bus, const char *dname, int dunit) static int spibus_transfer_impl(device_t dev, device_t child, struct spi_command *cmd) { - /* Maybe set flags too? spi mode? */ - spibus_get_cs(dev, &cmd->cs); - return (SPIBUS_TRANSFER(device_get_parent(dev), child, cmd)); } |