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