| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Driver for Cirrus Logic CS35L56 smart amp |
| 4 |
* |
| 5 |
* Copyright (C) 2023 Cirrus Logic, Inc. and |
| 6 |
* Cirrus Logic International Semiconductor Ltd. |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef CS35L56_H |
| 10 |
#define CS35L56_H |
| 11 |
|
| 12 |
#include <linux/completion.h> |
| 13 |
#include <linux/container_of.h> |
| 14 |
#include <linux/regulator/consumer.h> |
| 15 |
#include <linux/pm_runtime.h> |
| 16 |
#include <linux/workqueue.h> |
| 17 |
#include <sound/cs35l56.h> |
| 18 |
#include "wm_adsp.h" |
| 19 |
|
| 20 |
#define CS35L56_SDW_GEN_INT_STAT_1 0xc0 |
| 21 |
#define CS35L56_SDW_GEN_INT_MASK_1 0xc1 |
| 22 |
#define CS35L56_SDW_INT_MASK_CODEC_IRQ BIT(0) |
| 23 |
|
| 24 |
#define CS35L56_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) |
| 25 |
#define CS35L56_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE \ |
| 26 |
| SNDRV_PCM_FMTBIT_S32_LE) |
| 27 |
|
| 28 |
#define CS35L56_RATES (SNDRV_PCM_RATE_48000) |
| 29 |
|
| 30 |
struct sdw_slave; |
| 31 |
|
| 32 |
struct cs35l56_private { |
| 33 |
struct wm_adsp dsp; /* must be first member */ |
| 34 |
struct cs35l56_base base; |
| 35 |
struct work_struct dsp_work; |
| 36 |
struct workqueue_struct *dsp_wq; |
| 37 |
struct snd_soc_component *component; |
| 38 |
struct regulator_bulk_data supplies[CS35L56_NUM_BULK_SUPPLIES]; |
| 39 |
struct sdw_slave *sdw_peripheral; |
| 40 |
const char *fallback_fw_suffix; |
| 41 |
struct work_struct sdw_irq_work; |
| 42 |
bool sdw_irq_no_unmask; |
| 43 |
bool soft_resetting; |
| 44 |
bool sdw_attached; |
| 45 |
struct completion init_completion; |
| 46 |
|
| 47 |
int speaker_id; |
| 48 |
u32 rx_mask; |
| 49 |
u32 tx_mask; |
| 50 |
u8 asp_slot_width; |
| 51 |
u8 asp_slot_count; |
| 52 |
bool tdm_mode; |
| 53 |
bool sysclk_set; |
| 54 |
u8 sdw_link_num; |
| 55 |
u8 sdw_unique_id; |
| 56 |
}; |
| 57 |
|
| 58 |
static inline struct cs35l56_private *cs35l56_private_from_base(struct cs35l56_base *cs35l56_base) |
| 59 |
{ |
| 60 |
return container_of(cs35l56_base, struct cs35l56_private, base); |
| 61 |
} |
| 62 |
|
| 63 |
extern const struct dev_pm_ops cs35l56_pm_ops_i2c_spi; |
| 64 |
|
| 65 |
int cs35l56_system_suspend(struct device *dev); |
| 66 |
int cs35l56_system_suspend_late(struct device *dev); |
| 67 |
int cs35l56_system_suspend_no_irq(struct device *dev); |
| 68 |
int cs35l56_system_resume_no_irq(struct device *dev); |
| 69 |
int cs35l56_system_resume_early(struct device *dev); |
| 70 |
int cs35l56_system_resume(struct device *dev); |
| 71 |
irqreturn_t cs35l56_irq(int irq, void *data); |
| 72 |
int cs35l56_irq_request(struct cs35l56_base *cs35l56_base, int irq); |
| 73 |
int cs35l56_common_probe(struct cs35l56_private *cs35l56); |
| 74 |
int cs35l56_init(struct cs35l56_private *cs35l56); |
| 75 |
void cs35l56_remove(struct cs35l56_private *cs35l56); |
| 76 |
|
| 77 |
#if IS_ENABLED(CONFIG_KUNIT) |
| 78 |
int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56); |
| 79 |
int cs35l56_set_fw_name(struct snd_soc_component *component); |
| 80 |
int cs35l56_process_xu_properties(struct cs35l56_private *cs35l56); |
| 81 |
#endif |
| 82 |
|
| 83 |
#endif /* ifndef CS35L56_H */ |