9 #include <linux/module.h>
10 #include <linux/slab.h>
11 #include <linux/pci.h>
20 #include "../soundbus.h"
30 " no layout-id property is present");
39 static int alloc_dbdma_descriptor_ring(
struct i2sbus_dev *i2sdev,
44 r->
size = (numcmds + 3) *
sizeof(
struct dbdma_cmd);
49 &macio_get_pci_dev(i2sdev->
macio)->dev,
64 static void free_dbdma_descriptor_ring(
struct i2sbus_dev *i2sdev,
67 if (!r->
space)
return;
73 static void i2sbus_release_dev(
struct device *
dev)
81 if (i2sdev->out.dbdma)
iounmap(i2sdev->out.dbdma);
86 free_dbdma_descriptor_ring(i2sdev, &i2sdev->out.dbdma_ring);
87 free_dbdma_descriptor_ring(i2sdev, &i2sdev->
in.dbdma_ring);
135 if (layout != 76 && layout != 36)
148 res->
start += reg[index * 2];
149 res->
end = res->
start + reg[index * 2 + 1] - 1;
156 static int i2sbus_add_dev(
struct macio_dev *macio,
163 int i, layout = 0, rlen, ok =
force;
164 static const char *rnames[] = {
"i2sbus: %s (control)",
195 "sound-layout-%d", layout);
203 if (
id && (*
id == 22 || *
id == 14 || *
id == 35)) {
205 "aoa-device-id-%d", *
id);
224 dev->
sound.ofdev.archdata.dma_mask = macio->ofdev.archdata.dma_mask;
225 dev->
sound.ofdev.dev.of_node = np;
226 dev->
sound.ofdev.dev.dma_mask = &dev->
sound.ofdev.archdata.dma_mask;
227 dev->
sound.ofdev.dev.parent = &macio->ofdev.dev;
228 dev->
sound.ofdev.dev.release = i2sbus_release_dev;
231 dev->
sound.pcmid = -1;
235 INIT_LIST_HEAD(&dev->
sound.codec_list);
240 rnames[i], np->
name);
257 if (i2sbus_get_and_fixup_rsrc(np,i,layout,&dev->
resources[i]))
274 rlen = resource_size(r);
280 rlen = resource_size(r);
281 if (rlen <
sizeof(
struct dbdma_regs))
286 rlen = resource_size(r);
287 if (rlen <
sizeof(
struct dbdma_regs))
291 if (!dev->
intfregs || !dev->out.dbdma || !dev->
in.dbdma)
294 if (alloc_dbdma_descriptor_ring(dev, &dev->out.dbdma_ring,
297 if (alloc_dbdma_descriptor_ring(dev, &dev->
in.dbdma_ring,
321 free_dbdma_descriptor_ring(dev, &dev->out.dbdma_ring);
322 free_dbdma_descriptor_ring(dev, &dev->
in.dbdma_ring);
324 if (dev->out.dbdma)
iounmap(dev->out.dbdma);
351 got += i2sbus_add_dev(dev, control, np);
366 static int i2sbus_remove(
struct macio_dev* dev)
387 if (i2sdev->
sound.pcm) {
389 snd_pcm_suspend_all(i2sdev->
sound.pcm);
395 if (cii->
codec->suspend)
396 err = cii->
codec->suspend(cii, state);
408 static int i2sbus_resume(
struct macio_dev* dev)
422 if (cii->
codec->resume)
423 err = cii->
codec->resume(cii);
433 static int i2sbus_shutdown(
struct macio_dev* dev)
438 static struct macio_driver i2sbus_drv = {
440 .name =
"soundbus-i2s",
442 .of_match_table = i2sbus_match,
444 .probe = i2sbus_probe,
445 .remove = i2sbus_remove,
447 .suspend = i2sbus_suspend,
448 .resume = i2sbus_resume,
450 .shutdown = i2sbus_shutdown,
453 static int __init soundbus_i2sbus_init(
void)
458 static void __exit soundbus_i2sbus_exit(
void)