/*
* Driver for the TXx9 SoC DMA Controller
*
* Copyright (C) 2009 Atsushi Nemoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/dma-mapping.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/scatterlist.h>
#include "dmaengine.h"
#include "txx9dmac.h"
static struct txx9dmac_chan *to_txx9dmac_chan(struct dma_chan *chan)
{
return container_of(chan, struct txx9dmac_chan, chan);
}
static struct txx9dmac_cregs __iomem *__dma_regs(const struct txx9dmac_chan *dc)
{
return dc->ch_regs;
}
static struct txx9dmac_cregs32 __iomem *__dma_regs32(
const struct txx9dmac_chan *dc)
{
return dc->ch_regs;
}
#define channel64_readq(dc, name) \
__raw_readq(&(__dma_regs(dc)->name))
#define channel64_writeq(dc, name, val) \
__raw_writeq((val), &(__dma_regs(dc)->name))
#define channel64_readl(dc, name) \
__raw_readl(&(__dma_regs(dc)->name))
#define channel64_writel(dc, name, val) \
__raw_writel((val), &(__dma_regs(dc)->name))
#define channel32_readl(dc, name) \
__raw_readl(&(__dma_regs32(dc)->name))
#define channel32_writel(dc, name, val) \
__raw_writel((val), &(__dma_regs32(dc)->name))
#define channel_readq(dc, name) channel64_readq(dc, name)
#define channel_writeq(dc, name, val) channel64_writeq(dc, name, val)
#define channel_readl(dc, name) \
(is_dmac64(dc) ? \
channel64_readl(dc, name) : channel32_readl(dc, name))
#define channel_writel(dc, name, val) \
(is_dmac64(dc) ? \
channel64_writel(dc, name, val) : channel32_writel(dc, name, val))
static dma_addr_t channel64_read_CHAR(const struct txx9dmac_chan *dc)
{
if (sizeof(__dma_regs(dc)->CHAR) == sizeof(u64))
return channel64_readq(dc, CHAR);
else
return channel64_readl(dc, CHAR);
}
static void channel64_write_CHAR(const struct txx9dmac_chan *dc, dma_addr_t val)
{
if (sizeof(__dma_regs(dc)->CHAR) == sizeof(u64))
channel64_writeq(dc, CHAR, val);
else
channel64_writel(dc, CHAR, val);
}
static void channel64_clear_CHAR(const struct txx9dmac_chan *dc)
{
#if defined(CONFIG_32BIT) && !defined(CONFIG_64BIT_PHYS_ADDR)
channel64_writel(dc, CHAR, 0);
channel64_writel(dc, __pad_CHAR, 0);
#else
channel64_writeq(dc, CHAR, 0);
#endif
}
static dma_addr_t channel_read_CHAR(const struct txx9dmac_chan *<