ASoC: Intel: Skylake: Add support for Loadable modules
[deliverable/linux.git] / sound / soc / intel / skylake / skl-sst-dsp.h
CommitLineData
3582f9ae
SP
1/*
2 * Skylake SST DSP Support
3 *
4 * Copyright (C) 2014-15, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as version 2, as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
16#ifndef __SKL_SST_DSP_H__
17#define __SKL_SST_DSP_H__
18
a750ba5f 19#include <linux/interrupt.h>
b6626802 20#include <sound/memalloc.h>
3e40a784 21#include "skl-sst-cldma.h"
b6626802 22
3e40a784 23struct sst_dsp;
a750ba5f 24struct skl_sst;
e973e31a
SP
25struct sst_dsp_device;
26
3582f9ae
SP
27/* Intel HD Audio General DSP Registers */
28#define SKL_ADSP_GEN_BASE 0x0
29#define SKL_ADSP_REG_ADSPCS (SKL_ADSP_GEN_BASE + 0x04)
30#define SKL_ADSP_REG_ADSPIC (SKL_ADSP_GEN_BASE + 0x08)
31#define SKL_ADSP_REG_ADSPIS (SKL_ADSP_GEN_BASE + 0x0C)
32#define SKL_ADSP_REG_ADSPIC2 (SKL_ADSP_GEN_BASE + 0x10)
33#define SKL_ADSP_REG_ADSPIS2 (SKL_ADSP_GEN_BASE + 0x14)
34
35/* Intel HD Audio Inter-Processor Communication Registers */
36#define SKL_ADSP_IPC_BASE 0x40
37#define SKL_ADSP_REG_HIPCT (SKL_ADSP_IPC_BASE + 0x00)
38#define SKL_ADSP_REG_HIPCTE (SKL_ADSP_IPC_BASE + 0x04)
39#define SKL_ADSP_REG_HIPCI (SKL_ADSP_IPC_BASE + 0x08)
40#define SKL_ADSP_REG_HIPCIE (SKL_ADSP_IPC_BASE + 0x0C)
41#define SKL_ADSP_REG_HIPCCTL (SKL_ADSP_IPC_BASE + 0x10)
42
43/* HIPCI */
44#define SKL_ADSP_REG_HIPCI_BUSY BIT(31)
45
46/* HIPCIE */
47#define SKL_ADSP_REG_HIPCIE_DONE BIT(30)
48
49/* HIPCCTL */
50#define SKL_ADSP_REG_HIPCCTL_DONE BIT(1)
51#define SKL_ADSP_REG_HIPCCTL_BUSY BIT(0)
52
53/* HIPCT */
54#define SKL_ADSP_REG_HIPCT_BUSY BIT(31)
55
56/* Intel HD Audio SRAM Window 1 */
57#define SKL_ADSP_SRAM1_BASE 0xA000
58
59#define SKL_ADSP_MMIO_LEN 0x10000
60
61#define SKL_ADSP_W0_STAT_SZ 0x800
62
63#define SKL_ADSP_W0_UP_SZ 0x800
64
65#define SKL_ADSP_W1_SZ 0x1000
66
a750ba5f
SP
67#define SKL_FW_STS_MASK 0xf
68
69#define SKL_FW_INIT 0x1
70#define SKL_FW_RFW_START 0xf
71
3582f9ae
SP
72#define SKL_ADSPIC_IPC 1
73#define SKL_ADSPIS_IPC 1
74
e973e31a
SP
75/* ADSPCS - Audio DSP Control & Status */
76#define SKL_DSP_CORES 1
77#define SKL_DSP_CORE0_MASK 1
78#define SKL_DSP_CORES_MASK ((1 << SKL_DSP_CORES) - 1)
79
80/* Core Reset - asserted high */
81#define SKL_ADSPCS_CRST_SHIFT 0
82#define SKL_ADSPCS_CRST_MASK (SKL_DSP_CORES_MASK << SKL_ADSPCS_CRST_SHIFT)
83#define SKL_ADSPCS_CRST(x) ((x << SKL_ADSPCS_CRST_SHIFT) & SKL_ADSPCS_CRST_MASK)
84
85/* Core run/stall - when set to '1' core is stalled */
86#define SKL_ADSPCS_CSTALL_SHIFT 8
87#define SKL_ADSPCS_CSTALL_MASK (SKL_DSP_CORES_MASK << \
88 SKL_ADSPCS_CSTALL_SHIFT)
89#define SKL_ADSPCS_CSTALL(x) ((x << SKL_ADSPCS_CSTALL_SHIFT) & \
90 SKL_ADSPCS_CSTALL_MASK)
91
92/* Set Power Active - when set to '1' turn cores on */
93#define SKL_ADSPCS_SPA_SHIFT 16
94#define SKL_ADSPCS_SPA_MASK (SKL_DSP_CORES_MASK << SKL_ADSPCS_SPA_SHIFT)
95#define SKL_ADSPCS_SPA(x) ((x << SKL_ADSPCS_SPA_SHIFT) & SKL_ADSPCS_SPA_MASK)
96
97/* Current Power Active - power status of cores, set by hardware */
98#define SKL_ADSPCS_CPA_SHIFT 24
99#define SKL_ADSPCS_CPA_MASK (SKL_DSP_CORES_MASK << SKL_ADSPCS_CPA_SHIFT)
100#define SKL_ADSPCS_CPA(x) ((x << SKL_ADSPCS_CPA_SHIFT) & SKL_ADSPCS_CPA_MASK)
101
102#define SST_DSP_POWER_D0 0x0 /* full On */
103#define SST_DSP_POWER_D3 0x3 /* Off */
104
105enum skl_dsp_states {
106 SKL_DSP_RUNNING = 1,
107 SKL_DSP_RESET,
108};
109
110struct skl_dsp_fw_ops {
111 int (*load_fw)(struct sst_dsp *ctx);
112 /* FW module parser/loader */
113 int (*parse_fw)(struct sst_dsp *ctx);
114 int (*set_state_D0)(struct sst_dsp *ctx);
115 int (*set_state_D3)(struct sst_dsp *ctx);
a750ba5f 116 unsigned int (*get_fw_errcode)(struct sst_dsp *ctx);
6c5768b3
D
117 int (*load_mod)(struct sst_dsp *ctx, u16 mod_id, char *mod_name);
118 int (*unload_mod)(struct sst_dsp *ctx, u16 mod_id);
119
e973e31a
SP
120};
121
b6626802
SP
122struct skl_dsp_loader_ops {
123 int (*alloc_dma_buf)(struct device *dev,
124 struct snd_dma_buffer *dmab, size_t size);
125 int (*free_dma_buf)(struct device *dev,
126 struct snd_dma_buffer *dmab);
127};
128
6c5768b3
D
129struct skl_load_module_info {
130 u16 mod_id;
131 const struct firmware *fw;
132};
133
134struct skl_module_table {
135 struct skl_load_module_info *mod_info;
136 unsigned int usage_cnt;
137 struct list_head list;
138};
139
3e40a784
VK
140void skl_cldma_process_intr(struct sst_dsp *ctx);
141void skl_cldma_int_disable(struct sst_dsp *ctx);
142int skl_cldma_prepare(struct sst_dsp *ctx);
143
e973e31a
SP
144void skl_dsp_set_state_locked(struct sst_dsp *ctx, int state);
145struct sst_dsp *skl_dsp_ctx_init(struct device *dev,
146 struct sst_dsp_device *sst_dev, int irq);
147int skl_dsp_disable_core(struct sst_dsp *ctx);
148bool is_skl_dsp_running(struct sst_dsp *ctx);
149irqreturn_t skl_dsp_sst_interrupt(int irq, void *dev_id);
150int skl_dsp_wake(struct sst_dsp *ctx);
151int skl_dsp_sleep(struct sst_dsp *ctx);
152void skl_dsp_free(struct sst_dsp *dsp);
153
154int skl_dsp_boot(struct sst_dsp *ctx);
a750ba5f 155int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
aecf6fd8
VK
156 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
157 struct skl_sst **dsp);
a750ba5f 158void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx);
e973e31a 159
3582f9ae 160#endif /*__SKL_SST_DSP_H__*/
This page took 0.078901 seconds and 5 git commands to generate.