svn commit: r309935 - in head/sys: arm/lpc mips/atheros mips/atheros/ar531x mips/mediatek mips/rt305x
Emmanuel Vadot
manu at FreeBSD.org
Mon Dec 12 20:04:33 UTC 2016
Author: manu
Date: Mon Dec 12 20:04:31 2016
New Revision: 309935
URL: https://svnweb.freebsd.org/changeset/base/309935
Log:
Use the spibus accessor when applicable.
MFC after: 3 days
Modified:
head/sys/arm/lpc/lpc_spi.c
head/sys/mips/atheros/ar531x/ar5315_spi.c
head/sys/mips/atheros/ar71xx_spi.c
head/sys/mips/mediatek/mtk_spi_v1.c
head/sys/mips/mediatek/mtk_spi_v2.c
head/sys/mips/rt305x/rt305x_spi.c
Modified: head/sys/arm/lpc/lpc_spi.c
==============================================================================
--- head/sys/arm/lpc/lpc_spi.c Mon Dec 12 19:46:49 2016 (r309934)
+++ head/sys/arm/lpc/lpc_spi.c Mon Dec 12 20:04:31 2016 (r309935)
@@ -141,12 +141,14 @@ static int
lpc_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
{
struct lpc_spi_softc *sc = device_get_softc(dev);
- struct spibus_ivar *devi = SPIBUS_IVAR(child);
+ uint32_t cs;
uint8_t *in_buf, *out_buf;
int i;
+ spibus_get_cs(child, &cs);
+
/* Set CS active */
- lpc_gpio_set_state(child, devi->cs, 0);
+ lpc_gpio_set_state(child, cs, 0);
/* Wait for FIFO to be ready */
while ((lpc_spi_read_4(sc, LPC_SSP_SR) & LPC_SSP_SR_TNF) == 0);
@@ -168,7 +170,7 @@ lpc_spi_transfer(device_t dev, device_t
}
/* Set CS inactive */
- lpc_gpio_set_state(child, devi->cs, 1);
+ lpc_gpio_set_state(child, cs, 1);
return (0);
}
Modified: head/sys/mips/atheros/ar531x/ar5315_spi.c
==============================================================================
--- head/sys/mips/atheros/ar531x/ar5315_spi.c Mon Dec 12 19:46:49 2016 (r309934)
+++ head/sys/mips/atheros/ar531x/ar5315_spi.c Mon Dec 12 20:04:31 2016 (r309935)
@@ -155,9 +155,8 @@ ar5315_spi_transfer(device_t dev, device
{
struct ar5315_spi_softc *sc;
uint8_t *buf_in, *buf_out;
- struct spibus_ivar *devi = SPIBUS_IVAR(child);
int lin, lout;
- uint32_t ctl, cnt, op, rdat;
+ uint32_t ctl, cnt, op, rdat, cs;
int i, j;
sc = device_get_softc(dev);
@@ -165,8 +164,10 @@ ar5315_spi_transfer(device_t dev, device
if (sc->sc_debug & 0x8000)
printf("ar5315_spi_transfer: CMD ");
+ spibus_get_cs(child, &cs);
+
/* Open SPI controller interface */
- ar5315_spi_chip_activate(sc, devi->cs);
+ ar5315_spi_chip_activate(sc, cs);
do {
ctl = SPI_READ(sc, ARSPI_REG_CTL);
@@ -243,7 +244,7 @@ ar5315_spi_transfer(device_t dev, device
}
}
- ar5315_spi_chip_deactivate(sc, devi->cs);
+ ar5315_spi_chip_deactivate(sc, cs);
/*
* Close SPI controller interface, restore flash memory mapped access.
*/
Modified: head/sys/mips/atheros/ar71xx_spi.c
==============================================================================
--- head/sys/mips/atheros/ar71xx_spi.c Mon Dec 12 19:46:49 2016 (r309934)
+++ head/sys/mips/atheros/ar71xx_spi.c Mon Dec 12 20:04:31 2016 (r309935)
@@ -204,13 +204,15 @@ static int
ar71xx_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
{
struct ar71xx_spi_softc *sc;
+ uint32_t cs;
uint8_t *buf_in, *buf_out;
- struct spibus_ivar *devi = SPIBUS_IVAR(child);
int i;
sc = device_get_softc(dev);
- ar71xx_spi_chip_activate(sc, devi->cs);
+ spibus_get_cs(child, &cs);
+
+ ar71xx_spi_chip_activate(sc, cs);
KASSERT(cmd->tx_cmd_sz == cmd->rx_cmd_sz,
("TX/RX command sizes should be equal"));
@@ -223,7 +225,7 @@ ar71xx_spi_transfer(device_t dev, device
buf_out = (uint8_t *)cmd->tx_cmd;
buf_in = (uint8_t *)cmd->rx_cmd;
for (i = 0; i < cmd->tx_cmd_sz; i++)
- buf_in[i] = ar71xx_spi_txrx(sc, devi->cs, buf_out[i]);
+ buf_in[i] = ar71xx_spi_txrx(sc, cs, buf_out[i]);
/*
* Receive/transmit data (depends on command)
@@ -231,9 +233,9 @@ ar71xx_spi_transfer(device_t dev, device
buf_out = (uint8_t *)cmd->tx_data;
buf_in = (uint8_t *)cmd->rx_data;
for (i = 0; i < cmd->tx_data_sz; i++)
- buf_in[i] = ar71xx_spi_txrx(sc, devi->cs, buf_out[i]);
+ buf_in[i] = ar71xx_spi_txrx(sc, cs, buf_out[i]);
- ar71xx_spi_chip_deactivate(sc, devi->cs);
+ ar71xx_spi_chip_deactivate(sc, cs);
return (0);
}
Modified: head/sys/mips/mediatek/mtk_spi_v1.c
==============================================================================
--- head/sys/mips/mediatek/mtk_spi_v1.c Mon Dec 12 19:46:49 2016 (r309934)
+++ head/sys/mips/mediatek/mtk_spi_v1.c Mon Dec 12 20:04:31 2016 (r309935)
@@ -224,12 +224,14 @@ mtk_spi_transfer(device_t dev, device_t
{
struct mtk_spi_softc *sc;
uint8_t *buf, byte, *tx_buf;
- struct spibus_ivar *devi = SPIBUS_IVAR(child);
+ uint32_t cs;
int i, sz, error = 0, write = 0;
sc = device_get_softc(dev);
- if (devi->cs != 0)
+ spibus_get_cs(child, &cs);
+
+ if (cs != 0)
/* Only 1 CS */
return (ENXIO);
Modified: head/sys/mips/mediatek/mtk_spi_v2.c
==============================================================================
--- head/sys/mips/mediatek/mtk_spi_v2.c Mon Dec 12 19:46:49 2016 (r309934)
+++ head/sys/mips/mediatek/mtk_spi_v2.c Mon Dec 12 20:04:31 2016 (r309935)
@@ -229,12 +229,14 @@ mtk_spi_transfer(device_t dev, device_t
{
struct mtk_spi_softc *sc;
uint8_t *buf, byte, *tx_buf;
- struct spibus_ivar *devi = SPIBUS_IVAR(child);
+ uint32_t cs;
int i, sz, error, write = 0;
sc = device_get_softc(dev);
- if (devi->cs != 0)
+ spibus_get_cs(child, &cs);
+
+ if (cs != 0)
/* Only 1 CS */
return (ENXIO);
Modified: head/sys/mips/rt305x/rt305x_spi.c
==============================================================================
--- head/sys/mips/rt305x/rt305x_spi.c Mon Dec 12 19:46:49 2016 (r309934)
+++ head/sys/mips/rt305x/rt305x_spi.c Mon Dec 12 20:04:31 2016 (r309935)
@@ -218,13 +218,15 @@ static int
rt305x_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
{
struct rt305x_spi_softc *sc;
+ uint32_t cs;
uint8_t *buf, byte, *tx_buf;
- struct spibus_ivar *devi = SPIBUS_IVAR(child);
int i, sz, error = 0, write = 0;
sc = device_get_softc(dev);
- if (devi->cs != 0)
+ spibus_get_cs(child, &cs);
+
+ if (cs != 0)
/* Only 1 CS */
return (ENXIO);
More information about the svn-src-head
mailing list