diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-09 08:32:21 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-09 08:32:21 +0100 |
commit | 4680b375b9dd32e6558ae2ee8a15b27819c70e73 (patch) | |
tree | 945cd90ff3557de600e6e208596c7ef846fb603e /drivers | |
parent | 5544581e98d09c7c9008f9cac8cd25dbb6a14d6e (diff) | |
parent | 0e06a77f5b93d4479ff1b88bc32003ceaa37d152 (diff) | |
download | barebox-4680b375b9dd32e6558ae2ee8a15b27819c70e73.tar.gz barebox-4680b375b9dd32e6558ae2ee8a15b27819c70e73.tar.xz |
Merge branch 'for-next/streaming-dma'
Conflicts:
drivers/mci/dw_mmc.c
Diffstat (limited to 'drivers')
35 files changed, 264 insertions, 171 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 346ab98134..4e42180d9e 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -21,6 +21,7 @@ */ #include <common.h> +#include <dma.h> #include <init.h> #include <errno.h> #include <io.h> @@ -30,7 +31,6 @@ #include <linux/ctype.h> #include <linux/err.h> #include <disks.h> -#include <asm/mmu.h> #include <ata_drive.h> #include <linux/sizes.h> #include <clock.h> @@ -169,7 +169,11 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf return -EIO; if (wbuf) - dma_flush_range((unsigned long)wbuf, (unsigned long)wbuf + buf_len); + dma_sync_single_for_device((unsigned long)wbuf, buf_len, + DMA_TO_DEVICE); + if (rbuf) + dma_sync_single_for_device((unsigned long)rbuf, buf_len, + DMA_FROM_DEVICE); memcpy((unsigned char *)ahci_port->cmd_tbl, fis, fis_len); @@ -186,8 +190,12 @@ static int ahci_io(struct ahci_port *ahci_port, u8 *fis, int fis_len, void *rbuf if (ret) return -ETIMEDOUT; + if (wbuf) + dma_sync_single_for_cpu((unsigned long)wbuf, buf_len, + DMA_TO_DEVICE); if (rbuf) - dma_inv_range((unsigned long)rbuf, (unsigned long)rbuf + buf_len); + dma_sync_single_for_cpu((unsigned long)rbuf, buf_len, + DMA_FROM_DEVICE); return 0; } @@ -310,7 +318,8 @@ static int ahci_init_port(struct ahci_port *ahci_port) * First item in chunk of DMA memory: 32-slot command table, * 32 bytes each in size */ - ahci_port->cmd_slot = dma_alloc_coherent(AHCI_CMD_SLOT_SZ * 32); + ahci_port->cmd_slot = dma_alloc_coherent(AHCI_CMD_SLOT_SZ * 32, + DMA_ADDRESS_BROKEN); if (!ahci_port->cmd_slot) { ret = -ENOMEM; goto err_alloc; @@ -321,7 +330,8 @@ static int ahci_init_port(struct ahci_port *ahci_port) /* * Second item: Received-FIS area */ - ahci_port->rx_fis = (unsigned long)dma_alloc_coherent(AHCI_RX_FIS_SZ); + ahci_port->rx_fis = (unsigned long)dma_alloc_coherent(AHCI_RX_FIS_SZ, + DMA_ADDRESS_BROKEN); if (!ahci_port->rx_fis) { ret = -ENOMEM; goto err_alloc1; @@ -331,7 +341,8 @@ static int ahci_init_port(struct ahci_port *ahci_port) * Third item: data area for storing a single command * and its scatter-gather table */ - ahci_port->cmd_tbl = dma_alloc_coherent(AHCI_CMD_TBL_SZ); + ahci_port->cmd_tbl = dma_alloc_coherent(AHCI_CMD_TBL_SZ, + DMA_ADDRESS_BROKEN); if (!ahci_port->cmd_tbl) { ret = -ENOMEM; goto err_alloc2; @@ -429,11 +440,11 @@ static int ahci_init_port(struct ahci_port *ahci_port) ret = -ENODEV; err_init: - dma_free_coherent(ahci_port->cmd_tbl, AHCI_CMD_TBL_SZ); + dma_free_coherent(ahci_port->cmd_tbl, 0, AHCI_CMD_TBL_SZ); err_alloc2: - dma_free_coherent((void *)ahci_port->rx_fis, AHCI_RX_FIS_SZ); + dma_free_coherent((void *)ahci_port->rx_fis, 0, AHCI_RX_FIS_SZ); err_alloc1: - dma_free_coherent(ahci_port->cmd_slot, AHCI_CMD_SLOT_SZ * 32); + dma_free_coherent(ahci_port->cmd_slot, 0, AHCI_CMD_SLOT_SZ * 32); err_alloc: return ret; } diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c index cd218f4582..ebfc64700e 100644 --- a/drivers/dma/apbh_dma.c +++ b/drivers/dma/apbh_dma.c @@ -20,13 +20,13 @@ #include <linux/list.h> #include <linux/err.h> #include <common.h> +#include <dma.h> #include <driver.h> #include <malloc.h> #include <errno.h> #include <init.h> #include <io.h> -#include <asm/mmu.h> #define HW_APBHX_CTRL0 0x000 #define BM_APBH_CTRL0_APB_BURST8_EN (1 << 29) @@ -380,7 +380,8 @@ struct mxs_dma_desc *mxs_dma_desc_alloc(void) { struct mxs_dma_desc *pdesc; - pdesc = dma_alloc_coherent(sizeof(struct mxs_dma_desc)); + pdesc = dma_alloc_coherent(sizeof(struct mxs_dma_desc), + DMA_ADDRESS_BROKEN); if (pdesc == NULL) return NULL; diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig index 17bf0d381c..31f7d2d4ea 100644 --- a/drivers/mci/Kconfig +++ b/drivers/mci/Kconfig @@ -36,7 +36,7 @@ comment "--- MCI host drivers ---" config MCI_DW bool "Synopsys DesignWare Memory Card Interface" - depends on ARM + depends on HAS_DMA help This selects support for the Synopsys DesignWare Mobile Storage IP block, this provides host support for SD and MMC interfaces, in both diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c index 076f99de0e..c4dfbb88f3 100644 --- a/drivers/mci/dw_mmc.c +++ b/drivers/mci/dw_mmc.c @@ -18,6 +18,7 @@ */ #include <common.h> +#include <dma.h> #include <driver.h> #include <malloc.h> #include <clock.h> @@ -28,7 +29,6 @@ #include <linux/clk.h> #include <linux/err.h> #include <asm-generic/errno.h> -#include <asm/mmu.h> #define DWMCI_CTRL 0x000 #define DWMCI_PWREN 0x004 @@ -417,7 +417,6 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) uint64_t start; int ret; unsigned int num_bytes = 0; - const void *writebuf = NULL; start = get_time_ns(); while (1) { @@ -435,12 +434,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) if (data) { num_bytes = data->blocks * data->blocksize; - if (data->flags & MMC_DATA_WRITE) { - dma_flush_range((unsigned long)data->src, - (unsigned long)(data->src + data->blocks * 512)); - - writebuf = data->src; - } + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_device((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_device((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); ret = dwmci_prepare_data(host, data); if (ret) @@ -541,11 +540,12 @@ dwmci_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) ctrl &= ~(DWMCI_DMA_EN); dwmci_writel(host, DWMCI_CTRL, ctrl); - if (data->flags & MMC_DATA_READ) { - dma_inv_range((unsigned long)data->dest, - (unsigned long)(data->dest + - data->blocks * 512)); - } + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_cpu((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_cpu((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); } } @@ -729,7 +729,8 @@ static int dw_mmc_probe(struct device_d *dev) /* divider is 0 based in pdata and 1 based in our private struct */ host->ciu_div++; - host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS); + host->idmac = dma_alloc_coherent(sizeof(*host->idmac) * DW_MMC_NUM_IDMACS, + DMA_ADDRESS_BROKEN); host->mci.send_cmd = dwmci_cmd; host->mci.set_ios = dwmci_set_ios; diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c index 23bdc1fb15..8b45500a09 100644 --- a/drivers/mci/imx-esdhc.c +++ b/drivers/mci/imx-esdhc.c @@ -22,6 +22,7 @@ */ #include <config.h> #include <common.h> +#include <dma.h> #include <driver.h> #include <init.h> #include <of.h> @@ -31,7 +32,6 @@ #include <io.h> #include <linux/clk.h> #include <linux/err.h> -#include <asm/mmu.h> #include <mach/generic.h> #include <mach/esdhc.h> #include <gpio.h> @@ -211,6 +211,7 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) u32 irqstat; struct fsl_esdhc_host *host = to_fsl_esdhc(mci); void __iomem *regs = host->regs; + unsigned int num_bytes = 0; int ret; esdhc_write32(regs + SDHCI_INT_STATUS, -1); @@ -225,12 +226,15 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) err = esdhc_setup_data(mci, data); if(err) return err; - if (data->flags & MMC_DATA_WRITE) { - dma_flush_range((unsigned long)data->src, - (unsigned long)(data->src + data->blocks * 512)); - } else - dma_clean_range((unsigned long)data->src, - (unsigned long)(data->src + data->blocks * 512)); + + num_bytes = data->blocks * data->blocksize; + + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_device((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_device((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); } @@ -313,10 +317,12 @@ esdhc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) } while (!(irqstat & IRQSTAT_TC) && (esdhc_read32(regs + SDHCI_PRESENT_STATE) & PRSSTAT_DLA)); - if (data->flags & MMC_DATA_READ) { - dma_inv_range((unsigned long)data->dest, - (unsigned long)(data->dest + data->blocks * 512)); - } + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_cpu((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_cpu((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); #endif } diff --git a/drivers/mci/tegra-sdmmc.c b/drivers/mci/tegra-sdmmc.c index 0e23d6fef1..670c280cb8 100644 --- a/drivers/mci/tegra-sdmmc.c +++ b/drivers/mci/tegra-sdmmc.c @@ -17,10 +17,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <asm/mmu.h> #include <common.h> #include <clock.h> #include <driver.h> +#include <dma.h> #include <gpio.h> #include <init.h> #include <io.h> @@ -100,6 +100,7 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, struct mci_data *data) { struct tegra_sdmmc_host *host = to_tegra_sdmmc_host(mci); + unsigned int num_bytes = 0; u32 val = 0; int ret; @@ -109,15 +110,15 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, /* Set up for a data transfer if we have one */ if (data) { + num_bytes = data->blocks * data->blocksize; + if (data->flags & MMC_DATA_WRITE) { - dma_flush_range((unsigned long)data->src, - (unsigned long)(data->src + - data->blocks * 512)); + dma_sync_single_for_device((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); writel((u32)data->src, host->regs + SDHCI_DMA_ADDRESS); } else { - dma_clean_range((unsigned long)data->src, - (unsigned long)(data->src + - data->blocks * 512)); + dma_sync_single_for_device((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); writel((u32)data->dest, host->regs + SDHCI_DMA_ADDRESS); } @@ -255,11 +256,12 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, } writel(val, host->regs + SDHCI_INT_STATUS); - if (data->flags & MMC_DATA_READ) { - dma_inv_range((unsigned long)data->dest, - (unsigned long)(data->dest + - data->blocks * 512)); - } + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_cpu((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_cpu((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); } return 0; diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c index 4e38e09186..d5d64f369e 100644 --- a/drivers/mtd/nand/nand_mxs.c +++ b/drivers/mtd/nand/nand_mxs.c @@ -26,6 +26,7 @@ #include <linux/err.h> #include <of_mtd.h> #include <common.h> +#include <dma.h> #include <malloc.h> #include <errno.h> #include <driver.h> @@ -33,7 +34,6 @@ #include <io.h> #include <dma/apbh-dma.h> #include <stmp-device.h> -#include <asm/mmu.h> #include <mach/generic.h> #define MX28_BLOCK_SFTRST (1 << 31) @@ -1141,7 +1141,7 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info) const int size = NAND_MAX_PAGESIZE + NAND_MAX_OOBSIZE; /* DMA buffers */ - buf = dma_alloc_coherent(size); + buf = dma_alloc_coherent(size, DMA_ADDRESS_BROKEN); if (!buf) { printf("MXS NAND: Error allocating DMA buffers\n"); return -ENOMEM; @@ -1153,7 +1153,8 @@ int mxs_nand_alloc_buffers(struct mxs_nand_info *nand_info) nand_info->oob_buf = buf + NAND_MAX_PAGESIZE; /* Command buffers */ - nand_info->cmd_buf = dma_alloc_coherent(MXS_NAND_COMMAND_BUFFER_SIZE); + nand_info->cmd_buf = dma_alloc_coherent(MXS_NAND_COMMAND_BUFFER_SIZE, + DMA_ADDRESS_BROKEN); if (!nand_info->cmd_buf) { free(buf); printf("MXS NAND: Error allocating command buffers\n"); diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index adb7008f99..42ffa650ba 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -167,6 +167,7 @@ config DRIVER_NET_RTL8139 config DRIVER_NET_RTL8169 bool "RealTek RTL-8169 PCI Ethernet driver" depends on PCI + depends on HAS_DMA select PHYLIB help This is a driver for the Fast Ethernet PCI network cards based on diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index ecbb9f8974..385a7150ba 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -21,6 +21,7 @@ */ #include <common.h> +#include <dma.h> #include <net.h> #include <init.h> #include <clock.h> @@ -520,7 +521,7 @@ static int tse_probe(struct device_d *dev) return PTR_ERR(tx_desc); rx_desc = tx_desc + 2; #else - tx_desc = dma_alloc_coherent(sizeof(*tx_desc) * (3 + PKTBUFSRX), (unsigned long *)&dma_handle); + tx_desc = dma_alloc_coherent(sizeof(*tx_desc) * (3 + PKTBUFSRX), (dma_addr_t *)&dma_handle); rx_desc = tx_desc + 2; if (!tx_desc) { diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c index 06c3376975..84e2c75c5e 100644 --- a/drivers/net/arc_emac.c +++ b/drivers/net/arc_emac.c @@ -16,9 +16,9 @@ * GNU General Public License for more details. */ -#include <asm/mmu.h> #include <clock.h> #include <common.h> +#include <dma.h> #include <net.h> #include <io.h> #include <init.h> @@ -197,6 +197,8 @@ static int arc_emac_open(struct eth_device *edev) rxbd->data = cpu_to_le32(rxbuf); /* Return ownership to EMAC */ + dma_sync_single_for_device((unsigned long)rxbuf, PKTSIZE, + DMA_FROM_DEVICE); rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE); *last_rx_bd = (*last_rx_bd + 1) % RX_BD_NUM; @@ -246,7 +248,7 @@ static int arc_emac_send(struct eth_device *edev, void *data, int length) length = EMAC_ZLEN; } - dma_flush_range((unsigned long)data, (unsigned long)data + length); + dma_sync_single_for_device((unsigned long)data, length, DMA_TO_DEVICE); bd->data = cpu_to_le32(data); bd->info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | length); @@ -255,6 +257,8 @@ static int arc_emac_send(struct eth_device *edev, void *data, int length) ret = wait_on_timeout(20 * MSECOND, (arc_reg_get(priv, R_STATUS) & TXINT_MASK) != 0); + dma_sync_single_for_cpu((unsigned long)data, length, DMA_TO_DEVICE); + if (ret) { dev_err(&edev->dev, "transmit timeout\n"); return ret; @@ -296,18 +300,19 @@ static int arc_emac_recv(struct eth_device *edev) printk(KERN_DEBUG "incomplete packet received\n"); /* Return ownership to EMAC */ - rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE); continue; } pktlen = info & LEN_MASK; - /* invalidate current receive buffer */ - dma_inv_range((unsigned long)rxbd->data, - (unsigned long)rxbd->data + pktlen); + dma_sync_single_for_cpu((unsigned long)rxbd->data, pktlen, + DMA_FROM_DEVICE); net_receive(edev, (unsigned char *)rxbd->data, pktlen); + dma_sync_single_for_device((unsigned long)rxbd->data, pktlen, + DMA_FROM_DEVICE); + rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE); } @@ -438,8 +443,10 @@ static int arc_emac_probe(struct device_d *dev) miibus->parent = dev; /* allocate rx/tx descriptors */ - priv->rxbd = dma_alloc_coherent(RX_BD_NUM * sizeof(struct arc_emac_bd)); - priv->txbd = dma_alloc_coherent(TX_BD_NUM * sizeof(struct arc_emac_bd)); + priv->rxbd = dma_alloc_coherent(RX_BD_NUM * sizeof(struct arc_emac_bd), + DMA_ADDRESS_BROKEN); + priv->txbd = dma_alloc_coherent(TX_BD_NUM * sizeof(struct arc_emac_bd), + DMA_ADDRESS_BROKEN); priv->rxbuf = dma_alloc(RX_BD_NUM * PKTSIZE); /* Set poll rate so that it polls every 1 ms */ diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c index e09ea83f68..5a74837f65 100644 --- a/drivers/net/at91_ether.c +++ b/drivers/net/at91_ether.c @@ -20,6 +20,7 @@ */ #include <common.h> +#include <dma.h> #include <net.h> #include <clock.h> #include <malloc.h> @@ -34,7 +35,6 @@ #include <linux/clk.h> #include <linux/mii.h> #include <errno.h> -#include <asm/mmu.h> #include <linux/phy.h> #include "at91_ether.h" @@ -199,7 +199,8 @@ static int at91_ether_send(struct eth_device *edev, void *packet, int length) { while (!(at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ)); - dma_flush_range((ulong) packet, (ulong)packet + length); + dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE); + /* Set address of the data in the Transmit Address register */ at91_emac_write(AT91_EMAC_TAR, (unsigned long) packet); /* Set length of the packet in the Transmit Control register */ @@ -210,6 +211,8 @@ static int at91_ether_send(struct eth_device *edev, void *packet, int length) at91_emac_write(AT91_EMAC_TSR, at91_emac_read(AT91_EMAC_TSR) | AT91_EMAC_TSR_COMP); + dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE); + return 0; } @@ -224,7 +227,11 @@ static int at91_ether_rx(struct eth_device *edev) size = rbfp->size & RBF_SIZE; + dma_sync_single_for_cpu((unsigned long)rbfp->addr, size, + DMA_FROM_DEVICE); net_receive(edev, (unsigned char *)(rbfp->addr & RBF_ADDR), size); + dma_sync_single_for_device((unsigned long)rbfp->addr, size, + DMA_FROM_DEVICE); rbfp->addr &= ~RBF_OWNER; if (rbfp->addr & RBF_WRAP) @@ -320,8 +327,10 @@ static int at91_ether_probe(struct device_d *dev) edev->halt = at91_ether_halt; edev->get_ethaddr = at91_ether_get_ethaddr; edev->set_ethaddr = at91_ether_set_ethaddr; - ether_dev->rbf_framebuf = dma_alloc_coherent(MAX_RX_DESCR * MAX_RBUFF_SZ); - ether_dev->rbfdt = dma_alloc_coherent(sizeof(struct rbf_t) * MAX_RX_DESCR); + ether_dev->rbf_framebuf = dma_alloc_coherent(MAX_RX_DESCR * MAX_RBUFF_SZ, + DMA_ADDRESS_BROKEN); + ether_dev->rbfdt = dma_alloc_coherent(sizeof(struct rbf_t) * MAX_RX_DESCR, + DMA_ADDRESS_BROKEN); ether_dev->phy_addr = pdata->phy_addr; miibus->read = at91_ether_mii_read; diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index 301b8a9dfd..76872546fd 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -21,6 +21,7 @@ #include <init.h> #include <command.h> +#include <dma.h> #include <net.h> #include <malloc.h> #include <net.h> @@ -32,7 +33,6 @@ #include <of_net.h> #include <of_address.h> #include <xfuncs.h> -#include <asm/mmu.h> #include <asm/system.h> #include <linux/err.h> @@ -871,9 +871,9 @@ static int cpsw_send(struct eth_device *edev, void *packet, int length) dev_dbg(&slave->dev, "%s: %i bytes @ 0x%p\n", __func__, length, packet); - dma_flush_range((ulong) packet, (ulong)packet + length); - + dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE); ret = cpdma_submit(priv, &priv->tx_chan, packet, length); + dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE); return ret; } @@ -886,9 +886,11 @@ static int cpsw_recv(struct eth_device *edev) int len; while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) { - dma_inv_range((ulong)buffer, (ulong)buffer + len); + dma_sync_single_for_cpu((unsigned long)buffer, len, + DMA_FROM_DEVICE); net_receive(edev, buffer, len); - dma_inv_range((ulong)buffer, (ulong)buffer + len); + dma_sync_single_for_device((unsigned long)buffer, len, + DMA_FROM_DEVICE); cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE); } diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index ce367a3656..056ffe28bc 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -40,12 +40,12 @@ */ #include <common.h> +#include <dma.h> #include <io.h> #include <clock.h> #include <net.h> #include <malloc.h> #include <init.h> -#include <asm/mmu.h> #include <asm/system.h> #include <linux/phy.h> #include <mach/emac_defs.h> @@ -411,7 +411,7 @@ static int davinci_emac_send(struct eth_device *edev, void *packet, int length) EMAC_CPPI_OWNERSHIP_BIT | EMAC_CPPI_EOP_BIT), priv->emac_tx_desc + EMAC_DESC_PKT_FLAG_LEN); - dma_flush_range((ulong) packet, (ulong)packet + length); + dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE); /* Send the packet */ writel(BD_TO_HW(priv->emac_tx_desc), priv->adap_emac + EMAC_TX0HDP); @@ -429,6 +429,7 @@ static int davinci_emac_send(struct eth_device *edev, void *packet, int length) break; } } + dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE); dev_dbg(priv->dev, "- emac_send (ret_status %i)\n", ret_status); return ret_status; @@ -460,9 +461,9 @@ static int davinci_emac_recv(struct eth_device *edev) pkt = (unsigned char *)readl(rx_curr_desc + EMAC_DESC_BUFFER); len = readl(rx_curr_desc + EMAC_DESC_BUFF_OFF_LEN) & 0xffff; dev_dbg(priv->dev, "| emac_recv got packet (length %i)\n", len); - dma_inv_range((ulong)pkt, - (ulong)readl(rx_curr_desc + EMAC_DESC_BUFFER) + len); + dma_sync_single_for_cpu((unsigned long)pkt, len, DMA_FROM_DEVICE); net_receive(edev, pkt, len); + dma_sync_single_for_device((unsigned long)pkt, len, DMA_FROM_DEVICE); ret = len; } diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 29a6047c7f..1b16db5806 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -22,11 +22,11 @@ */ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <net.h> #include <of_net.h> -#include <asm/mmu.h> #include <net/designware.h> #include <linux/phy.h> #include <linux/err.h> @@ -196,8 +196,8 @@ static void rx_descs_init(struct eth_device *dev) else desc_p->dmamac_cntl |= DESC_RXCTRL_RXCHAIN; - dma_inv_range((unsigned long)desc_p->dmamac_addr, - (unsigned long)desc_p->dmamac_addr + CONFIG_ETH_BUFSIZE); + dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, + CONFIG_ETH_BUFSIZE, DMA_FROM_DEVICE); desc_p->txrx_status = DESC_RXSTS_OWNBYDMA; } @@ -301,8 +301,8 @@ static int dwc_ether_send(struct eth_device *dev, void *packet, int length) } memcpy((void *)desc_p->dmamac_addr, packet, length); - dma_flush_range((unsigned long)desc_p->dmamac_addr, - (unsigned long)desc_p->dmamac_addr + length); + dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length, + DMA_TO_DEVICE); if (priv->enh_desc) { desc_p->txrx_status |= DESC_ENH_TXSTS_TXFIRST | DESC_ENH_TXSTS_TXLAST; @@ -327,6 +327,9 @@ static int dwc_ether_send(struct eth_device *dev, void *packet, int length) /* Start the transmission */ writel(POLL_DATA, &dma_p->txpolldemand); + dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length, + DMA_TO_DEVICE); + return 0; } @@ -350,10 +353,11 @@ static int dwc_ether_rx(struct eth_device *dev) * Make the current descriptor valid again and go to * the next one */ - dma_inv_range((unsigned long)desc_p->dmamac_addr, - (unsigned long)desc_p->dmamac_addr + length); - + dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length, + DMA_FROM_DEVICE); net_receive(dev, desc_p->dmamac_addr, length); + dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length, + DMA_FROM_DEVICE); desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA; @@ -451,9 +455,11 @@ static int dwc_ether_probe(struct device_d *dev) dwc_version(dev, readl(&priv->mac_regs_p->version)); priv->dma_regs_p = base + DW_DMA_BASE_OFFSET; priv->tx_mac_descrtable = dma_alloc_coherent( - CONFIG_TX_DESCR_NUM * sizeof(struct dmamacdescr)); + CONFIG_TX_DESCR_NUM * sizeof(struct dmamacdescr), + DMA_ADDRESS_BROKEN); priv->rx_mac_descrtable = dma_alloc_coherent( - CONFIG_RX_DESCR_NUM * sizeof(struct dmamacdescr)); + CONFIG_RX_DESCR_NUM * sizeof(struct dmamacdescr), + DMA_ADDRESS_BROKEN); priv->txbuffs = dma_alloc(TX_TOTAL_BUFSIZE); priv->rxbuffs = dma_alloc(RX_TOTAL_BUFSIZE); diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c index c1fa1517da..875905a1bf 100644 --- a/drivers/net/fec_imx.c +++ b/drivers/net/fec_imx.c @@ -15,6 +15,7 @@ */ #include <common.h> +#include <dma.h> #include <malloc.h> #include <net.h> #include <init.h> @@ -30,8 +31,6 @@ #include <of_gpio.h> #include <gpio.h> -#include <asm/mmu.h> - #include "fec_imx.h" struct fec_frame { @@ -478,8 +477,9 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length) writew(data_length, &fec->tbd_base[fec->tbd_index].data_length); writel((uint32_t)(eth_data), &fec->tbd_base[fec->tbd_index].data_pointer); - dma_flush_range((unsigned long)eth_data, - (unsigned long)(eth_data + data_length)); + + dma_sync_single_for_device((unsigned long)eth_data, data_length, + DMA_TO_DEVICE); /* * update BD's status now * This block: @@ -502,6 +502,8 @@ static int fec_send(struct eth_device *dev, void *eth_data, int data_length) break; } } + dma_sync_single_for_cpu((unsigned long)eth_data, data_length, + DMA_TO_DEVICE); /* for next transmission use the other buffer */ if (fec->tbd_index) @@ -575,7 +577,11 @@ static int fec_recv(struct eth_device *dev) */ frame = phys_to_virt(readl(&rbd->data_pointer)); frame_length = readw(&rbd->data_length) - 4; + dma_sync_single_for_cpu((unsigned long)frame->data, + frame_length, DMA_FROM_DEVICE); net_receive(dev, frame->data, frame_length); + dma_sync_single_for_device((unsigned long)frame->data, + frame_length, DMA_FROM_DEVICE); len = frame_length; } else { if (bd_status & FEC_RBD_ERR) { @@ -600,7 +606,7 @@ static int fec_alloc_receive_packets(struct fec_priv *fec, int count, int size) int i; /* reserve data memory and consider alignment */ - p = dma_alloc_coherent(size * count); + p = dma_alloc_coherent(size * count, DMA_ADDRESS_BROKEN); if (!p) return -ENOMEM; @@ -698,7 +704,7 @@ static int fec_probe(struct device_d *dev) * Datasheet forces the startaddress of each chain is 16 byte aligned */ base = dma_alloc_coherent((2 + FEC_RBD_NUM) * - sizeof(struct buffer_descriptor)); + sizeof(struct buffer_descriptor), DMA_ADDRESS_BROKEN); fec->rbd_base = base; base += FEC_RBD_NUM * sizeof(struct buffer_descriptor); fec->tbd_base = base; diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 8e67aecc84..2ac00f3460 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -38,6 +38,7 @@ #include <net.h> #include <clock.h> +#include <dma.h> #include <malloc.h> #include <xfuncs.h> #include <init.h> @@ -46,7 +47,6 @@ #include <platform_data/macb.h> #include <linux/clk.h> #include <linux/err.h> -#include <asm/mmu.h> #include <linux/phy.h> #include "macb.h" @@ -121,7 +121,7 @@ static int macb_send(struct eth_device *edev, void *packet, macb->tx_ring[tx_head].ctrl = ctrl; macb->tx_ring[tx_head].addr = (ulong)packet; barrier(); - dma_flush_range((ulong) packet, (ulong)packet + length); + dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE); macb_writel(macb, NCR, MACB_BIT(TE) | MACB_BIT(RE) | MACB_BIT(TSTART)); start = get_time_ns(); @@ -134,6 +134,7 @@ static int macb_send(struct eth_device *edev, void *packet, break; } } while (!is_timeout(start, 100 * MSECOND)); + dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE); if (ctrl & MACB_BIT(TX_UNDERRUN)) dev_err(macb->dev, "TX underrun\n"); @@ -187,7 +188,11 @@ static int gem_recv(struct eth_device *edev) status = macb->rx_ring[macb->rx_tail].ctrl; length = MACB_BFEXT(RX_FRMLEN, status); buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail; + dma_sync_single_for_cpu((unsigned long)buffer, length, + DMA_FROM_DEVICE); net_receive(edev, buffer, length); + dma_sync_single_for_device((unsigned long)buffer, length, + DMA_FROM_DEVICE); macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED); barrier(); @@ -597,7 +602,8 @@ static void macb_init_rx_buffer_size(struct macb_device *bp, size_t size) bp->rx_buffer_size = roundup(bp->rx_buffer_size, RX_BUFFER_MULTIPLE); } - bp->rx_buffer = dma_alloc_coherent(bp->rx_buffer_size * bp->rx_ring_size); + bp->rx_buffer = dma_alloc_coherent(bp->rx_buffer_size * bp->rx_ring_size, + DMA_ADDRESS_BROKEN); } dev_dbg(bp->dev, "[%d] rx_buffer_size [%d]\n", @@ -667,9 +673,10 @@ static int macb_probe(struct device_d *dev) edev->recv = macb_recv; macb_init_rx_buffer_size(macb, PKTSIZE); - macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size); - macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb)); - macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES); + macb->rx_buffer = dma_alloc_coherent(macb->rx_buffer_size * macb->rx_ring_size, + DMA_ADDRESS_BROKEN); + macb->rx_ring = dma_alloc_coherent(RX_RING_BYTES(macb), DMA_ADDRESS_BROKEN); + macb->tx_ring = dma_alloc_coherent(TX_RING_BYTES, DMA_ADDRESS_BROKEN); macb_reset_hw(macb); ncfgr = macb_mdc_clk_div(macb); diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index 8042e90951..f2948e4ed7 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -24,6 +24,7 @@ */ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <net.h> @@ -590,9 +591,11 @@ void mvneta_setup_tx_rx(struct mvneta_port *priv) u32 val; /* Allocate descriptors and buffers */ - priv->txdesc = dma_alloc_coherent(ALIGN(sizeof(*priv->txdesc), 32)); + priv->txdesc = dma_alloc_coherent(ALIGN(sizeof(*priv->txdesc), 32), + DMA_ADDRESS_BROKEN); priv->rxdesc = dma_alloc_coherent(RX_RING_SIZE * - ALIGN(sizeof(*priv->rxdesc), 32)); + ALIGN(sizeof(*priv->rxdesc), 32), + DMA_ADDRESS_BROKEN); priv->rxbuf = dma_alloc(RX_RING_SIZE * ALIGN(PKTSIZE, 8)); mvneta_init_rx_ring(priv); diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c index 3fbc1df893..97ffff2b26 100644 --- a/drivers/net/orion-gbe.c +++ b/drivers/net/orion-gbe.c @@ -27,12 +27,12 @@ * MA 02110-1301 USA */ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <net.h> #include <of_net.h> #include <linux/sizes.h> -#include <asm/mmu.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/mbus.h> @@ -242,7 +242,7 @@ static int port_send(struct eth_device *edev, void *data, int len) int ret; /* flush transmit data */ - dma_flush_range((unsigned long)data, (unsigned long)data+len); + dma_sync_single_for_device((unsigned long)data, len, DMA_TO_DEVICE); txdesc->cmd_sts = TXDESC_OWNED_BY_DMA; txdesc->cmd_sts |= TXDESC_FIRST | TXDESC_LAST; @@ -257,6 +257,7 @@ static int port_send(struct eth_device *edev, void *data, int len) /* wait for packet transmit completion */ ret = wait_on_timeout(TRANSFER_TIMEOUT, (readl(&txdesc->cmd_sts) & TXDESC_OWNED_BY_DMA) == 0); + dma_sync_single_for_cpu((unsigned long)data, len, DMA_TO_DEVICE); if (ret) { dev_err(&edev->dev, "transmit timeout\n"); return ret; @@ -300,12 +301,15 @@ static int port_recv(struct eth_device *edev) } /* invalidate current receive buffer */ - dma_inv_range((unsigned long)rxdesc->buf_ptr, - (unsigned long)rxdesc->buf_ptr + - ALIGN(PKTSIZE, 8)); + dma_sync_single_for_cpu((unsigned long)rxdesc->buf_ptr, + ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE); /* received packet is padded with two null bytes */ net_receive(edev, rxdesc->buf_ptr + 0x2, rxdesc->byte_cnt - 0x2); + + dma_sync_single_for_device((unsigned long)rxdesc->buf_ptr, + ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE); + ret = 0; recv_err: @@ -419,9 +423,11 @@ static int port_probe(struct device_d *parent, struct port_priv *port) return PTR_ERR(port->regs); /* allocate rx/tx descriptors and buffers */ - port->txdesc = dma_alloc_coherent(ALIGN(sizeof(*port->txdesc), 16)); + port->txdesc = dma_alloc_coherent(ALIGN(sizeof(*port->txdesc), 16), + DMA_ADDRESS_BROKEN); port->rxdesc = dma_alloc_coherent(RX_RING_SIZE * - ALIGN(sizeof(*port->rxdesc), 16)); + ALIGN(sizeof(*port->rxdesc), 16), + DMA_ADDRESS_BROKEN); port->rxbuf = dma_alloc(RX_RING_SIZE * ALIGN(PKTSIZE, 8)); port_stop(port); diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index b24a083a56..d57c706e52 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -1,4 +1,5 @@ #include <common.h> +#include <dma.h> #include <net.h> #include <malloc.h> #include <init.h> diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index f8a6500a0f..d6a761087c 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -14,8 +14,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <asm/mmu.h> #include <common.h> +#include <dma.h> #include <init.h> #include <net.h> #include <malloc.h> @@ -228,13 +228,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv) priv->cur_rx = priv->cur_tx = 0; priv->tx_desc = dma_alloc_coherent(NUM_TX_DESC * - sizeof(struct bufdesc)); + sizeof(struct bufdesc), DMA_ADDRESS_BROKEN); priv->tx_buf = malloc(NUM_TX_DESC * PKT_BUF_SIZE); priv->rx_desc = dma_alloc_coherent(NUM_RX_DESC * - sizeof(struct bufdesc)); + sizeof(struct bufdesc), DMA_ADDRESS_BROKEN); priv->rx_buf = malloc(NUM_RX_DESC * PKT_BUF_SIZE); - dma_clean_range((unsigned long)priv->rx_buf, - (unsigned long)priv->rx_buf + NUM_RX_DESC * PKT_BUF_SIZE); + dma_sync_single_for_device((unsigned long)priv->rx_buf, + NUM_RX_DESC * PKT_BUF_SIZE, DMA_FROM_DEVICE); memset((void *)priv->tx_desc, 0, NUM_TX_DESC * sizeof(struct bufdesc)); memset((void *)priv->rx_desc, 0, NUM_RX_DESC * sizeof(struct bufdesc)); @@ -365,8 +365,8 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet, if (packet_length < ETH_ZLEN) memset(priv->tx_buf + entry * PKT_BUF_SIZE, 0, ETH_ZLEN); memcpy(priv->tx_buf + entry * PKT_BUF_SIZE, packet, packet_length); - dma_flush_range((unsigned long)priv->tx_buf + entry * PKT_BUF_SIZE, - (unsigned long)priv->tx_buf + (entry + 1) * PKT_BUF_SIZE); + dma_sync_single_for_device((unsigned long)priv->tx_buf + entry * + PKT_BUF_SIZE, PKT_BUF_SIZE, DMA_TO_DEVICE); priv->tx_desc[entry].buf_Haddr = 0; priv->tx_desc[entry].buf_addr = @@ -387,6 +387,9 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet, while (priv->tx_desc[entry].status & BD_STAT_OWN) ; + dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry * + PKT_BUF_SIZE, PKT_BUF_SIZE, DMA_TO_DEVICE); + priv->cur_tx++; return 0; @@ -404,22 +407,16 @@ static int rtl8169_eth_rx(struct eth_device *edev) if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) { pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4; - dma_inv_range((unsigned long)priv->rx_buf - + entry * PKT_BUF_SIZE, - (unsigned long)priv->rx_buf - + entry * PKT_BUF_SIZE + pkt_size); + dma_sync_single_for_cpu((unsigned long)priv->rx_buf + + entry * PKT_BUF_SIZE, + pkt_size, DMA_FROM_DEVICE); net_receive(edev, priv->rx_buf + entry * PKT_BUF_SIZE, pkt_size); - /* - * the buffer is going to be reused by HW, make sure to - * clean out any potentially modified data - */ - dma_clean_range((unsigned long)priv->rx_buf - + entry * PKT_BUF_SIZE, - (unsigned long)priv->rx_buf - + entry * PKT_BUF_SIZE + pkt_size); + dma_sync_single_for_device((unsigned long)priv->rx_buf + + entry * PKT_BUF_SIZE, + pkt_size, DMA_FROM_DEVICE); if (entry == NUM_RX_DESC - 1) priv->rx_desc[entry].status = BD_STAT_OWN | diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c index cc22d0ea54..3b2273fd79 100644 --- a/drivers/net/xgmac.c +++ b/drivers/net/xgmac.c @@ -16,6 +16,7 @@ */ #include <common.h> +#include <dma.h> #include <net.h> #include <clock.h> #include <malloc.h> @@ -24,7 +25,6 @@ #include <errno.h> #include <io.h> #include <linux/err.h> -#include <asm/mmu.h> #define TX_NUM_DESC 1 #define RX_NUM_DESC 32 @@ -586,7 +586,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length) struct xgmac_dma_desc *txdesc = &priv->tx_chain[currdesc]; int ret; - dma_flush_range((ulong) packet, (ulong)packet + length); + dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE); desc_set_buf_addr_and_size(txdesc, packet, length); desc_set_tx_owner(txdesc, TXDESC_FIRST_SEG | TXDESC_LAST_SEG | TXDESC_CRC_EN_APPEND); @@ -595,6 +595,7 @@ static int xgmac_send(struct eth_device *edev, void *packet, int length) writel(1, priv->base + XGMAC_DMA_TX_POLL); ret = wait_on_timeout(1 * SECOND, !desc_get_owner(txdesc)); + dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE); if (ret) { dev_err(priv->dev, "TX timeout\n"); return ret; @@ -610,14 +611,19 @@ static int xgmac_recv(struct eth_device *edev) u32 currdesc = priv->rx_currdesc; struct xgmac_dma_desc *rxdesc = &priv->rx_chain[currdesc]; int length = 0; + void *buf_addr; /* check if the host has the desc */ if (desc_get_owner(rxdesc)) return -1; /* something bad happened */ length = desc_get_rx_frame_len(rxdesc); + buf_addr = desc_get_buf_addr(rxdesc); - net_receive(edev, desc_get_buf_addr(rxdesc), length); + dma_sync_single_for_cpu((unsigned long)buf_addr, length, DMA_FROM_DEVICE); + net_receive(edev, buf_addr, length); + dma_sync_single_for_device((unsigned long)buf_addr, length, + DMA_FROM_DEVICE); /* set descriptor back to owned by XGMAC */ desc_set_rx_owner(rxdesc); @@ -698,9 +704,11 @@ static int hb_xgmac_probe(struct device_d *dev) priv->dev = dev; priv->base = base; - priv->rxbuffer = dma_alloc_coherent(RX_BUF_SZ); - priv->rx_chain = dma_alloc_coherent(RX_NUM_DESC * sizeof(struct xgmac_dma_desc)); - priv->tx_chain = dma_alloc_coherent(TX_NUM_DESC * sizeof(struct xgmac_dma_desc)); + priv->rxbuffer = dma_alloc_coherent(RX_BUF_SZ, DMA_ADDRESS_BROKEN); + priv->rx_chain = dma_alloc_coherent(RX_NUM_DESC * sizeof(struct xgmac_dma_desc), + DMA_ADDRESS_BROKEN); + priv->tx_chain = dma_alloc_coherent(TX_NUM_DESC * sizeof(struct xgmac_dma_desc), + DMA_ADDRESS_BROKEN); edev = &priv->edev; edev->priv = priv; diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index 8932103475..9fe2fd4eaf 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -23,7 +23,6 @@ #include <stmp-device.h> #include <linux/clk.h> #include <linux/err.h> -#include <asm/mmu.h> #include <mach/generic.h> #include <mach/clock.h> #include <mach/ssp.h> diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c index d067f03a40..19f3da65bb 100644 --- a/drivers/usb/gadget/fsl_udc.c +++ b/drivers/usb/gadget/fsl_udc.c @@ -1,4 +1,5 @@ #include <common.h> +#include <dma.h> #include <errno.h> #include <dma.h> #include <init.h> @@ -10,6 +11,8 @@ #include <asm/byteorder.h> #include <linux/err.h> +#include <asm/mmu.h> + /* ### define USB registers here */ #define USB_MAX_CTRL_PAYLOAD 64 @@ -562,11 +565,11 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int status) if (j != req->dtd_count - 1) { next_td = curr_td->next_td_virt; } - dma_free_coherent(curr_td, sizeof(struct ep_td_struct)); + dma_free_coherent(curr_td, 0, sizeof(struct ep_td_struct)); } - dma_inv_range((unsigned long)req->req.buf, - (unsigned long)(req->req.buf + req->req.length)); + dma_sync_single_for_cpu((unsigned long)req->req.buf, req->req.length, + DMA_BIDIRECTIONAL); if (status && (status != -ESHUTDOWN)) VDBG("complete %s req %p stat %d len %u/%u", @@ -1135,7 +1138,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, *length = min(req->req.length - req->req.actual, (unsigned)EP_MAX_LENGTH_TRANSFER); - dtd = dma_alloc_coherent(sizeof(struct ep_td_struct)); + dtd = dma_alloc_coherent(sizeof(struct ep_td_struct), + DMA_ADDRESS_BROKEN); if (dtd == NULL) return dtd; @@ -1247,8 +1251,8 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req) req->ep = ep; - dma_flush_range((unsigned long)req->req.buf, - (unsigned long)(req->req.buf + req->req.length)); + dma_sync_single_for_device((unsigned long)req->req.buf, req->req.length, + DMA_BIDIRECTIONAL); req->req.status = -EINPROGRESS; req->req.actual = 0; @@ -2058,7 +2062,7 @@ static int struct_udc_setup(struct fsl_udc *udc, size &= ~(QH_ALIGNMENT - 1); } - udc->ep_qh = dma_alloc_coherent(size); + udc->ep_qh = dma_alloc_coherent(size, DMA_ADDRESS_BROKEN); if (!udc->ep_qh) { ERR("malloc QHs for udc failed\n"); kfree(udc->eps); diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 7b913270be..abaeaf2aa7 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -18,6 +18,7 @@ */ /*#define DEBUG */ #include <common.h> +#include <dma.h> #include <asm/byteorder.h> #include <usb/usb.h> #include <io.h> @@ -29,7 +30,6 @@ #include <errno.h> #include <of.h> #include <usb/ehci.h> -#include <asm/mmu.h> #include <linux/err.h> #include "ehci.h" @@ -330,7 +330,9 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, struct qTD *qtd = &ehci->td[i]; if (!qtd->qtd_dma) continue; - dma_flush_range(qtd->qtd_dma, qtd->qtd_dma + qtd->length); + dma_sync_single_for_device((unsigned long)qtd->qtd_dma, + qtd->length, + DMA_BIDIRECTIONAL); } } @@ -371,7 +373,8 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, struct qTD *qtd = &ehci->td[i]; if (!qtd->qtd_dma) continue; - dma_inv_range(qtd->qtd_dma, qtd->qtd_dma + qtd->length); + dma_sync_single_for_cpu((unsigned long)qtd->qtd_dma, + qtd->length, DMA_BIDIRECTIONAL); } } @@ -890,8 +893,10 @@ int ehci_register(struct device_d *dev, struct ehci_data *data) ehci->init = data->init; ehci->post_init = data->post_init; - ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD); - ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD); + ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD, + DMA_ADDRESS_BROKEN); + ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD, + DMA_ADDRESS_BROKEN); host->hw_dev = dev; host->init = ehci_init; diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 622f5c3a5b..1d511b7563 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -41,7 +41,9 @@ * to activate workaround for bug #41 or this driver will NOT work! */ #include <common.h> +#include <dma.h> #include <clock.h> +#include <dma.h> #include <malloc.h> #include <usb/usb.h> #include <usb/usb_defs.h> @@ -51,7 +53,6 @@ #include <asm/byteorder.h> #include <io.h> -#include <asm/mmu.h> #include "ohci.h" @@ -856,7 +857,7 @@ static void td_fill(struct ohci *ohci, unsigned int info, td->hwNextTD = virt_to_phys((void *)m32_swap((unsigned long)td_pt)); - dma_flush_range((unsigned long)data, (unsigned long)(data + len)); + dma_sync_single_for_device((unsigned long)data, len, DMA_BIDIRECTIONAL); /* append to queue */ td->ed->hwTailP = td->hwNextTD; @@ -1092,7 +1093,8 @@ static int dl_done_list(struct ohci *ohci) unsigned long ptdphys = virt_to_phys(ptd); struct td *td_list; - dma_clean_range(ptdphys, ptdphys + (sizeof(struct td) * NUM_TD)); + dma_sync_single_for_device((unsigned long)ptdphys, + sizeof(struct td) * NUM_TD, DMA_BIDIRECTIONAL); td_list = dl_reverse_done_list(ohci); @@ -1528,7 +1530,8 @@ static int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *b dev->status = stat; dev->act_len = urb->actual_length; - dma_inv_range((unsigned long)buffer, (unsigned long)(buffer + transfer_len)); + dma_sync_single_for_cpu((unsigned long)buffer, transfer_len, + DMA_BIDIRECTIONAL); pkt_print(urb, dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe)); @@ -1758,7 +1761,8 @@ static int ohci_init(struct usb_host *host) info("%s\n", __func__); - ohci->ptd = dma_alloc_coherent(sizeof(struct td) * NUM_TD); + ohci->ptd = dma_alloc_coherent(sizeof(struct td) * NUM_TD, + DMA_ADDRESS_BROKEN); if (!ohci->ptd) return -ENOMEM; memset(ohci->ptd, 0, sizeof(struct td) * NUM_TD); @@ -1801,11 +1805,13 @@ static int ohci_probe(struct device_d *dev) host->submit_control_msg = submit_control_msg; host->submit_bulk_msg = submit_bulk_msg; - ohci->hcca = dma_alloc_coherent(sizeof(*ohci->hcca)); + ohci->hcca = dma_alloc_coherent(sizeof(*ohci->hcca), + DMA_ADDRESS_BROKEN); if (!ohci->hcca) return -ENOMEM; - ohci->ohci_dev = dma_alloc_coherent(sizeof(*ohci->ohci_dev)); + ohci->ohci_dev = dma_alloc_coherent(sizeof(*ohci->ohci_dev), + DMA_ADDRESS_BROKEN); if (!ohci->ohci_dev) return -ENOMEM; memset(ohci->ohci_dev, 0, sizeof(*ohci->ohci_dev)); diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c index 9253419750..c3d623e91f 100644 --- a/drivers/usb/host/xhci-hcd.c +++ b/drivers/usb/host/xhci-hcd.c @@ -12,9 +12,9 @@ * warranty of any kind, whether express or implied. */ //#define DEBUG -#include <asm/mmu.h> #include <clock.h> #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <linux/err.h> @@ -444,7 +444,7 @@ static struct xhci_virtual_device *xhci_alloc_virtdev(struct xhci_hcd *xhci, sz_ictx = ALIGN(sz_ctx + HCC_CTX_SIZE(xhci->hcc_params), 64); vdev->dma_size = sz_ictx + sz_dctx; - p = vdev->dma = dma_alloc_coherent(vdev->dma_size); + p = vdev->dma = dma_alloc_coherent(vdev->dma_size, DMA_ADDRESS_BROKEN); memset(vdev->dma, 0, vdev->dma_size); vdev->out_ctx = p; p += sz_dctx; @@ -463,7 +463,7 @@ static void xhci_free_virtdev(struct xhci_virtual_device *vdev) xhci_put_endpoint_ring(xhci, vdev->ep[i]); list_del(&vdev->list); - dma_free_coherent(vdev->dma, vdev->dma_size); + dma_free_coherent(vdev->dma, 0, vdev->dma_size); free(vdev); } @@ -1203,7 +1203,7 @@ static void xhci_dma_alloc(struct xhci_hcd *xhci) num_ep = max(MAX_EP_RINGS, MIN_EP_RINGS + num_ep); xhci->dma_size += num_ep * sz_ep; - p = xhci->dma = dma_alloc_coherent(xhci->dma_size); + p = xhci->dma = dma_alloc_coherent(xhci->dma_size, DMA_ADDRESS_BROKEN); memset(xhci->dma, 0, xhci->dma_size); xhci->sp = p; p += sz_sp; diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index bf952570f8..5ae16f5ca5 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -14,7 +14,6 @@ * warranty of any kind, whether express or implied. */ //#define DEBUG -#include <asm/mmu.h> #include <clock.h> #include <common.h> #include <io.h> diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c index 26db7589af..f7aab7f454 100644 --- a/drivers/video/atmel_hlcdfb.c +++ b/drivers/video/atmel_hlcdfb.c @@ -27,7 +27,6 @@ #include <mach/io.h> #include <mach/cpu.h> #include <errno.h> -#include <asm/mmu.h> #include "atmel_lcdfb.h" diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index bb302bdc94..20204c1dd4 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -25,7 +25,6 @@ #include <mach/io.h> #include <mach/cpu.h> #include <errno.h> -#include <asm/mmu.h> #include <linux/clk.h> #include "atmel_lcdfb.h" diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c index 420ccbedf1..76116af1da 100644 --- a/drivers/video/atmel_lcdfb_core.c +++ b/drivers/video/atmel_lcdfb_core.c @@ -19,11 +19,11 @@ */ #include <common.h> +#include <dma.h> #include <io.h> #include <linux/err.h> #include <linux/clk.h> #include <malloc.h> -#include <asm/mmu.h> #include "atmel_lcdfb.h" @@ -200,7 +200,7 @@ static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo) * ((info->bits_per_pixel + 7) / 8)); smem_len = max(smem_len, sinfo->smem_len); - info->screen_base = dma_alloc_coherent(smem_len); + info->screen_base = dma_alloc_coherent(smem_len, DMA_ADDRESS_BROKEN); if (!info->screen_base) return -ENOMEM; @@ -289,7 +289,8 @@ int atmel_lcdc_register(struct device_d *dev, struct atmel_lcdfb_devdata *data) atmel_lcdfb_start_clock(sinfo); if (data->dma_desc_size) - sinfo->dma_desc = dma_alloc_coherent(data->dma_desc_size); + sinfo->dma_desc = dma_alloc_coherent(data->dma_desc_size, + DMA_ADDRESS_BROKEN); ret = register_framebuffer(info); if (ret != 0) { diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c index a69df50811..b56658202c 100644 --- a/drivers/video/imx-ipu-fb.c +++ b/drivers/video/imx-ipu-fb.c @@ -18,6 +18,7 @@ */ #include <common.h> +#include <dma.h> #include <init.h> #include <io.h> #include <mach/imx35-regs.h> @@ -1030,7 +1031,8 @@ static int imxfb_probe(struct device_d *dev) fbi->info.screen_size, mmu_get_pte_uncached_flags()); } else { - fbi->info.screen_base = dma_alloc_coherent(fbi->info.screen_size); + fbi->info.screen_base = dma_alloc_coherent(fbi->info.screen_size, + DMA_ADDRESS_BROKEN); if (!fbi->info.screen_base) return -ENOMEM; } diff --git a/drivers/video/imx-ipu-v3/ipu-common.c b/drivers/video/imx-ipu-v3/ipu-common.c index f13cf012a1..5c85f8615c 100644 --- a/drivers/video/imx-ipu-v3/ipu-common.c +++ b/drivers/video/imx-ipu-v3/ipu-common.c @@ -19,7 +19,6 @@ #include <clock.h> #include <driver.h> #include <init.h> -#include <asm/mmu.h> #include <mach/generic.h> #include <mach/imx6-regs.h> #include <mach/imx53-regs.h> diff --git a/drivers/video/imx-ipu-v3/ipufb.c b/drivers/video/imx-ipu-v3/ipufb.c index 14a099e14a..7ee4ae3627 100644 --- a/drivers/video/imx-ipu-v3/ipufb.c +++ b/drivers/video/imx-ipu-v3/ipufb.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) "IPU: " fmt #include <common.h> +#include <dma.h> #include <fb.h> #include <io.h> #include <driver.h> @@ -21,7 +22,6 @@ #include <linux/clk.h> #include <linux/err.h> #include <asm-generic/div64.h> -#include <asm/mmu.h> #include "imx-ipu-v3.h" #include "ipuv3-plane.h" @@ -203,7 +203,8 @@ static int ipufb_activate_var(struct fb_info *info) struct ipufb_info *fbi = container_of(info, struct ipufb_info, info); info->line_length = info->xres * (info->bits_per_pixel >> 3); - fbi->info.screen_base = dma_alloc_coherent(info->line_length * info->yres); + fbi->info.screen_base = dma_alloc_coherent(info->line_length * info->yres, + DMA_ADDRESS_BROKEN); if (!fbi->info.screen_base) return -ENOMEM; diff --git a/drivers/video/omap.c b/drivers/video/omap.c index bd66c92f10..3603ad2ccb 100644 --- a/drivers/video/omap.c +++ b/drivers/video/omap.c @@ -19,6 +19,7 @@ */ #include <driver.h> +#include <dma.h> #include <fb.h> #include <errno.h> #include <xfuncs.h> @@ -126,7 +127,7 @@ static void omapfb_disable(struct fb_info *info) /* free frame buffer; but only when screen is not * preallocated */ if (info->screen_base) - dma_free_coherent(info->screen_base, fbi->dma_size); + dma_free_coherent(info->screen_base, 0, fbi->dma_size); } info->screen_base = NULL; @@ -270,13 +271,13 @@ static int omapfb_activate_var(struct fb_info *info) /*Free old screen buf*/ if (!fbi->prealloc_screen.addr && info->screen_base) - dma_free_coherent(info->screen_base, fbi->dma_size); + dma_free_coherent(info->screen_base, 0, fbi->dma_size); fbi->dma_size = PAGE_ALIGN(size); if (!fbi->prealloc_screen.addr) { /* case 1: no preallocated screen */ - info->screen_base = dma_alloc_coherent(size); + info->screen_base = dma_alloc_coherent(size, DMA_ADDRESS_BROKEN); } else if (fbi->prealloc_screen.size < fbi->dma_size) { /* case 2: preallocated screen, but too small */ dev_err(fbi->dev, diff --git a/drivers/video/pxa.c b/drivers/video/pxa.c index d6d11ae610..e76404d9c9 100644 --- a/drivers/video/pxa.c +++ b/drivers/video/pxa.c @@ -24,6 +24,7 @@ */ #include <common.h> +#include <dma.h> #include <driver.h> #include <errno.h> #include <fb.h> @@ -37,7 +38,6 @@ #include <mach/pxafb.h> #include <asm/io.h> -#include <asm/mmu.h> #include <asm-generic/div64.h> /* PXA LCD DMA descriptor */ @@ -522,11 +522,12 @@ static int pxafb_probe(struct device_d *dev) else fbi->info.screen_base = PTR_ALIGN(dma_alloc_coherent(info->xres * info->yres * - (info->bits_per_pixel >> 3) + PAGE_SIZE), + (info->bits_per_pixel >> 3) + PAGE_SIZE, + DMA_ADDRESS_BROKEN), PAGE_SIZE); - fbi->dma_buff = PTR_ALIGN(dma_alloc_coherent(sizeof(struct pxafb_dma_buff) + 16), - 16); + fbi->dma_buff = PTR_ALIGN(dma_alloc_coherent(sizeof(struct pxafb_dma_buff) + 16, + DMA_ADDRESS_BROKEN), 16); pxafb_activate_var(fbi); |