Commit 5bac942d authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Paul Mundt

SH: constify multiple DMA related objects and references to them

Lists of DMA channels and slaves are not changed, make them constant. Besides,
SH7724 channel and slave configuration of both DMA controllers is identical,
remove the extra copy of the configuration data.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 6b6b18e6
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <cpu/dma-register.h> #include <cpu/dma-register.h>
#include <cpu/sh7722.h> #include <cpu/sh7722.h>
static struct sh_dmae_slave_config sh7722_dmae_slaves[] = { static const struct sh_dmae_slave_config sh7722_dmae_slaves[] = {
{ {
.slave_id = SHDMA_SLAVE_SCIF0_TX, .slave_id = SHDMA_SLAVE_SCIF0_TX,
.addr = 0xffe0000c, .addr = 0xffe0000c,
...@@ -78,7 +78,7 @@ static struct sh_dmae_slave_config sh7722_dmae_slaves[] = { ...@@ -78,7 +78,7 @@ static struct sh_dmae_slave_config sh7722_dmae_slaves[] = {
}, },
}; };
static struct sh_dmae_channel sh7722_dmae_channels[] = { static const struct sh_dmae_channel sh7722_dmae_channels[] = {
{ {
.offset = 0, .offset = 0,
.dmars = 0, .dmars = 0,
...@@ -106,7 +106,7 @@ static struct sh_dmae_channel sh7722_dmae_channels[] = { ...@@ -106,7 +106,7 @@ static struct sh_dmae_channel sh7722_dmae_channels[] = {
} }
}; };
static unsigned int ts_shift[] = TS_SHIFT; static const unsigned int ts_shift[] = TS_SHIFT;
static struct sh_dmae_pdata dma_platform_data = { static struct sh_dmae_pdata dma_platform_data = {
.slave = sh7722_dmae_slaves, .slave = sh7722_dmae_slaves,
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <cpu/sh7724.h> #include <cpu/sh7724.h>
/* DMA */ /* DMA */
static struct sh_dmae_channel sh7724_dmae0_channels[] = { static const struct sh_dmae_channel sh7724_dmae_channels[] = {
{ {
.offset = 0, .offset = 0,
.dmars = 0, .dmars = 0,
...@@ -59,51 +59,11 @@ static struct sh_dmae_channel sh7724_dmae0_channels[] = { ...@@ -59,51 +59,11 @@ static struct sh_dmae_channel sh7724_dmae0_channels[] = {
} }
}; };
static struct sh_dmae_channel sh7724_dmae1_channels[] = { static const unsigned int ts_shift[] = TS_SHIFT;
{
.offset = 0,
.dmars = 0,
.dmars_bit = 0,
}, {
.offset = 0x10,
.dmars = 0,
.dmars_bit = 8,
}, {
.offset = 0x20,
.dmars = 4,
.dmars_bit = 0,
}, {
.offset = 0x30,
.dmars = 4,
.dmars_bit = 8,
}, {
.offset = 0x50,
.dmars = 8,
.dmars_bit = 0,
}, {
.offset = 0x60,
.dmars = 8,
.dmars_bit = 8,
}
};
static unsigned int ts_shift[] = TS_SHIFT;
static struct sh_dmae_pdata dma0_platform_data = {
.channel = sh7724_dmae0_channels,
.channel_num = ARRAY_SIZE(sh7724_dmae0_channels),
.ts_low_shift = CHCR_TS_LOW_SHIFT,
.ts_low_mask = CHCR_TS_LOW_MASK,
.ts_high_shift = CHCR_TS_HIGH_SHIFT,
.ts_high_mask = CHCR_TS_HIGH_MASK,
.ts_shift = ts_shift,
.ts_shift_num = ARRAY_SIZE(ts_shift),
.dmaor_init = DMAOR_INIT,
};
static struct sh_dmae_pdata dma1_platform_data = { static struct sh_dmae_pdata dma_platform_data = {
.channel = sh7724_dmae1_channels, .channel = sh7724_dmae_channels,
.channel_num = ARRAY_SIZE(sh7724_dmae1_channels), .channel_num = ARRAY_SIZE(sh7724_dmae_channels),
.ts_low_shift = CHCR_TS_LOW_SHIFT, .ts_low_shift = CHCR_TS_LOW_SHIFT,
.ts_low_mask = CHCR_TS_LOW_MASK, .ts_low_mask = CHCR_TS_LOW_MASK,
.ts_high_shift = CHCR_TS_HIGH_SHIFT, .ts_high_shift = CHCR_TS_HIGH_SHIFT,
...@@ -187,7 +147,7 @@ static struct platform_device dma0_device = { ...@@ -187,7 +147,7 @@ static struct platform_device dma0_device = {
.resource = sh7724_dmae0_resources, .resource = sh7724_dmae0_resources,
.num_resources = ARRAY_SIZE(sh7724_dmae0_resources), .num_resources = ARRAY_SIZE(sh7724_dmae0_resources),
.dev = { .dev = {
.platform_data = &dma0_platform_data, .platform_data = &dma_platform_data,
}, },
.archdata = { .archdata = {
.hwblk_id = HWBLK_DMAC0, .hwblk_id = HWBLK_DMAC0,
...@@ -200,7 +160,7 @@ static struct platform_device dma1_device = { ...@@ -200,7 +160,7 @@ static struct platform_device dma1_device = {
.resource = sh7724_dmae1_resources, .resource = sh7724_dmae1_resources,
.num_resources = ARRAY_SIZE(sh7724_dmae1_resources), .num_resources = ARRAY_SIZE(sh7724_dmae1_resources),
.dev = { .dev = {
.platform_data = &dma1_platform_data, .platform_data = &dma_platform_data,
}, },
.archdata = { .archdata = {
.hwblk_id = HWBLK_DMAC1, .hwblk_id = HWBLK_DMAC1,
......
...@@ -233,7 +233,7 @@ static struct platform_device rtc_device = { ...@@ -233,7 +233,7 @@ static struct platform_device rtc_device = {
}; };
/* DMA */ /* DMA */
static struct sh_dmae_channel sh7780_dmae0_channels[] = { static const struct sh_dmae_channel sh7780_dmae0_channels[] = {
{ {
.offset = 0, .offset = 0,
.dmars = 0, .dmars = 0,
...@@ -261,7 +261,7 @@ static struct sh_dmae_channel sh7780_dmae0_channels[] = { ...@@ -261,7 +261,7 @@ static struct sh_dmae_channel sh7780_dmae0_channels[] = {
} }
}; };
static struct sh_dmae_channel sh7780_dmae1_channels[] = { static const struct sh_dmae_channel sh7780_dmae1_channels[] = {
{ {
.offset = 0, .offset = 0,
}, { }, {
...@@ -277,7 +277,7 @@ static struct sh_dmae_channel sh7780_dmae1_channels[] = { ...@@ -277,7 +277,7 @@ static struct sh_dmae_channel sh7780_dmae1_channels[] = {
} }
}; };
static unsigned int ts_shift[] = TS_SHIFT; static const unsigned int ts_shift[] = TS_SHIFT;
static struct sh_dmae_pdata dma0_platform_data = { static struct sh_dmae_pdata dma0_platform_data = {
.channel = sh7780_dmae0_channels, .channel = sh7780_dmae0_channels,
......
...@@ -275,7 +275,7 @@ static struct platform_device tmu5_device = { ...@@ -275,7 +275,7 @@ static struct platform_device tmu5_device = {
}; };
/* DMA */ /* DMA */
static struct sh_dmae_channel sh7785_dmae0_channels[] = { static const struct sh_dmae_channel sh7785_dmae0_channels[] = {
{ {
.offset = 0, .offset = 0,
.dmars = 0, .dmars = 0,
...@@ -303,7 +303,7 @@ static struct sh_dmae_channel sh7785_dmae0_channels[] = { ...@@ -303,7 +303,7 @@ static struct sh_dmae_channel sh7785_dmae0_channels[] = {
} }
}; };
static struct sh_dmae_channel sh7785_dmae1_channels[] = { static const struct sh_dmae_channel sh7785_dmae1_channels[] = {
{ {
.offset = 0, .offset = 0,
}, { }, {
...@@ -319,7 +319,7 @@ static struct sh_dmae_channel sh7785_dmae1_channels[] = { ...@@ -319,7 +319,7 @@ static struct sh_dmae_channel sh7785_dmae1_channels[] = {
} }
}; };
static unsigned int ts_shift[] = TS_SHIFT; static const unsigned int ts_shift[] = TS_SHIFT;
static struct sh_dmae_pdata dma0_platform_data = { static struct sh_dmae_pdata dma0_platform_data = {
.channel = sh7785_dmae0_channels, .channel = sh7785_dmae0_channels,
......
...@@ -445,7 +445,7 @@ static struct platform_device tmu11_device = { ...@@ -445,7 +445,7 @@ static struct platform_device tmu11_device = {
.num_resources = ARRAY_SIZE(tmu11_resources), .num_resources = ARRAY_SIZE(tmu11_resources),
}; };
static struct sh_dmae_channel dmac0_channels[] = { static const struct sh_dmae_channel dmac0_channels[] = {
{ {
.offset = 0, .offset = 0,
.dmars = 0, .dmars = 0,
...@@ -473,7 +473,7 @@ static struct sh_dmae_channel dmac0_channels[] = { ...@@ -473,7 +473,7 @@ static struct sh_dmae_channel dmac0_channels[] = {
} }
}; };
static unsigned int ts_shift[] = TS_SHIFT; static const unsigned int ts_shift[] = TS_SHIFT;
static struct sh_dmae_pdata dma0_platform_data = { static struct sh_dmae_pdata dma0_platform_data = {
.channel = dmac0_channels, .channel = dmac0_channels,
......
...@@ -188,7 +188,7 @@ static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val) ...@@ -188,7 +188,7 @@ static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val)
struct sh_dmae_device *shdev = container_of(sh_chan->common.device, struct sh_dmae_device *shdev = container_of(sh_chan->common.device,
struct sh_dmae_device, common); struct sh_dmae_device, common);
struct sh_dmae_pdata *pdata = shdev->pdata; struct sh_dmae_pdata *pdata = shdev->pdata;
struct sh_dmae_channel *chan_pdata = &pdata->channel[sh_chan->id]; const struct sh_dmae_channel *chan_pdata = &pdata->channel[sh_chan->id];
u16 __iomem *addr = shdev->dmars + chan_pdata->dmars / sizeof(u16); u16 __iomem *addr = shdev->dmars + chan_pdata->dmars / sizeof(u16);
int shift = chan_pdata->dmars_bit; int shift = chan_pdata->dmars_bit;
...@@ -264,7 +264,7 @@ static struct sh_desc *sh_dmae_get_desc(struct sh_dmae_chan *sh_chan) ...@@ -264,7 +264,7 @@ static struct sh_desc *sh_dmae_get_desc(struct sh_dmae_chan *sh_chan)
return NULL; return NULL;
} }
static struct sh_dmae_slave_config *sh_dmae_find_slave( static const struct sh_dmae_slave_config *sh_dmae_find_slave(
struct sh_dmae_chan *sh_chan, struct sh_dmae_slave *param) struct sh_dmae_chan *sh_chan, struct sh_dmae_slave *param)
{ {
struct dma_device *dma_dev = sh_chan->common.device; struct dma_device *dma_dev = sh_chan->common.device;
...@@ -296,7 +296,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) ...@@ -296,7 +296,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
* never runs concurrently with itself or free_chan_resources. * never runs concurrently with itself or free_chan_resources.
*/ */
if (param) { if (param) {
struct sh_dmae_slave_config *cfg; const struct sh_dmae_slave_config *cfg;
cfg = sh_dmae_find_slave(sh_chan, param); cfg = sh_dmae_find_slave(sh_chan, param);
if (!cfg) if (!cfg)
...@@ -557,12 +557,14 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg( ...@@ -557,12 +557,14 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg(
{ {
struct sh_dmae_slave *param; struct sh_dmae_slave *param;
struct sh_dmae_chan *sh_chan; struct sh_dmae_chan *sh_chan;
dma_addr_t slave_addr;
if (!chan) if (!chan)
return NULL; return NULL;
sh_chan = to_sh_chan(chan); sh_chan = to_sh_chan(chan);
param = chan->private; param = chan->private;
slave_addr = param->config->addr;
/* Someone calling slave DMA on a public channel? */ /* Someone calling slave DMA on a public channel? */
if (!param || !sg_len) { if (!param || !sg_len) {
...@@ -575,7 +577,7 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg( ...@@ -575,7 +577,7 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg(
* if (param != NULL), this is a successfully requested slave channel, * if (param != NULL), this is a successfully requested slave channel,
* therefore param->config != NULL too. * therefore param->config != NULL too.
*/ */
return sh_dmae_prep_sg(sh_chan, sgl, sg_len, &param->config->addr, return sh_dmae_prep_sg(sh_chan, sgl, sg_len, &slave_addr,
direction, flags); direction, flags);
} }
...@@ -856,7 +858,7 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id, ...@@ -856,7 +858,7 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id,
int irq, unsigned long flags) int irq, unsigned long flags)
{ {
int err; int err;
struct sh_dmae_channel *chan_pdata = &shdev->pdata->channel[id]; const struct sh_dmae_channel *chan_pdata = &shdev->pdata->channel[id];
struct platform_device *pdev = to_platform_device(shdev->common.dev); struct platform_device *pdev = to_platform_device(shdev->common.dev);
struct sh_dmae_chan *new_sh_chan; struct sh_dmae_chan *new_sh_chan;
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
struct sh_dmae_slave { struct sh_dmae_slave {
unsigned int slave_id; /* Set by the platform */ unsigned int slave_id; /* Set by the platform */
struct device *dma_dev; /* Set by the platform */ struct device *dma_dev; /* Set by the platform */
struct sh_dmae_slave_config *config; /* Set by the driver */ const struct sh_dmae_slave_config *config; /* Set by the driver */
}; };
struct sh_dmae_regs { struct sh_dmae_regs {
...@@ -36,6 +36,7 @@ struct sh_desc { ...@@ -36,6 +36,7 @@ struct sh_desc {
int chunks; int chunks;
int mark; int mark;
}; };
struct sh_dmae_slave_config { struct sh_dmae_slave_config {
unsigned int slave_id; unsigned int slave_id;
dma_addr_t addr; dma_addr_t addr;
...@@ -50,15 +51,15 @@ struct sh_dmae_channel { ...@@ -50,15 +51,15 @@ struct sh_dmae_channel {
}; };
struct sh_dmae_pdata { struct sh_dmae_pdata {
struct sh_dmae_slave_config *slave; const struct sh_dmae_slave_config *slave;
int slave_num; int slave_num;
struct sh_dmae_channel *channel; const struct sh_dmae_channel *channel;
int channel_num; int channel_num;
unsigned int ts_low_shift; unsigned int ts_low_shift;
unsigned int ts_low_mask; unsigned int ts_low_mask;
unsigned int ts_high_shift; unsigned int ts_high_shift;
unsigned int ts_high_mask; unsigned int ts_high_mask;
unsigned int *ts_shift; const unsigned int *ts_shift;
int ts_shift_num; int ts_shift_num;
u16 dmaor_init; u16 dmaor_init;
}; };
......
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