Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge commit 'renesas-rcar-audmapp-for-v3.17' into for-linus

+113 -30
+29
Documentation/devicetree/bindings/dma/rcar-audmapp.txt
··· 1 + * R-Car Audio DMAC peri peri Device Tree bindings 2 + 3 + Required properties: 4 + - compatible: should be "renesas,rcar-audmapp" 5 + - #dma-cells: should be <1>, see "dmas" property below 6 + 7 + Example: 8 + audmapp: audio-dma-pp@0xec740000 { 9 + compatible = "renesas,rcar-audmapp"; 10 + #dma-cells = <1>; 11 + 12 + reg = <0 0xec740000 0 0x200>; 13 + }; 14 + 15 + 16 + * DMA client 17 + 18 + Required properties: 19 + - dmas: a list of <[DMA multiplexer phandle] [SRS/DRS value]> pairs, 20 + where SRS/DRS values are fixed handles, specified in the SoC 21 + manual as the value that would be written into the PDMACHCR. 22 + - dma-names: a list of DMA channel names, one per "dmas" entry 23 + 24 + Example: 25 + 26 + dmas = <&audmapp 0x2d00 27 + &audmapp 0x3700>; 28 + dma-names = "src0_ssiu0", 29 + "dvc0_ssiu0";
+84 -30
drivers/dma/sh/rcar-audmapp.c
··· 22 22 #include <linux/module.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/dmaengine.h> 25 + #include <linux/of_dma.h> 25 26 #include <linux/platform_data/dma-rcar-audmapp.h> 26 27 #include <linux/platform_device.h> 27 28 #include <linux/shdma-base.h> ··· 46 45 47 46 struct audmapp_chan { 48 47 struct shdma_chan shdma_chan; 49 - struct audmapp_slave_config *config; 50 48 void __iomem *base; 49 + dma_addr_t slave_addr; 50 + u32 chcr; 51 51 }; 52 52 53 53 struct audmapp_device { ··· 58 56 void __iomem *chan_reg; 59 57 }; 60 58 59 + struct audmapp_desc { 60 + struct shdma_desc shdma_desc; 61 + dma_addr_t src; 62 + dma_addr_t dst; 63 + }; 64 + 65 + #define to_shdma_chan(c) container_of(c, struct shdma_chan, dma_chan) 66 + 61 67 #define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan) 68 + #define to_desc(sdesc) container_of(sdesc, struct audmapp_desc, shdma_desc) 62 69 #define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device, \ 63 70 struct audmapp_device, shdma_dev.dma_dev) 64 71 ··· 101 90 } 102 91 103 92 static void audmapp_start_xfer(struct shdma_chan *schan, 104 - struct shdma_desc *sdecs) 93 + struct shdma_desc *sdesc) 105 94 { 106 95 struct audmapp_chan *auchan = to_chan(schan); 107 96 struct audmapp_device *audev = to_dev(auchan); 108 - struct audmapp_slave_config *cfg = auchan->config; 97 + struct audmapp_desc *desc = to_desc(sdesc); 109 98 struct device *dev = audev->dev; 110 - u32 chcr = cfg->chcr | PDMACHCR_DE; 99 + u32 chcr = auchan->chcr | PDMACHCR_DE; 111 100 112 - dev_dbg(dev, "src/dst/chcr = %pad/%pad/%x\n", 113 - &cfg->src, &cfg->dst, cfg->chcr); 101 + dev_dbg(dev, "src/dst/chcr = %pad/%pad/%08x\n", 102 + &desc->src, &desc->dst, chcr); 114 103 115 - audmapp_write(auchan, cfg->src, PDMASAR); 116 - audmapp_write(auchan, cfg->dst, PDMADAR); 104 + audmapp_write(auchan, desc->src, PDMASAR); 105 + audmapp_write(auchan, desc->dst, PDMADAR); 117 106 audmapp_write(auchan, chcr, PDMACHCR); 118 107 } 119 108 120 - static struct audmapp_slave_config * 121 - audmapp_find_slave(struct audmapp_chan *auchan, int slave_id) 109 + static void audmapp_get_config(struct audmapp_chan *auchan, int slave_id, 110 + u32 *chcr, dma_addr_t *dst) 122 111 { 123 112 struct audmapp_device *audev = to_dev(auchan); 124 113 struct audmapp_pdata *pdata = audev->pdata; 125 114 struct audmapp_slave_config *cfg; 126 115 int i; 127 116 117 + *chcr = 0; 118 + *dst = 0; 119 + 120 + if (!pdata) { /* DT */ 121 + *chcr = ((u32)slave_id) << 16; 122 + auchan->shdma_chan.slave_id = (slave_id) >> 8; 123 + return; 124 + } 125 + 126 + /* non-DT */ 127 + 128 128 if (slave_id >= AUDMAPP_SLAVE_NUMBER) 129 - return NULL; 129 + return; 130 130 131 131 for (i = 0, cfg = pdata->slave; i < pdata->slave_num; i++, cfg++) 132 - if (cfg->slave_id == slave_id) 133 - return cfg; 134 - 135 - return NULL; 132 + if (cfg->slave_id == slave_id) { 133 + *chcr = cfg->chcr; 134 + *dst = cfg->dst; 135 + break; 136 + } 136 137 } 137 138 138 139 static int audmapp_set_slave(struct shdma_chan *schan, int slave_id, 139 140 dma_addr_t slave_addr, bool try) 140 141 { 141 142 struct audmapp_chan *auchan = to_chan(schan); 142 - struct audmapp_slave_config *cfg = 143 - audmapp_find_slave(auchan, slave_id); 143 + u32 chcr; 144 + dma_addr_t dst; 144 145 145 - if (!cfg) 146 - return -ENODEV; 146 + audmapp_get_config(auchan, slave_id, &chcr, &dst); 147 + 147 148 if (try) 148 149 return 0; 149 150 150 - auchan->config = cfg; 151 + auchan->chcr = chcr; 152 + auchan->slave_addr = slave_addr ? : dst; 151 153 152 154 return 0; 153 155 } 154 156 155 157 static int audmapp_desc_setup(struct shdma_chan *schan, 156 - struct shdma_desc *sdecs, 158 + struct shdma_desc *sdesc, 157 159 dma_addr_t src, dma_addr_t dst, size_t *len) 158 160 { 159 - struct audmapp_chan *auchan = to_chan(schan); 160 - struct audmapp_slave_config *cfg = auchan->config; 161 - 162 - if (!cfg) 163 - return -ENODEV; 161 + struct audmapp_desc *desc = to_desc(sdesc); 164 162 165 163 if (*len > (size_t)AUDMAPP_LEN_MAX) 166 164 *len = (size_t)AUDMAPP_LEN_MAX; 165 + 166 + desc->src = src; 167 + desc->dst = dst; 167 168 168 169 return 0; 169 170 } ··· 187 164 188 165 static dma_addr_t audmapp_slave_addr(struct shdma_chan *schan) 189 166 { 190 - return 0; /* always fixed address */ 167 + struct audmapp_chan *auchan = to_chan(schan); 168 + 169 + return auchan->slave_addr; 191 170 } 192 171 193 172 static bool audmapp_channel_busy(struct shdma_chan *schan) ··· 208 183 209 184 static struct shdma_desc *audmapp_embedded_desc(void *buf, int i) 210 185 { 211 - return &((struct shdma_desc *)buf)[i]; 186 + return &((struct audmapp_desc *)buf)[i].shdma_desc; 212 187 } 213 188 214 189 static const struct shdma_ops audmapp_shdma_ops = { ··· 259 234 dma_dev->chancnt = 0; 260 235 } 261 236 237 + static struct dma_chan *audmapp_of_xlate(struct of_phandle_args *dma_spec, 238 + struct of_dma *ofdma) 239 + { 240 + dma_cap_mask_t mask; 241 + struct dma_chan *chan; 242 + u32 chcr = dma_spec->args[0]; 243 + 244 + if (dma_spec->args_count != 1) 245 + return NULL; 246 + 247 + dma_cap_zero(mask); 248 + dma_cap_set(DMA_SLAVE, mask); 249 + 250 + chan = dma_request_channel(mask, shdma_chan_filter, NULL); 251 + if (chan) 252 + to_shdma_chan(chan)->hw_req = chcr; 253 + 254 + return chan; 255 + } 256 + 262 257 static int audmapp_probe(struct platform_device *pdev) 263 258 { 264 259 struct audmapp_pdata *pdata = pdev->dev.platform_data; 260 + struct device_node *np = pdev->dev.of_node; 265 261 struct audmapp_device *audev; 266 262 struct shdma_dev *sdev; 267 263 struct dma_device *dma_dev; 268 264 struct resource *res; 269 265 int err, i; 270 266 271 - if (!pdata) 267 + if (np) 268 + of_dma_controller_register(np, audmapp_of_xlate, pdev); 269 + else if (!pdata) 272 270 return -ENODEV; 273 271 274 272 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 308 260 309 261 sdev = &audev->shdma_dev; 310 262 sdev->ops = &audmapp_shdma_ops; 311 - sdev->desc_size = sizeof(struct shdma_desc); 263 + sdev->desc_size = sizeof(struct audmapp_desc); 312 264 313 265 dma_dev = &sdev->dma_dev; 314 266 dma_dev->copy_align = LOG2_DEFAULT_XFER_SIZE; ··· 353 305 return 0; 354 306 } 355 307 308 + static const struct of_device_id audmapp_of_match[] = { 309 + { .compatible = "renesas,rcar-audmapp", }, 310 + {}, 311 + }; 312 + 356 313 static struct platform_driver audmapp_driver = { 357 314 .probe = audmapp_probe, 358 315 .remove = audmapp_remove, 359 316 .driver = { 360 317 .owner = THIS_MODULE, 361 318 .name = "rcar-audmapp-engine", 319 + .of_match_table = audmapp_of_match, 362 320 }, 363 321 }; 364 322 module_platform_driver(audmapp_driver);