svn commit: r239626 - in head/sys: arm/at91 dev/spibus
Warner Losh
imp at FreeBSD.org
Thu Aug 23 22:38:39 UTC 2012
Author: imp
Date: Thu Aug 23 22:38:37 2012
New Revision: 239626
URL: http://svn.freebsd.org/changeset/base/239626
Log:
Fetch the chip select in the bridge driver, like all the other spi
bridges do.
Modified:
head/sys/arm/at91/at91_spi.c
head/sys/dev/spibus/spi.h
head/sys/dev/spibus/spibus.c
Modified: head/sys/arm/at91/at91_spi.c
==============================================================================
--- head/sys/arm/at91/at91_spi.c Thu Aug 23 22:23:56 2012 (r239625)
+++ head/sys/arm/at91/at91_spi.c Thu Aug 23 22:38:37 2012 (r239626)
@@ -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
{
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
* 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
* 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
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);
/*
Modified: head/sys/dev/spibus/spi.h
==============================================================================
--- head/sys/dev/spibus/spi.h Thu Aug 23 22:23:56 2012 (r239625)
+++ head/sys/dev/spibus/spi.h Thu Aug 23 22:38:37 2012 (r239626)
@@ -1,7 +1,6 @@
/* $FreeBSD$ */
struct spi_command {
- int cs;
void *tx_cmd;
uint32_t tx_cmd_sz;
void *rx_cmd;
Modified: head/sys/dev/spibus/spibus.c
==============================================================================
--- head/sys/dev/spibus/spibus.c Thu Aug 23 22:23:56 2012 (r239625)
+++ head/sys/dev/spibus/spibus.c Thu Aug 23 22:38:37 2012 (r239626)
@@ -158,9 +158,6 @@ spibus_hinted_child(device_t bus, const
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));
}
More information about the svn-src-head
mailing list