aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/shdma.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-06-17 04:20:40 -0400
committerPaul Mundt <lethal@linux-sh.org>2011-06-21 04:55:57 -0400
commit5899a723b336da241b492583d7e55f1055f8f3b3 (patch)
tree3d75b8d88a99e277779325790903a76913a3e2d9 /drivers/dma/shdma.c
parent090b91805a97f58a7deff0f2b40aad1cc2f1b7e0 (diff)
dmaengine: shdma: add chcr_write/read function
CHCR register position is not same in all DMAC. This patch adds new "chcr_offset" to decide it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/dma/shdma.c')
-rw-r--r--drivers/dma/shdma.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index 41a21b322960..40900c1cee9a 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -78,6 +78,20 @@ static void dmaor_write(struct sh_dmae_device *shdev, u16 data)
78 __raw_writew(data, shdev->chan_reg + DMAOR / sizeof(u32)); 78 __raw_writew(data, shdev->chan_reg + DMAOR / sizeof(u32));
79} 79}
80 80
81static void chcr_write(struct sh_dmae_chan *sh_dc, u32 data)
82{
83 struct sh_dmae_device *shdev = to_sh_dev(sh_dc);
84
85 __raw_writel(data, sh_dc->base + shdev->chcr_offset / sizeof(u32));
86}
87
88static u32 chcr_read(struct sh_dmae_chan *sh_dc)
89{
90 struct sh_dmae_device *shdev = to_sh_dev(sh_dc);
91
92 return __raw_readl(sh_dc->base + shdev->chcr_offset / sizeof(u32));
93}
94
81/* 95/*
82 * Reset DMA controller 96 * Reset DMA controller
83 * 97 *
@@ -120,7 +134,7 @@ static int sh_dmae_rst(struct sh_dmae_device *shdev)
120 134
121static bool dmae_is_busy(struct sh_dmae_chan *sh_chan) 135static bool dmae_is_busy(struct sh_dmae_chan *sh_chan)
122{ 136{
123 u32 chcr = sh_dmae_readl(sh_chan, CHCR); 137 u32 chcr = chcr_read(sh_chan);
124 138
125 if ((chcr & (CHCR_DE | CHCR_TE)) == CHCR_DE) 139 if ((chcr & (CHCR_DE | CHCR_TE)) == CHCR_DE)
126 return true; /* working */ 140 return true; /* working */
@@ -167,18 +181,18 @@ static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs *hw)
167 181
168static void dmae_start(struct sh_dmae_chan *sh_chan) 182static void dmae_start(struct sh_dmae_chan *sh_chan)
169{ 183{
170 u32 chcr = sh_dmae_readl(sh_chan, CHCR); 184 u32 chcr = chcr_read(sh_chan);
171 185
172 chcr |= CHCR_DE | CHCR_IE; 186 chcr |= CHCR_DE | CHCR_IE;
173 sh_dmae_writel(sh_chan, chcr & ~CHCR_TE, CHCR); 187 chcr_write(sh_chan, chcr & ~CHCR_TE);
174} 188}
175 189
176static void dmae_halt(struct sh_dmae_chan *sh_chan) 190static void dmae_halt(struct sh_dmae_chan *sh_chan)
177{ 191{
178 u32 chcr = sh_dmae_readl(sh_chan, CHCR); 192 u32 chcr = chcr_read(sh_chan);
179 193
180 chcr &= ~(CHCR_DE | CHCR_TE | CHCR_IE); 194 chcr &= ~(CHCR_DE | CHCR_TE | CHCR_IE);
181 sh_dmae_writel(sh_chan, chcr, CHCR); 195 chcr_write(sh_chan, chcr);
182} 196}
183 197
184static void dmae_init(struct sh_dmae_chan *sh_chan) 198static void dmae_init(struct sh_dmae_chan *sh_chan)
@@ -190,7 +204,7 @@ static void dmae_init(struct sh_dmae_chan *sh_chan)
190 u32 chcr = DM_INC | SM_INC | 0x400 | log2size_to_chcr(sh_chan, 204 u32 chcr = DM_INC | SM_INC | 0x400 | log2size_to_chcr(sh_chan,
191 LOG2_DEFAULT_XFER_SIZE); 205 LOG2_DEFAULT_XFER_SIZE);
192 sh_chan->xmit_shift = calc_xmit_shift(sh_chan, chcr); 206 sh_chan->xmit_shift = calc_xmit_shift(sh_chan, chcr);
193 sh_dmae_writel(sh_chan, chcr, CHCR); 207 chcr_write(sh_chan, chcr);
194} 208}
195 209
196static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val) 210static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
@@ -200,7 +214,7 @@ static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
200 return -EBUSY; 214 return -EBUSY;
201 215
202 sh_chan->xmit_shift = calc_xmit_shift(sh_chan, val); 216 sh_chan->xmit_shift = calc_xmit_shift(sh_chan, val);
203 sh_dmae_writel(sh_chan, val, CHCR); 217 chcr_write(sh_chan, val);
204 218
205 return 0; 219 return 0;
206} 220}
@@ -840,7 +854,7 @@ static irqreturn_t sh_dmae_interrupt(int irq, void *data)
840 854
841 spin_lock(&sh_chan->desc_lock); 855 spin_lock(&sh_chan->desc_lock);
842 856
843 chcr = sh_dmae_readl(sh_chan, CHCR); 857 chcr = chcr_read(sh_chan);
844 858
845 if (chcr & CHCR_TE) { 859 if (chcr & CHCR_TE) {
846 /* DMA stop */ 860 /* DMA stop */
@@ -1138,6 +1152,11 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
1138 /* platform data */ 1152 /* platform data */
1139 shdev->pdata = pdata; 1153 shdev->pdata = pdata;
1140 1154
1155 if (pdata->chcr_offset)
1156 shdev->chcr_offset = pdata->chcr_offset;
1157 else
1158 shdev->chcr_offset = CHCR;
1159
1141 platform_set_drvdata(pdev, shdev); 1160 platform_set_drvdata(pdev, shdev);
1142 1161
1143 pm_runtime_enable(&pdev->dev); 1162 pm_runtime_enable(&pdev->dev);