|
20 | 20 | #include "sof-priv.h" |
21 | 21 | #include "ops.h" |
22 | 22 |
|
23 | | -#define TIMEOUT_IPC 5 |
24 | | -#define TIMEOUT_BOOT 100 |
| 23 | +/* SOF defaults if not provided by the platform in ms */ |
| 24 | +#define TIMEOUT_DEFAULT_IPC 5 |
| 25 | +#define TIMEOUT_DEFAULT_BOOT 100 |
| 26 | + |
| 27 | +/* |
| 28 | + * Generic object lookup APIs. |
| 29 | + */ |
25 | 30 |
|
26 | 31 | struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_sof_dev *sdev, |
27 | 32 | struct snd_soc_pcm_runtime *rtd) |
@@ -123,11 +128,16 @@ static inline unsigned int sof_get_pages(size_t size) |
123 | 128 | return (size + PAGE_SIZE - 1) >> PAGE_SHIFT; |
124 | 129 | } |
125 | 130 |
|
| 131 | +/* |
| 132 | + * FW Panic/fault handling. |
| 133 | + */ |
| 134 | + |
126 | 135 | struct sof_panic_msg { |
127 | 136 | u32 id; |
128 | 137 | const char *msg; |
129 | 138 | }; |
130 | 139 |
|
| 140 | +/* standard FW panic types */ |
131 | 141 | static const struct sof_panic_msg panic_msg[] = { |
132 | 142 | {SOF_IPC_PANIC_MEM, "out of memory"}, |
133 | 143 | {SOF_IPC_PANIC_WORK, "work subsystem init failed"}, |
@@ -178,6 +188,43 @@ int snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code, |
178 | 188 | } |
179 | 189 | EXPORT_SYMBOL(snd_sof_get_status); |
180 | 190 |
|
| 191 | +/* |
| 192 | + * Generic buffer page table creation. |
| 193 | + */ |
| 194 | + |
| 195 | +int snd_sof_create_page_table(struct snd_sof_dev *sdev, |
| 196 | + struct snd_dma_buffer *dmab, |
| 197 | + unsigned char *page_table, size_t size) |
| 198 | +{ |
| 199 | + int i, pages; |
| 200 | + |
| 201 | + pages = snd_sgbuf_aligned_pages(size); |
| 202 | + |
| 203 | + dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n", |
| 204 | + dmab->area, size, pages); |
| 205 | + |
| 206 | + for (i = 0; i < pages; i++) { |
| 207 | + u32 idx = (((i << 2) + i)) >> 1; |
| 208 | + u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT; |
| 209 | + u32 *pg_table; |
| 210 | + |
| 211 | + dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn); |
| 212 | + |
| 213 | + pg_table = (u32 *)(page_table + idx); |
| 214 | + |
| 215 | + if (i & 1) |
| 216 | + *pg_table |= (pfn << 4); |
| 217 | + else |
| 218 | + *pg_table |= pfn; |
| 219 | + } |
| 220 | + |
| 221 | + return pages; |
| 222 | +} |
| 223 | + |
| 224 | +/* |
| 225 | + * SOF Driver enumeration. |
| 226 | + */ |
| 227 | + |
181 | 228 | static int sof_probe(struct platform_device *pdev) |
182 | 229 | { |
183 | 230 | struct snd_sof_pdata *plat_data = dev_get_platdata(&pdev->dev); |
@@ -217,11 +264,11 @@ static int sof_probe(struct platform_device *pdev) |
217 | 264 |
|
218 | 265 | /* set default timeouts if none provided */ |
219 | 266 | if (plat_data->desc->ipc_timeout == 0) |
220 | | - sdev->ipc_timeout = TIMEOUT_IPC; |
| 267 | + sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC; |
221 | 268 | else |
222 | 269 | sdev->ipc_timeout = plat_data->desc->ipc_timeout; |
223 | 270 | if (plat_data->desc->boot_timeout == 0) |
224 | | - sdev->boot_timeout = TIMEOUT_BOOT; |
| 271 | + sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT; |
225 | 272 | else |
226 | 273 | sdev->boot_timeout = plat_data->desc->boot_timeout; |
227 | 274 |
|
@@ -284,6 +331,7 @@ static int sof_probe(struct platform_device *pdev) |
284 | 331 | /* init DMA trace */ |
285 | 332 | ret = snd_sof_init_trace(sdev); |
286 | 333 | if (ret < 0) { |
| 334 | + /* non fatal */ |
287 | 335 | dev_warn(sdev->dev, |
288 | 336 | "warning: failed to initialize trace %d\n", ret); |
289 | 337 | } |
@@ -324,34 +372,6 @@ void snd_sof_shutdown(struct device *dev) |
324 | 372 | } |
325 | 373 | EXPORT_SYMBOL(snd_sof_shutdown); |
326 | 374 |
|
327 | | -int snd_sof_create_page_table(struct snd_sof_dev *sdev, |
328 | | - struct snd_dma_buffer *dmab, |
329 | | - unsigned char *page_table, size_t size) |
330 | | -{ |
331 | | - int i, pages; |
332 | | - |
333 | | - pages = sof_get_pages(size); |
334 | | - |
335 | | - dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n", |
336 | | - dmab->area, size, pages); |
337 | | - |
338 | | - for (i = 0; i < pages; i++) { |
339 | | - u32 idx = (((i << 2) + i)) >> 1; |
340 | | - u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT; |
341 | | - u32 *pg_table; |
342 | | - |
343 | | - dev_dbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn); |
344 | | - |
345 | | - pg_table = (u32 *)(page_table + idx); |
346 | | - |
347 | | - if (i & 1) |
348 | | - *pg_table |= (pfn << 4); |
349 | | - else |
350 | | - *pg_table |= pfn; |
351 | | - } |
352 | | - |
353 | | - return pages; |
354 | | -} |
355 | 375 |
|
356 | 376 | static struct platform_driver sof_driver = { |
357 | 377 | .driver = { |
|
0 commit comments