1 #ifndef __CONFIG_LINUX_KERNEL_INC__
2 #define __CONFIG_LINUX_KERNEL_INC__
4 #include <linux/kernel.h>
5 #include <linux/types.h>
6 #include <linux/ctype.h>
7 #include <linux/delay.h>
8 #include <linux/slab.h>
9 #include <linux/crc32.h>
10 #include <linux/ftrace.h>
11 #include <linux/of_device.h>
12 #include <sound/pcm.h>
15 i2c transaction on Linux limited to 64k
16 (See Linux kernel documentation: Documentation/i2c/writing-clients)
18 #define MAX_I2C_BUFFER_SIZE 65536
19 #define TFA98XX_FLAG_TDM_DEVICE (1 << 10)
20 /* max. length of a alsa mixer control name */
21 #define MAX_CONTROL_NAME 48
24 #define PRINT(fmt) "%s: " fmt, __func__
27 #define PRINT_ASSERT(e)if ((e)) printk(KERN_ERR "PrintAssert:%s (%s:%d) error code:%d\n", __FUNCTION__, __FILE__, __LINE__, e)
29 #define TFA98XX_MAX_REGISTER 0xff
31 #define TFA98XX_FLAG_DSP_START_ON_MUTE (1 << 0)
32 #define TFA98XX_FLAG_SKIP_INTERRUPTS (1 << 1)
33 #define TFA98XX_FLAG_SAAM_AVAILABLE (1 << 2)
34 #define TFA98XX_FLAG_STEREO_DEVICE (1 << 3)
35 #define TFA98XX_FLAG_MULTI_MIC_INPUTS (1 << 4)
36 #define TFA98XX_FLAG_TAPDET_AVAILABLE (1 << 5)
37 #define TFA98XX_FLAG_TFA9890_FAM_DEV (1 << 6)
38 #define TFA98XX_FLAG_TFA9897_FAM_DEV (1 << 7)
40 #define TFA98XX_NUM_RATES 9
42 enum tfa98xx_dsp_init_state {
43 TFA98XX_DSP_INIT_STOPPED, /* DSP not running */
44 TFA98XX_DSP_INIT_RECOVER, /* DSP error detected at runtime */
45 TFA98XX_DSP_INIT_FAIL, /* DSP init failed */
46 TFA98XX_DSP_INIT_PENDING, /* DSP start requested */
47 TFA98XX_DSP_INIT_DONE, /* DSP running */
48 TFA98XX_DSP_INIT_INVALIDATED, /* DSP was running, requires re-init */
51 enum tfa98xx_dsp_fw_state {
52 TFA98XX_DSP_FW_NONE = 0,
53 TFA98XX_DSP_FW_PENDING,
58 struct tfa98xx_firmware {
60 struct tfa98xx_device *dev;
64 struct tfa98xx_baseprofile {
65 char basename[MAX_CONTROL_NAME]; /* profile basename */
66 int len; /* profile length */
67 int item_id; /* profile id */
68 int sr_rate_sup[TFA98XX_NUM_RATES]; /* sample rates supported by this profile */
69 struct list_head list; /* list of all profiles */
73 struct regmap *regmap;
74 struct i2c_client *i2c;
75 struct regulator *vdd;
76 struct snd_soc_codec *codec;
77 struct workqueue_struct *tfa98xx_wq;
78 struct delayed_work init_work;
79 struct delayed_work monitor_work;
80 struct delayed_work interrupt_work;
81 struct delayed_work tapdet_work;
82 struct mutex dsp_lock;
90 struct tfa98xx_firmware fw;
95 unsigned int init_count;
98 struct input_dev *input;
99 bool tapdet_enabled; /* service enabled */
100 bool tapdet_open; /* device file opened */
101 unsigned int tapdet_profiles; /* tapdet profile bitfield */
102 bool tapdet_poll; /* tapdet running on polling mode */
104 unsigned int rate_constraint_list[TFA98XX_NUM_RATES];
105 struct snd_pcm_hw_constraint_list rate_constraint;
113 #ifdef CONFIG_DEBUG_FS
114 struct dentry *dbg_dir;
118 unsigned int count_wait_for_source_state;
119 unsigned int count_noclk;
122 struct device_node *spk_id_gpio_p;
125 #if defined(CONFIG_TRACING) && defined(DEBUG)
126 #define tfa98xx_trace_printk(...) trace_printk(__VA_ARGS__)
128 #define tfa98xx_trace_printk(...)
132 i2c transaction on Linux limited to 64k
133 (See Linux kernel documentation: Documentation/i2c/writing-clients)
135 static inline int NXP_I2C_BufferSize(void)
140 #endif /* __CONFIG_LINUX_KERNEL_INC__ */