From owner-svn-src-all@FreeBSD.ORG Thu Aug 23 22:38:38 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9788106583A; Thu, 23 Aug 2012 22:38:38 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6A1F58FC0A; Thu, 23 Aug 2012 22:38:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7NMcc42007211; Thu, 23 Aug 2012 22:38:38 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7NMccwx007206; Thu, 23 Aug 2012 22:38:38 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201208232238.q7NMccwx007206@svn.freebsd.org> From: Warner Losh Date: Thu, 23 Aug 2012 22:38:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239626 - in head/sys: arm/at91 dev/spibus X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Aug 2012 22:38:39 -0000 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 #include +#include #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)); }