aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/sh/shdma-base.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-06-18 12:16:57 -0400
committerVinod Koul <vinod.koul@intel.com>2013-07-05 02:11:00 -0400
commit67eacc1583909d0588c8d5d80c16298c899a6382 (patch)
tree093794f972e21cf084efcb734667453db1c68926 /drivers/dma/sh/shdma-base.c
parentd0951a23383d09276f7976ed34d8f1cede629b48 (diff)
DMA: shdma: add DT support
This patch adds Device Tree support to the shdma driver. No special DT properties are used, only standard DMA DT bindings are implemented. Since shdma controllers reside on SoCs, their configuration is SoC-specific and shall be passed to the driver from the SoC platform data, using the auxdata procedure. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/sh/shdma-base.c')
-rw-r--r--drivers/dma/sh/shdma-base.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index 4acb85a10250..28ca36121631 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -175,7 +175,18 @@ static int shdma_setup_slave(struct shdma_chan *schan, int slave_id)
175{ 175{
176 struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device); 176 struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
177 const struct shdma_ops *ops = sdev->ops; 177 const struct shdma_ops *ops = sdev->ops;
178 int ret; 178 int ret, match;
179
180 if (schan->dev->of_node) {
181 match = schan->hw_req;
182 ret = ops->set_slave(schan, match, true);
183 if (ret < 0)
184 return ret;
185
186 slave_id = schan->slave_id;
187 } else {
188 match = slave_id;
189 }
179 190
180 if (slave_id < 0 || slave_id >= slave_num) 191 if (slave_id < 0 || slave_id >= slave_num)
181 return -EINVAL; 192 return -EINVAL;
@@ -183,7 +194,7 @@ static int shdma_setup_slave(struct shdma_chan *schan, int slave_id)
183 if (test_and_set_bit(slave_id, shdma_slave_used)) 194 if (test_and_set_bit(slave_id, shdma_slave_used))
184 return -EBUSY; 195 return -EBUSY;
185 196
186 ret = ops->set_slave(schan, slave_id, false); 197 ret = ops->set_slave(schan, match, false);
187 if (ret < 0) { 198 if (ret < 0) {
188 clear_bit(slave_id, shdma_slave_used); 199 clear_bit(slave_id, shdma_slave_used);
189 return ret; 200 return ret;
@@ -206,23 +217,26 @@ static int shdma_setup_slave(struct shdma_chan *schan, int slave_id)
206 * services would have to provide their own filters, which first would check 217 * services would have to provide their own filters, which first would check
207 * the device driver, similar to how other DMAC drivers, e.g., sa11x0-dma.c, do 218 * the device driver, similar to how other DMAC drivers, e.g., sa11x0-dma.c, do
208 * this, and only then, in case of a match, call this common filter. 219 * this, and only then, in case of a match, call this common filter.
220 * NOTE 2: This filter function is also used in the DT case by shdma_of_xlate().
221 * In that case the MID-RID value is used for slave channel filtering and is
222 * passed to this function in the "arg" parameter.
209 */ 223 */
210bool shdma_chan_filter(struct dma_chan *chan, void *arg) 224bool shdma_chan_filter(struct dma_chan *chan, void *arg)
211{ 225{
212 struct shdma_chan *schan = to_shdma_chan(chan); 226 struct shdma_chan *schan = to_shdma_chan(chan);
213 struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device); 227 struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
214 const struct shdma_ops *ops = sdev->ops; 228 const struct shdma_ops *ops = sdev->ops;
215 int slave_id = (int)arg; 229 int match = (int)arg;
216 int ret; 230 int ret;
217 231
218 if (slave_id < 0) 232 if (match < 0)
219 /* No slave requested - arbitrary channel */ 233 /* No slave requested - arbitrary channel */
220 return true; 234 return true;
221 235
222 if (slave_id >= slave_num) 236 if (!schan->dev->of_node && match >= slave_num)
223 return false; 237 return false;
224 238
225 ret = ops->set_slave(schan, slave_id, true); 239 ret = ops->set_slave(schan, match, true);
226 if (ret < 0) 240 if (ret < 0)
227 return false; 241 return false;
228 242