Commit db9b99d4 authored by Mark Glaisher's avatar Mark Glaisher Committed by Paul Mundt

sh: dma-api channel capability extensions.

This extends the SH DMA API for allowing handling of DMA
channels based off of their respective capabilities.

A couple of functions are added to the existing API,
the core bits are register_chan_caps() for registering
channel capabilities, and request_dma_bycap() for fetching
a channel dynamically based off of a capability set.
Signed-off-by: default avatarMark Glaisher <mark.glaisher@st.com>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent e803aaf6
This diff is collapsed.
...@@ -14,9 +14,7 @@ ...@@ -14,9 +14,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/sysdev.h> #include <linux/sysdev.h>
#include <linux/device.h>
#include <asm/cpu/dma.h> #include <asm/cpu/dma.h>
#include <asm/semaphore.h>
/* The maximum address that we can perform a DMA transfer to on this platform */ /* The maximum address that we can perform a DMA transfer to on this platform */
/* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any /* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any
...@@ -46,16 +44,21 @@ ...@@ -46,16 +44,21 @@
* DMAC (dma_info) flags * DMAC (dma_info) flags
*/ */
enum { enum {
DMAC_CHANNELS_CONFIGURED = 0x00, DMAC_CHANNELS_CONFIGURED = 0x01,
DMAC_CHANNELS_TEI_CAPABLE = 0x01, DMAC_CHANNELS_TEI_CAPABLE = 0x02, /* Transfer end interrupt */
}; };
/* /*
* DMA channel capabilities / flags * DMA channel capabilities / flags
*/ */
enum { enum {
DMA_TEI_CAPABLE = 0x01, DMA_CONFIGURED = 0x01,
DMA_CONFIGURED = 0x02,
/*
* Transfer end interrupt, inherited from DMAC.
* wait_queue used in dma_wait_for_completion.
*/
DMA_TEI_CAPABLE = 0x02,
}; };
extern spinlock_t dma_spin_lock; extern spinlock_t dma_spin_lock;
...@@ -68,28 +71,31 @@ struct dma_ops { ...@@ -68,28 +71,31 @@ struct dma_ops {
int (*get_residue)(struct dma_channel *chan); int (*get_residue)(struct dma_channel *chan);
int (*xfer)(struct dma_channel *chan); int (*xfer)(struct dma_channel *chan);
void (*configure)(struct dma_channel *chan, unsigned long flags); int (*configure)(struct dma_channel *chan, unsigned long flags);
int (*extend)(struct dma_channel *chan, unsigned long op, void *param);
}; };
struct dma_channel { struct dma_channel {
char dev_id[16]; char dev_id[16]; /* unique name per DMAC of channel */
unsigned int chan; /* Physical channel number */ unsigned int chan; /* DMAC channel number */
unsigned int vchan; /* Virtual channel number */ unsigned int vchan; /* Virtual channel number */
unsigned int mode; unsigned int mode;
unsigned int count; unsigned int count;
unsigned long sar; unsigned long sar;
unsigned long dar; unsigned long dar;
const char **caps;
unsigned long flags; unsigned long flags;
atomic_t busy; atomic_t busy;
struct semaphore sem;
wait_queue_head_t wait_queue; wait_queue_head_t wait_queue;
struct sys_device dev; struct sys_device dev;
char *name; void *priv_data;
}; };
struct dma_info { struct dma_info {
...@@ -103,6 +109,12 @@ struct dma_info { ...@@ -103,6 +109,12 @@ struct dma_info {
struct dma_channel *channels; struct dma_channel *channels;
struct list_head list; struct list_head list;
int first_channel_nr;
};
struct dma_chan_caps {
int ch_num;
const char **caplist;
}; };
#define to_dma_channel(channel) container_of(channel, struct dma_channel, dev) #define to_dma_channel(channel) container_of(channel, struct dma_channel, dev)
...@@ -121,6 +133,8 @@ extern int dma_xfer(unsigned int chan, unsigned long from, ...@@ -121,6 +133,8 @@ extern int dma_xfer(unsigned int chan, unsigned long from,
#define dma_read_page(chan, from, to) \ #define dma_read_page(chan, from, to) \
dma_read(chan, from, to, PAGE_SIZE) dma_read(chan, from, to, PAGE_SIZE)
extern int request_dma_bycap(const char **dmac, const char **caps,
const char *dev_id);
extern int request_dma(unsigned int chan, const char *dev_id); extern int request_dma(unsigned int chan, const char *dev_id);
extern void free_dma(unsigned int chan); extern void free_dma(unsigned int chan);
extern int get_dma_residue(unsigned int chan); extern int get_dma_residue(unsigned int chan);
...@@ -131,6 +145,10 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags); ...@@ -131,6 +145,10 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags);
extern int register_dmac(struct dma_info *info); extern int register_dmac(struct dma_info *info);
extern void unregister_dmac(struct dma_info *info); extern void unregister_dmac(struct dma_info *info);
extern struct dma_info *get_dma_info_by_name(const char *dmac_name);
extern int dma_extend(unsigned int chan, unsigned long op, void *param);
extern int register_chan_caps(const char *dmac, struct dma_chan_caps *capslist);
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
/* arch/sh/drivers/dma/dma-sysfs.c */ /* arch/sh/drivers/dma/dma-sysfs.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment