Ola Lilja | e069038 | 2012-06-12 08:50:08 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) ST-Ericsson SA 2012 |
| 3 | * |
| 4 | * Author: Ola Lilja (ola.o.lilja@stericsson.com) |
| 5 | * for ST-Ericsson. |
| 6 | * |
| 7 | * License terms: |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as published |
| 11 | * by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <asm/mach-types.h> |
| 15 | |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/io.h> |
| 18 | #include <linux/spi/spi.h> |
| 19 | |
| 20 | #include <sound/soc.h> |
| 21 | #include <sound/initval.h> |
| 22 | |
| 23 | #include "ux500_pcm.h" |
| 24 | #include "ux500_msp_dai.h" |
| 25 | |
| 26 | #include <mop500_ab8500.h> |
| 27 | |
| 28 | /* Define the whole MOP500 soundcard, linking platform to the codec-drivers */ |
| 29 | struct snd_soc_dai_link mop500_dai_links[] = { |
| 30 | { |
| 31 | .name = "ab8500_0", |
| 32 | .stream_name = "ab8500_0", |
| 33 | .cpu_dai_name = "ux500-msp-i2s.1", |
| 34 | .codec_dai_name = "ab8500-codec-dai.0", |
| 35 | .platform_name = "ux500-pcm.0", |
| 36 | .codec_name = "ab8500-codec.0", |
| 37 | .init = mop500_ab8500_machine_init, |
| 38 | .ops = mop500_ab8500_ops, |
| 39 | }, |
| 40 | { |
| 41 | .name = "ab8500_1", |
| 42 | .stream_name = "ab8500_1", |
| 43 | .cpu_dai_name = "ux500-msp-i2s.3", |
| 44 | .codec_dai_name = "ab8500-codec-dai.1", |
| 45 | .platform_name = "ux500-pcm.0", |
| 46 | .codec_name = "ab8500-codec.0", |
| 47 | .init = NULL, |
| 48 | .ops = mop500_ab8500_ops, |
| 49 | }, |
| 50 | }; |
| 51 | |
| 52 | static struct snd_soc_card mop500_card = { |
| 53 | .name = "MOP500-card", |
| 54 | .probe = NULL, |
| 55 | .dai_link = mop500_dai_links, |
| 56 | .num_links = ARRAY_SIZE(mop500_dai_links), |
| 57 | }; |
| 58 | |
| 59 | static int __devinit mop500_probe(struct platform_device *pdev) |
| 60 | { |
| 61 | int ret; |
| 62 | |
| 63 | pr_debug("%s: Enter.\n", __func__); |
| 64 | |
| 65 | dev_dbg(&pdev->dev, "%s: Enter.\n", __func__); |
| 66 | |
| 67 | mop500_card.dev = &pdev->dev; |
| 68 | |
| 69 | dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n", |
| 70 | __func__, mop500_card.name); |
| 71 | platform_set_drvdata(pdev, &mop500_card); |
| 72 | |
| 73 | snd_soc_card_set_drvdata(&mop500_card, NULL); |
| 74 | |
| 75 | dev_dbg(&pdev->dev, "%s: Card %s: num_links = %d\n", |
| 76 | __func__, mop500_card.name, mop500_card.num_links); |
| 77 | dev_dbg(&pdev->dev, "%s: Card %s: DAI-link 0: name = %s\n", |
| 78 | __func__, mop500_card.name, mop500_card.dai_link[0].name); |
| 79 | dev_dbg(&pdev->dev, "%s: Card %s: DAI-link 0: stream_name = %s\n", |
| 80 | __func__, mop500_card.name, |
| 81 | mop500_card.dai_link[0].stream_name); |
| 82 | |
| 83 | ret = snd_soc_register_card(&mop500_card); |
| 84 | if (ret) |
| 85 | dev_err(&pdev->dev, |
| 86 | "Error: snd_soc_register_card failed (%d)!\n", |
| 87 | ret); |
| 88 | |
| 89 | return ret; |
| 90 | } |
| 91 | |
| 92 | static int __devexit mop500_remove(struct platform_device *pdev) |
| 93 | { |
| 94 | struct snd_soc_card *mop500_card = platform_get_drvdata(pdev); |
| 95 | |
| 96 | pr_debug("%s: Enter.\n", __func__); |
| 97 | |
| 98 | snd_soc_unregister_card(mop500_card); |
| 99 | mop500_ab8500_remove(mop500_card); |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | static struct platform_driver snd_soc_mop500_driver = { |
| 105 | .driver = { |
| 106 | .owner = THIS_MODULE, |
| 107 | .name = "snd-soc-mop500", |
| 108 | }, |
| 109 | .probe = mop500_probe, |
| 110 | .remove = __devexit_p(mop500_remove), |
| 111 | }; |
| 112 | |
| 113 | module_platform_driver(snd_soc_mop500_driver); |