Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208656
b: refs/heads/master
c: 9bc4341
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mundt committed Apr 7, 2010
1 parent 4cf6f71 commit 6339c12
Show file tree
Hide file tree
Showing 11 changed files with 230 additions and 96 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0924fada1e64f92dd89818cf3a15571cc515afd8
refs/heads/master: 9bc4341eb79d885e5a9dda6384a60bb0f4655fe7
63 changes: 2 additions & 61 deletions trunk/arch/sh/include/asm/dmaengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@
#ifndef ASM_DMAENGINE_H
#define ASM_DMAENGINE_H

#include <linux/dmaengine.h>
#include <linux/list.h>
#include <linux/sh_dma.h>

#include <asm/dma-register.h>

#define SH_DMAC_MAX_CHANNELS 6

enum sh_dmae_slave_chan_id {
enum {
SHDMA_SLAVE_SCIF0_TX,
SHDMA_SLAVE_SCIF0_RX,
SHDMA_SLAVE_SCIF1_TX,
Expand All @@ -34,60 +29,6 @@ enum sh_dmae_slave_chan_id {
SHDMA_SLAVE_SIUA_RX,
SHDMA_SLAVE_SIUB_TX,
SHDMA_SLAVE_SIUB_RX,
SHDMA_SLAVE_NUMBER, /* Must stay last */
};

struct sh_dmae_slave_config {
enum sh_dmae_slave_chan_id slave_id;
dma_addr_t addr;
u32 chcr;
char mid_rid;
};

struct sh_dmae_channel {
unsigned int offset;
unsigned int dmars;
unsigned int dmars_bit;
};

struct sh_dmae_pdata {
struct sh_dmae_slave_config *slave;
int slave_num;
struct sh_dmae_channel *channel;
int channel_num;
unsigned int ts_low_shift;
unsigned int ts_low_mask;
unsigned int ts_high_shift;
unsigned int ts_high_mask;
unsigned int *ts_shift;
int ts_shift_num;
u16 dmaor_init;
};

struct device;

/* Used by slave DMA clients to request DMA to/from a specific peripheral */
struct sh_dmae_slave {
enum sh_dmae_slave_chan_id slave_id; /* Set by the platform */
struct device *dma_dev; /* Set by the platform */
struct sh_dmae_slave_config *config; /* Set by the driver */
};

struct sh_dmae_regs {
u32 sar; /* SAR / source address */
u32 dar; /* DAR / destination address */
u32 tcr; /* TCR / transfer count */
};

struct sh_desc {
struct sh_dmae_regs hw;
struct list_head node;
struct dma_async_tx_descriptor async_tx;
enum dma_data_direction direction;
dma_cookie_t cookie;
size_t partial;
int chunks;
int mark;
};

#endif
8 changes: 4 additions & 4 deletions trunk/arch/sh/include/asm/siu.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ struct device;

struct siu_platform {
struct device *dma_dev;
enum sh_dmae_slave_chan_id dma_slave_tx_a;
enum sh_dmae_slave_chan_id dma_slave_rx_a;
enum sh_dmae_slave_chan_id dma_slave_tx_b;
enum sh_dmae_slave_chan_id dma_slave_rx_b;
unsigned int dma_slave_tx_a;
unsigned int dma_slave_rx_a;
unsigned int dma_slave_tx_b;
unsigned int dma_slave_rx_b;
};

#endif /* ASM_SIU_H */
2 changes: 1 addition & 1 deletion trunk/drivers/dma/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ config TXX9_DMAC

config SH_DMAE
tristate "Renesas SuperH DMAC support"
depends on SUPERH && SH_DMA
depends on (SUPERH && SH_DMA) || (ARM && ARCH_SHMOBILE)
depends on !SH_DMA_API
select DMA_ENGINE
help
Expand Down
21 changes: 10 additions & 11 deletions trunk/drivers/dma/shdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include <linux/dma-mapping.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>

#include <asm/dmaengine.h>
#include <linux/sh_dma.h>

#include "shdma.h"

Expand All @@ -45,7 +44,7 @@ enum sh_dmae_desc_status {
#define LOG2_DEFAULT_XFER_SIZE 2

/* A bitmask with bits enough for enum sh_dmae_slave_chan_id */
static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SHDMA_SLAVE_NUMBER)];
static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SH_DMA_SLAVE_NUMBER)];

static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all);

Expand Down Expand Up @@ -267,19 +266,19 @@ static struct sh_desc *sh_dmae_get_desc(struct sh_dmae_chan *sh_chan)
}

static struct sh_dmae_slave_config *sh_dmae_find_slave(
struct sh_dmae_chan *sh_chan, enum sh_dmae_slave_chan_id slave_id)
struct sh_dmae_chan *sh_chan, struct sh_dmae_slave *param)
{
struct dma_device *dma_dev = sh_chan->common.device;
struct sh_dmae_device *shdev = container_of(dma_dev,
struct sh_dmae_device, common);
struct sh_dmae_pdata *pdata = shdev->pdata;
int i;

if ((unsigned)slave_id >= SHDMA_SLAVE_NUMBER)
if (param->slave_id >= SH_DMA_SLAVE_NUMBER)
return NULL;

for (i = 0; i < pdata->slave_num; i++)
if (pdata->slave[i].slave_id == slave_id)
if (pdata->slave[i].slave_id == param->slave_id)
return pdata->slave + i;

return NULL;
Expand All @@ -300,7 +299,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
if (param) {
struct sh_dmae_slave_config *cfg;

cfg = sh_dmae_find_slave(sh_chan, param->slave_id);
cfg = sh_dmae_find_slave(sh_chan, param);
if (!cfg)
return -EINVAL;

Expand Down Expand Up @@ -795,7 +794,7 @@ static irqreturn_t sh_dmae_interrupt(int irq, void *data)
return ret;
}

#if defined(CONFIG_CPU_SH4)
#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
static irqreturn_t sh_dmae_err(int irq, void *data)
{
struct sh_dmae_device *shdev = (struct sh_dmae_device *)data;
Expand Down Expand Up @@ -1036,7 +1035,7 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
/* Default transfer size of 32 bytes requires 32-byte alignment */
shdev->common.copy_align = LOG2_DEFAULT_XFER_SIZE;

#if defined(CONFIG_CPU_SH4)
#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
chanirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);

if (!chanirq_res)
Expand All @@ -1061,7 +1060,7 @@ static int __init sh_dmae_probe(struct platform_device *pdev)

#else
chanirq_res = errirq_res;
#endif /* CONFIG_CPU_SH4 */
#endif /* CONFIG_CPU_SH4 || CONFIG_ARCH_SHMOBILE */

if (chanirq_res->start == chanirq_res->end &&
!platform_get_resource(pdev, IORESOURCE_IRQ, 1)) {
Expand Down Expand Up @@ -1108,7 +1107,7 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
chan_probe_err:
sh_dmae_chan_remove(shdev);
eirqres:
#if defined(CONFIG_CPU_SH4)
#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
free_irq(errirq, shdev);
eirq_err:
#endif
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/dma/shdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include <linux/interrupt.h>
#include <linux/list.h>

#include <asm/dmaengine.h>

#define SH_DMAC_MAX_CHANNELS 6
#define SH_DMA_SLAVE_NUMBER 256
#define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */

struct device;
Expand Down
18 changes: 8 additions & 10 deletions trunk/drivers/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ struct sci_port {
struct dma_chan *chan_rx;
#ifdef CONFIG_SERIAL_SH_SCI_DMA
struct device *dma_dev;
enum sh_dmae_slave_chan_id slave_tx;
enum sh_dmae_slave_chan_id slave_rx;
unsigned int slave_tx;
unsigned int slave_rx;
struct dma_async_tx_descriptor *desc_tx;
struct dma_async_tx_descriptor *desc_rx[2];
dma_cookie_t cookie_tx;
Expand Down Expand Up @@ -913,10 +913,10 @@ static void sci_dma_tx_complete(void *arg)

spin_lock_irqsave(&port->lock, flags);

xmit->tail += s->sg_tx.length;
xmit->tail += sg_dma_len(&s->sg_tx);
xmit->tail &= UART_XMIT_SIZE - 1;

port->icount.tx += s->sg_tx.length;
port->icount.tx += sg_dma_len(&s->sg_tx);

async_tx_ack(s->desc_tx);
s->cookie_tx = -EINVAL;
Expand Down Expand Up @@ -1131,14 +1131,13 @@ static void work_fn_tx(struct work_struct *work)
*/
spin_lock_irq(&port->lock);
sg->offset = xmit->tail & (UART_XMIT_SIZE - 1);
sg->dma_address = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) +
sg_dma_address(sg) = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) +
sg->offset;
sg->length = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE),
sg_dma_len(sg) = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE),
CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE));
sg->dma_length = sg->length;
spin_unlock_irq(&port->lock);

BUG_ON(!sg->length);
BUG_ON(!sg_dma_len(sg));

desc = chan->device->device_prep_slave_sg(chan,
sg, s->sg_len_tx, DMA_TO_DEVICE,
Expand Down Expand Up @@ -1339,8 +1338,7 @@ static void sci_request_dma(struct uart_port *port)
sg_init_table(sg, 1);
sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
(int)buf[i] & ~PAGE_MASK);
sg->dma_address = dma[i];
sg->dma_length = sg->length;
sg_dma_address(sg) = dma[i];
}

INIT_WORK(&s->work_rx, work_fn_rx);
Expand Down
Loading

0 comments on commit 6339c12

Please sign in to comment.