aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2014-02-17 08:32:07 -0500
committerMark Brown <broonie@linaro.org>2014-02-17 20:38:35 -0500
commitc2f8783fa2d053a61059f6b784c917129fb3064b (patch)
tree1bb8dfd4cbad35fb3c01dc8b9bc23672ad6a159e
parent790aff62291eade029755713fb41c1143d4ddbc7 (diff)
ASoC: Intel: Add common SST driver loader on ACPI systems
Most of the SST devices will be exposed as ACPI devices. It makes sense to avoid duplication of the driver enumeration logic and concentrate the functionality into a single ACPI SST enumeration file. Idea of this loader is to parse data we get from ACPI and to be able to load needed other SST drivers and ASoC machine driver runtime based on single ACPI ID what BIOS gives to us. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/intel/sst-acpi.c212
1 files changed, 212 insertions, 0 deletions
diff --git a/sound/soc/intel/sst-acpi.c b/sound/soc/intel/sst-acpi.c
new file mode 100644
index 000000000000..aba73ca8a923
--- /dev/null
+++ b/sound/soc/intel/sst-acpi.c
@@ -0,0 +1,212 @@
1/*
2 * Intel SST loader on ACPI systems
3 *
4 * Copyright (C) 2013, Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/acpi.h>
18#include <linux/device.h>
19#include <linux/module.h>
20#include <linux/platform_device.h>
21
22#include "sst-dsp.h"
23
24#define SST_LPT_DSP_DMA_ADDR_OFFSET 0x0F0000
25#define SST_WPT_DSP_DMA_ADDR_OFFSET 0x0FE000
26#define SST_LPT_DSP_DMA_SIZE (1024 - 1)
27
28/* Descriptor for setting up SST platform data */
29struct sst_acpi_desc {
30 const char *drv_name;
31 /* Platform resource indexes. Must set to -1 if not used */
32 int resindex_lpe_base;
33 int resindex_pcicfg_base;
34 int resindex_fw_base;
35 int irqindex_host_ipc;
36 int resindex_dma_base;
37 /* Unique number identifying the SST core on platform */
38 int sst_id;
39 /* firmware file name */
40 const char *fw_filename;
41 /* DMA only valid when resindex_dma_base != -1*/
42 int dma_engine;
43 int dma_size;
44};
45
46/* Descriptor for SST ASoC machine driver */
47struct sst_acpi_mach {
48 const char *drv_name;
49 struct sst_acpi_desc *res_desc;
50};
51
52struct sst_acpi_priv {
53 struct platform_device *pdev_mach;
54 struct platform_device *pdev_pcm;
55 struct sst_pdata sst_pdata;
56 struct sst_acpi_desc *desc;
57};
58
59static int sst_acpi_probe(struct platform_device *pdev)
60{
61 const struct acpi_device_id *id;
62 struct device *dev = &pdev->dev;
63 struct sst_acpi_priv *sst_acpi;
64 struct sst_pdata *sst_pdata;
65 struct sst_acpi_mach *mach;
66 struct sst_acpi_desc *desc;
67 struct resource *mmio;
68 int ret = 0;
69
70 sst_acpi = devm_kzalloc(dev, sizeof(*sst_acpi), GFP_KERNEL);
71 if (sst_acpi == NULL)
72 return -ENOMEM;
73
74 id = acpi_match_device(dev->driver->acpi_match_table, dev);
75 if (!id)
76 return -ENODEV;
77
78 mach = (struct sst_acpi_mach *)id->driver_data;
79 desc = mach->res_desc;
80 sst_pdata = &sst_acpi->sst_pdata;
81 sst_pdata->id = desc->sst_id;
82 sst_pdata->fw_filename = desc->fw_filename;
83 sst_acpi->desc = desc;
84
85 if (desc->resindex_dma_base >= 0) {
86 sst_pdata->dma_engine = desc->dma_engine;
87 sst_pdata->dma_base = desc->resindex_dma_base;
88 sst_pdata->dma_size = desc->dma_size;
89 }
90
91 if (desc->irqindex_host_ipc >= 0)
92 sst_pdata->irq = platform_get_irq(pdev, desc->irqindex_host_ipc);
93
94 if (desc->resindex_lpe_base >= 0) {
95 mmio = platform_get_resource(pdev, IORESOURCE_MEM,
96 desc->resindex_lpe_base);
97 if (mmio) {
98 sst_pdata->lpe_base = mmio->start;
99 sst_pdata->lpe_size = resource_size(mmio);
100 }
101 }
102
103 if (desc->resindex_pcicfg_base >= 0) {
104 mmio = platform_get_resource(pdev, IORESOURCE_MEM,
105 desc->resindex_pcicfg_base);
106 if (mmio) {
107 sst_pdata->pcicfg_base = mmio->start;
108 sst_pdata->pcicfg_size = resource_size(mmio);
109 }
110 }
111
112 if (desc->resindex_fw_base >= 0) {
113 mmio = platform_get_resource(pdev, IORESOURCE_MEM,
114 desc->resindex_fw_base);
115 if (mmio) {
116 sst_pdata->fw_base = mmio->start;
117 sst_pdata->fw_size = resource_size(mmio);
118 }
119 }
120
121 /* register PCM and DAI driver */
122 sst_acpi->pdev_pcm =
123 platform_device_register_data(dev, desc->drv_name, -1,
124 sst_pdata, sizeof(*sst_pdata));
125 if (IS_ERR(sst_acpi->pdev_pcm))
126 return PTR_ERR(sst_acpi->pdev_pcm);
127
128 /* register machine driver */
129 platform_set_drvdata(pdev, sst_acpi);
130
131 sst_acpi->pdev_mach =
132 platform_device_register_data(dev, mach->drv_name, -1,
133 sst_pdata, sizeof(*sst_pdata));
134 if (IS_ERR(sst_acpi->pdev_mach)) {
135 ret = PTR_ERR(sst_acpi->pdev_mach);
136 goto sst_err;
137 }
138
139 return ret;
140
141sst_err:
142 platform_device_unregister(sst_acpi->pdev_pcm);
143 return ret;
144}
145
146static int sst_acpi_remove(struct platform_device *pdev)
147{
148 struct sst_acpi_priv *sst_acpi = platform_get_drvdata(pdev);
149
150 platform_device_unregister(sst_acpi->pdev_mach);
151 platform_device_unregister(sst_acpi->pdev_pcm);
152
153 return 0;
154}
155
156static struct sst_acpi_desc sst_acpi_haswell_desc = {
157 .drv_name = "haswell-pcm-audio",
158 .resindex_lpe_base = 0,
159 .resindex_pcicfg_base = 1,
160 .resindex_fw_base = -1,
161 .irqindex_host_ipc = 0,
162 .sst_id = SST_DEV_ID_LYNX_POINT,
163 .fw_filename = "intel/IntcSST1.bin",
164 .dma_engine = SST_DMA_TYPE_DW,
165 .resindex_dma_base = SST_LPT_DSP_DMA_ADDR_OFFSET,
166 .dma_size = SST_LPT_DSP_DMA_SIZE,
167};
168
169static struct sst_acpi_desc sst_acpi_broadwell_desc = {
170 .drv_name = "haswell-pcm-audio",
171 .resindex_lpe_base = 0,
172 .resindex_pcicfg_base = 1,
173 .resindex_fw_base = -1,
174 .irqindex_host_ipc = 0,
175 .sst_id = SST_DEV_ID_WILDCAT_POINT,
176 .fw_filename = "intel/IntcSST2.bin",
177 .dma_engine = SST_DMA_TYPE_DW,
178 .resindex_dma_base = SST_WPT_DSP_DMA_ADDR_OFFSET,
179 .dma_size = SST_LPT_DSP_DMA_SIZE,
180};
181
182static struct sst_acpi_mach haswell_mach = {
183 .drv_name = "haswell-audio",
184 .res_desc = &sst_acpi_haswell_desc,
185};
186
187static struct sst_acpi_mach broadwell_mach = {
188 .drv_name = "broadwell-audio",
189 .res_desc = &sst_acpi_broadwell_desc,
190};
191
192static struct acpi_device_id sst_acpi_match[] = {
193 { "INT33C8", (unsigned long)&haswell_mach },
194 { "INT3438", (unsigned long)&broadwell_mach },
195 { }
196};
197MODULE_DEVICE_TABLE(acpi, sst_acpi_match);
198
199static struct platform_driver sst_acpi_driver = {
200 .probe = sst_acpi_probe,
201 .remove = sst_acpi_remove,
202 .driver = {
203 .name = "sst-acpi",
204 .owner = THIS_MODULE,
205 .acpi_match_table = ACPI_PTR(sst_acpi_match),
206 },
207};
208module_platform_driver(sst_acpi_driver);
209
210MODULE_AUTHOR("Jarkko Nikula <jarkko.nikula@linux.intel.com>");
211MODULE_DESCRIPTION("Intel SST loader on ACPI systems");
212MODULE_LICENSE("GPL v2");