Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149269
b: refs/heads/master
c: 97c1b14
h: refs/heads/master
i:
  149267: d27ed2b
v: v3
  • Loading branch information
Ben Dooks authored and Ben Dooks committed May 1, 2009
1 parent 6050af0 commit 92766ea
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 90 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: 20934cdbaae9c26a31d7f593c6a747c687ae79a1
refs/heads/master: 97c1b145231730e62dd71921ec653315a1da3aad
8 changes: 2 additions & 6 deletions trunk/arch/arm/mach-s3c2410/include/mach/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ enum dma_ch {

/* we have 4 dma channels */
#ifndef CONFIG_CPU_S3C2443
#define S3C2410_DMA_CHANNELS (4)
#define S3C_DMA_CHANNELS (4)
#else
#define S3C2410_DMA_CHANNELS (6)
#define S3C_DMA_CHANNELS (6)
#endif

/* types */
Expand Down Expand Up @@ -192,10 +192,6 @@ struct s3c2410_dma_chan {
struct sys_device dev;
};

/* the currently allocated channel information */
extern struct s3c2410_dma_chan s3c2410_chans[];

/* note, we don't really use dma_device_t at the moment */
typedef unsigned long dma_device_t;

#endif /* __ASM_ARCH_DMA_H */
7 changes: 7 additions & 0 deletions trunk/arch/arm/plat-s3c/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ config S3C_GPIO_CFG_S3C64XX
Internal configuration to enable S3C64XX style GPIO configuration
functions.

# DMA

config S3C_DMA
bool
help
Internal configuration for S3C DMA core

# device definitions to compile in

config S3C_DEV_HSMMC
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/arm/plat-s3c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ obj-y += pwm-clock.o
obj-y += gpio.o
obj-y += gpio-config.o

# DMA support

obj-$(CONFIG_S3C_DMA) += dma.o

# PM support

obj-$(CONFIG_PM) += pm.o
Expand Down
86 changes: 86 additions & 0 deletions trunk/arch/arm/plat-s3c/dma.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* linux/arch/arm/plat-s3c/dma.c
*
* Copyright (c) 2003-2005,2006,2009 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* http://armlinux.simtec.co.uk/
*
* S3C DMA core
*
* 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.
*/

struct s3c2410_dma_buf;

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>

#include <mach/dma.h>
#include <mach/irqs.h>

#include <plat/dma-plat.h>

/* dma channel state information */
struct s3c2410_dma_chan s3c2410_chans[S3C_DMA_CHANNELS];
struct s3c2410_dma_chan *s3c_dma_chan_map[DMACH_MAX];

/* s3c_dma_lookup_channel
*
* change the dma channel number given into a real dma channel id
*/

struct s3c2410_dma_chan *s3c_dma_lookup_channel(unsigned int channel)
{
if (channel & DMACH_LOW_LEVEL)
return &s3c2410_chans[channel & ~DMACH_LOW_LEVEL];
else
return s3c_dma_chan_map[channel];
}

/* do we need to protect the settings of the fields from
* irq?
*/

int s3c2410_dma_set_opfn(unsigned int channel, s3c2410_dma_opfn_t rtn)
{
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);

if (chan == NULL)
return -EINVAL;

pr_debug("%s: chan=%p, op rtn=%p\n", __func__, chan, rtn);

chan->op_fn = rtn;

return 0;
}
EXPORT_SYMBOL(s3c2410_dma_set_opfn);

int s3c2410_dma_set_buffdone_fn(unsigned int channel, s3c2410_dma_cbfn_t rtn)
{
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);

if (chan == NULL)
return -EINVAL;

pr_debug("%s: chan=%p, callback rtn=%p\n", __func__, chan, rtn);

chan->callback_fn = rtn;

return 0;
}
EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn);

int s3c2410_dma_setflags(unsigned int channel, unsigned int flags)
{
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);

if (chan == NULL)
return -EINVAL;

chan->flags = flags;
return 0;
}
EXPORT_SYMBOL(s3c2410_dma_setflags);
22 changes: 22 additions & 0 deletions trunk/arch/arm/plat-s3c/include/plat/dma-core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* arch/arm/plat-s3c/include/plat/dma.h
*
* Copyright 2008 Openmoko, Inc.
* Copyright 2008 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
* http://armlinux.simtec.co.uk/
*
* Samsung S3C DMA core support
*
* 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.
*/

extern struct s3c2410_dma_chan *s3c_dma_lookup_channel(unsigned int channel);

extern struct s3c2410_dma_chan *s3c_dma_chan_map[];

/* the currently allocated channel information */
extern struct s3c2410_dma_chan s3c2410_chans[];


1 change: 1 addition & 0 deletions trunk/arch/arm/plat-s3c24xx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ config PM_SIMTEC
config S3C2410_DMA
bool "S3C2410 DMA support"
depends on ARCH_S3C2410
select S3C_DMA
help
S3C2410 DMA support. This is needed for drivers like sound which
use the S3C2410's DMA system to move data to and from the
Expand Down
87 changes: 8 additions & 79 deletions trunk/arch/arm/plat-s3c24xx/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ static int dma_channels;

static struct s3c24xx_dma_selection dma_sel;

/* dma channel state information */
struct s3c2410_dma_chan s3c2410_chans[S3C2410_DMA_CHANNELS];

/* debugging functions */

Expand Down Expand Up @@ -135,21 +133,6 @@ dmadbg_showregs(const char *fname, int line, struct s3c2410_dma_chan *chan)
#define dbg_showchan(chan) do { } while(0)
#endif /* CONFIG_S3C2410_DMA_DEBUG */

static struct s3c2410_dma_chan *dma_chan_map[DMACH_MAX];

/* lookup_dma_channel
*
* change the dma channel number given into a real dma channel id
*/

static struct s3c2410_dma_chan *lookup_dma_channel(unsigned int channel)
{
if (channel & DMACH_LOW_LEVEL)
return &s3c2410_chans[channel & ~DMACH_LOW_LEVEL];
else
return dma_chan_map[channel];
}

/* s3c2410_dma_stats_timeout
*
* Update DMA stats from timeout info
Expand Down Expand Up @@ -214,8 +197,6 @@ s3c2410_dma_waitforload(struct s3c2410_dma_chan *chan, int line)
return 0;
}



/* s3c2410_dma_loadbuffer
*
* load a buffer, and update the channel state
Expand Down Expand Up @@ -453,7 +434,7 @@ s3c2410_dma_canload(struct s3c2410_dma_chan *chan)
int s3c2410_dma_enqueue(unsigned int channel, void *id,
dma_addr_t data, int size)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
struct s3c2410_dma_buf *buf;
unsigned long flags;

Expand Down Expand Up @@ -804,7 +785,7 @@ EXPORT_SYMBOL(s3c2410_dma_request);

int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
unsigned long flags;

if (chan == NULL)
Expand Down Expand Up @@ -836,7 +817,7 @@ int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client)
chan->irq_claimed = 0;

if (!(channel & DMACH_LOW_LEVEL))
dma_chan_map[channel] = NULL;
s3c_dma_chan_map[channel] = NULL;

local_irq_restore(flags);

Expand Down Expand Up @@ -995,7 +976,7 @@ static int s3c2410_dma_started(struct s3c2410_dma_chan *chan)
int
s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);

if (chan == NULL)
return -EINVAL;
Expand Down Expand Up @@ -1043,7 +1024,7 @@ EXPORT_SYMBOL(s3c2410_dma_ctrl);
int s3c2410_dma_config(unsigned int channel,
int xferunit)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
unsigned int dcon;

pr_debug("%s: chan=%d, xfer_unit=%d, dcon=%08x\n",
Expand Down Expand Up @@ -1112,58 +1093,6 @@ int s3c2410_dma_config(unsigned int channel,

EXPORT_SYMBOL(s3c2410_dma_config);

int s3c2410_dma_setflags(unsigned int channel, unsigned int flags)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);

if (chan == NULL)
return -EINVAL;

pr_debug("%s: chan=%p, flags=%08x\n", __func__, chan, flags);

chan->flags = flags;

return 0;
}

EXPORT_SYMBOL(s3c2410_dma_setflags);


/* do we need to protect the settings of the fields from
* irq?
*/

int s3c2410_dma_set_opfn(unsigned int channel, s3c2410_dma_opfn_t rtn)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);

if (chan == NULL)
return -EINVAL;

pr_debug("%s: chan=%p, op rtn=%p\n", __func__, chan, rtn);

chan->op_fn = rtn;

return 0;
}

EXPORT_SYMBOL(s3c2410_dma_set_opfn);

int s3c2410_dma_set_buffdone_fn(unsigned int channel, s3c2410_dma_cbfn_t rtn)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);

if (chan == NULL)
return -EINVAL;

pr_debug("%s: chan=%p, callback rtn=%p\n", __func__, chan, rtn);

chan->callback_fn = rtn;

return 0;
}

EXPORT_SYMBOL(s3c2410_dma_set_buffdone_fn);

/* s3c2410_dma_devconfig
*
Expand All @@ -1179,7 +1108,7 @@ int s3c2410_dma_devconfig(int channel,
enum s3c2410_dmasrc source,
unsigned long devaddr)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
unsigned int hwcfg;

if (chan == NULL)
Expand Down Expand Up @@ -1250,7 +1179,7 @@ EXPORT_SYMBOL(s3c2410_dma_devconfig);

int s3c2410_dma_getposition(unsigned int channel, dma_addr_t *src, dma_addr_t *dst)
{
struct s3c2410_dma_chan *chan = lookup_dma_channel(channel);
struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);

if (chan == NULL)
return -EINVAL;
Expand Down Expand Up @@ -1508,7 +1437,7 @@ static struct s3c2410_dma_chan *s3c2410_dma_map_channel(int channel)
dmach = &s3c2410_chans[ch];
dmach->map = ch_map;
dmach->req_ch = channel;
dma_chan_map[channel] = dmach;
s3c_dma_chan_map[channel] = dmach;

/* select the channel */

Expand Down
10 changes: 6 additions & 4 deletions trunk/arch/arm/plat-s3c24xx/include/plat/dma-plat.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
* published by the Free Software Foundation.
*/

#include <plat/dma-core.h>

extern struct sysdev_class dma_sysclass;
extern struct s3c2410_dma_chan s3c2410_chans[S3C2410_DMA_CHANNELS];
extern struct s3c2410_dma_chan s3c2410_chans[S3C_DMA_CHANNELS];

#define DMA_CH_VALID (1<<31)
#define DMA_CH_NEVER (1<<30)
Expand All @@ -31,8 +33,8 @@ struct s3c24xx_dma_map {
const char *name;
struct s3c24xx_dma_addr hw_addr;

unsigned long channels[S3C2410_DMA_CHANNELS];
unsigned long channels_rx[S3C2410_DMA_CHANNELS];
unsigned long channels[S3C_DMA_CHANNELS];
unsigned long channels_rx[S3C_DMA_CHANNELS];
};

struct s3c24xx_dma_selection {
Expand All @@ -58,7 +60,7 @@ extern int s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel);
*/

struct s3c24xx_dma_order_ch {
unsigned int list[S3C2410_DMA_CHANNELS]; /* list of channels */
unsigned int list[S3C_DMA_CHANNELS]; /* list of channels */
unsigned int flags; /* flags */
};

Expand Down

0 comments on commit 92766ea

Please sign in to comment.