linux/include/sound/cs35l56.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Common definitions for Cirrus Logic CS35L56 smart amp
 *
 * Copyright (C) 2023 Cirrus Logic, Inc. and
 *                    Cirrus Logic International Semiconductor Ltd.
 */

#ifndef __CS35L56_H
#define __CS35L56_H

#include <linux/firmware/cirrus/cs_dsp.h>
#include <linux/regulator/consumer.h>
#include <linux/regmap.h>
#include <sound/cs-amp-lib.h>

#define CS35L56_DEVID
#define CS35L56_REVID
#define CS35L56_RELID
#define CS35L56_OTPID
#define CS35L56_SFT_RESET
#define CS35L56_GLOBAL_ENABLES
#define CS35L56_BLOCK_ENABLES
#define CS35L56_BLOCK_ENABLES2
#define CS35L56_REFCLK_INPUT
#define CS35L56_GLOBAL_SAMPLE_RATE
#define CS35L56_OTP_MEM_53
#define CS35L56_OTP_MEM_54
#define CS35L56_OTP_MEM_55
#define CS35L56_ASP1_ENABLES1
#define CS35L56_ASP1_CONTROL1
#define CS35L56_ASP1_CONTROL2
#define CS35L56_ASP1_CONTROL3
#define CS35L56_ASP1_FRAME_CONTROL1
#define CS35L56_ASP1_FRAME_CONTROL5
#define CS35L56_ASP1_DATA_CONTROL1
#define CS35L56_ASP1_DATA_CONTROL5
#define CS35L56_DACPCM1_INPUT
#define CS35L56_DACPCM2_INPUT
#define CS35L56_ASP1TX1_INPUT
#define CS35L56_ASP1TX2_INPUT
#define CS35L56_ASP1TX3_INPUT
#define CS35L56_ASP1TX4_INPUT
#define CS35L56_DSP1RX1_INPUT
#define CS35L56_DSP1RX2_INPUT
#define CS35L56_SWIRE_DP3_CH1_INPUT
#define CS35L56_SWIRE_DP3_CH2_INPUT
#define CS35L56_SWIRE_DP3_CH3_INPUT
#define CS35L56_SWIRE_DP3_CH4_INPUT
#define CS35L56_IRQ1_CFG
#define CS35L56_IRQ1_STATUS
#define CS35L56_IRQ1_EINT_1
#define CS35L56_IRQ1_EINT_2
#define CS35L56_IRQ1_EINT_4
#define CS35L56_IRQ1_EINT_8
#define CS35L56_IRQ1_EINT_18
#define CS35L56_IRQ1_EINT_20
#define CS35L56_IRQ1_MASK_1
#define CS35L56_IRQ1_MASK_2
#define CS35L56_IRQ1_MASK_4
#define CS35L56_IRQ1_MASK_8
#define CS35L56_IRQ1_MASK_18
#define CS35L56_IRQ1_MASK_20
#define CS35L56_DSP_VIRTUAL1_MBOX_1
#define CS35L56_DSP_VIRTUAL1_MBOX_2
#define CS35L56_DSP_VIRTUAL1_MBOX_3
#define CS35L56_DSP_VIRTUAL1_MBOX_4
#define CS35L56_DSP_VIRTUAL1_MBOX_5
#define CS35L56_DSP_VIRTUAL1_MBOX_6
#define CS35L56_DSP_VIRTUAL1_MBOX_7
#define CS35L56_DSP_VIRTUAL1_MBOX_8
#define CS35L56_DSP_RESTRICT_STS1
#define CS35L56_DSP1_XMEM_PACKED_0
#define CS35L56_DSP1_XMEM_PACKED_6143
#define CS35L56_DSP1_XMEM_UNPACKED32_0
#define CS35L56_DSP1_XMEM_UNPACKED32_4095
#define CS35L56_DSP1_SYS_INFO_ID
#define CS35L56_DSP1_SYS_INFO_END
#define CS35L56_DSP1_AHBM_WINDOW_DEBUG_0
#define CS35L56_DSP1_AHBM_WINDOW_DEBUG_1
#define CS35L56_DSP1_XMEM_UNPACKED24_0
#define CS35L56_DSP1_FW_VER
#define CS35L56_DSP1_HALO_STATE
#define CS35L56_DSP1_PM_CUR_STATE
#define CS35L56_DSP1_XMEM_UNPACKED24_8191
#define CS35L56_DSP1_CORE_BASE
#define CS35L56_DSP1_SCRATCH1
#define CS35L56_DSP1_SCRATCH2
#define CS35L56_DSP1_SCRATCH3
#define CS35L56_DSP1_SCRATCH4
#define CS35L56_DSP1_YMEM_PACKED_0
#define CS35L56_DSP1_YMEM_PACKED_4604
#define CS35L56_DSP1_YMEM_UNPACKED32_0
#define CS35L56_DSP1_YMEM_UNPACKED32_3070
#define CS35L56_DSP1_YMEM_UNPACKED24_0
#define CS35L56_MAIN_RENDER_USER_MUTE
#define CS35L56_MAIN_RENDER_USER_VOLUME
#define CS35L56_MAIN_POSTURE_NUMBER
#define CS35L56_PROTECTION_STATUS
#define CS35L56_TRANSDUCER_ACTUAL_PS
#define CS35L56_DSP1_YMEM_UNPACKED24_6141
#define CS35L56_DSP1_PMEM_0
#define CS35L56_DSP1_PMEM_5114

/* DEVID */
#define CS35L56_DEVID_MASK

/* REVID */
#define CS35L56_AREVID_MASK
#define CS35L56_MTLREVID_MASK
#define CS35L56_REVID_B0

/* ASP_ENABLES1 */
#define CS35L56_ASP_RX2_EN_SHIFT
#define CS35L56_ASP_RX1_EN_SHIFT
#define CS35L56_ASP_TX4_EN_SHIFT
#define CS35L56_ASP_TX3_EN_SHIFT
#define CS35L56_ASP_TX2_EN_SHIFT
#define CS35L56_ASP_TX1_EN_SHIFT

/* ASP_CONTROL1 */
#define CS35L56_ASP_BCLK_FREQ_MASK
#define CS35L56_ASP_BCLK_FREQ_SHIFT

/* ASP_CONTROL2 */
#define CS35L56_ASP_RX_WIDTH_MASK
#define CS35L56_ASP_RX_WIDTH_SHIFT
#define CS35L56_ASP_TX_WIDTH_MASK
#define CS35L56_ASP_TX_WIDTH_SHIFT
#define CS35L56_ASP_FMT_MASK
#define CS35L56_ASP_FMT_SHIFT
#define CS35L56_ASP_BCLK_INV_MASK
#define CS35L56_ASP_FSYNC_INV_MASK

/* ASP_CONTROL3 */
#define CS35L56_ASP1_DOUT_HIZ_CTRL_MASK

/* ASP_DATA_CONTROL1 */
#define CS35L56_ASP_TX_WL_MASK

/* ASP_DATA_CONTROL5 */
#define CS35L56_ASP_RX_WL_MASK

/* ASPTXn_INPUT */
#define CS35L56_ASP_TXn_SRC_MASK

/* SWIRETX[1..7]_SRC SDWTXn INPUT */
#define CS35L56_SWIRETXn_SRC_MASK

/* IRQ1_STATUS */
#define CS35L56_IRQ1_STS_MASK

/* IRQ1_EINT_1 */
#define CS35L56_AMP_SHORT_ERR_EINT1_MASK

/* IRQ1_EINT_2 */
#define CS35L56_DSP_VIRTUAL2_MBOX_WR_EINT1_MASK

/* IRQ1_EINT_4 */
#define CS35L56_OTP_BOOT_DONE_MASK

/* IRQ1_EINT_8 */
#define CS35L56_TEMP_ERR_EINT1_MASK

/* Mixer input sources */
#define CS35L56_INPUT_SRC_NONE
#define CS35L56_INPUT_SRC_ASP1RX1
#define CS35L56_INPUT_SRC_ASP1RX2
#define CS35L56_INPUT_SRC_VMON
#define CS35L56_INPUT_SRC_IMON
#define CS35L56_INPUT_SRC_ERR_VOL
#define CS35L56_INPUT_SRC_CLASSH
#define CS35L56_INPUT_SRC_VDDBMON
#define CS35L56_INPUT_SRC_VBSTMON
#define CS35L56_INPUT_SRC_DSP1TX1
#define CS35L56_INPUT_SRC_DSP1TX2
#define CS35L56_INPUT_SRC_DSP1TX3
#define CS35L56_INPUT_SRC_DSP1TX4
#define CS35L56_INPUT_SRC_DSP1TX5
#define CS35L56_INPUT_SRC_DSP1TX6
#define CS35L56_INPUT_SRC_DSP1TX7
#define CS35L56_INPUT_SRC_DSP1TX8
#define CS35L56_INPUT_SRC_TEMPMON
#define CS35L56_INPUT_SRC_INTERPOLATOR
#define CS35L56_INPUT_SRC_SWIRE_DP1_CHANNEL1
#define CS35L56_INPUT_SRC_SWIRE_DP1_CHANNEL2
#define CS35L56_INPUT_MASK

#define CS35L56_NUM_INPUT_SRC

/* ASP formats */
#define CS35L56_ASP_FMT_DSP_A
#define CS35L56_ASP_FMT_I2S

/* ASP HiZ modes */
#define CS35L56_ASP_UNUSED_HIZ_OFF_HIZ

/* MAIN_RENDER_ACTUAL_PS */
#define CS35L56_PS0
#define CS35L56_PS3

/* CS35L56_DSP_RESTRICT_STS1 */
#define CS35L56_RESTRICTED_MASK

/* CS35L56_MAIN_RENDER_USER_MUTE */
#define CS35L56_MAIN_RENDER_USER_MUTE_MASK

/* CS35L56_MAIN_RENDER_USER_VOLUME */
#define CS35L56_MAIN_RENDER_USER_VOLUME_MIN
#define CS35L56_MAIN_RENDER_USER_VOLUME_MAX
#define CS35L56_MAIN_RENDER_USER_VOLUME_MASK
#define CS35L56_MAIN_RENDER_USER_VOLUME_SHIFT
#define CS35L56_MAIN_RENDER_USER_VOLUME_SIGNBIT

/* CS35L56_MAIN_POSTURE_NUMBER */
#define CS35L56_MAIN_POSTURE_MIN
#define CS35L56_MAIN_POSTURE_MAX
#define CS35L56_MAIN_POSTURE_MASK

/* CS35L56_PROTECTION_STATUS */
#define CS35L56_FIRMWARE_MISSING

/* Software Values */
#define CS35L56_HALO_STATE_SHUTDOWN
#define CS35L56_HALO_STATE_BOOT_DONE

#define CS35L56_MBOX_CMD_AUDIO_PLAY
#define CS35L56_MBOX_CMD_AUDIO_PAUSE
#define CS35L56_MBOX_CMD_AUDIO_REINIT
#define CS35L56_MBOX_CMD_HIBERNATE_NOW
#define CS35L56_MBOX_CMD_WAKEUP
#define CS35L56_MBOX_CMD_PREVENT_AUTO_HIBERNATE
#define CS35L56_MBOX_CMD_ALLOW_AUTO_HIBERNATE
#define CS35L56_MBOX_CMD_SHUTDOWN
#define CS35L56_MBOX_CMD_SYSTEM_RESET

#define CS35L56_MBOX_TIMEOUT_US
#define CS35L56_MBOX_POLL_US

#define CS35L56_PS0_POLL_US
#define CS35L56_PS0_TIMEOUT_US
#define CS35L56_PS3_POLL_US
#define CS35L56_PS3_TIMEOUT_US

#define CS35L56_CONTROL_PORT_READY_US
#define CS35L56_HALO_STATE_POLL_US
#define CS35L56_HALO_STATE_TIMEOUT_US
#define CS35L56_RESET_PULSE_MIN_US
#define CS35L56_WAKE_HOLD_TIME_US

#define CS35L56_SDW1_PLAYBACK_PORT
#define CS35L56_SDW1_CAPTURE_PORT

#define CS35L56_NUM_BULK_SUPPLIES
#define CS35L56_NUM_DSP_REGIONS

struct cs35l56_base {};

/* Temporary to avoid a build break with the HDA driver */
static inline int cs35l56_force_sync_asp1_registers_from_cache(struct cs35l56_base *cs35l56_base)
{}

static inline bool cs35l56_is_otp_register(unsigned int reg)
{}

extern const struct regmap_config cs35l56_regmap_i2c;
extern const struct regmap_config cs35l56_regmap_spi;
extern const struct regmap_config cs35l56_regmap_sdw;

extern const struct cirrus_amp_cal_controls cs35l56_calibration_controls;

extern const char * const cs35l56_tx_input_texts[CS35L56_NUM_INPUT_SRC];
extern const unsigned int cs35l56_tx_input_values[CS35L56_NUM_INPUT_SRC];

int cs35l56_set_patch(struct cs35l56_base *cs35l56_base);
int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command);
int cs35l56_firmware_shutdown(struct cs35l56_base *cs35l56_base);
int cs35l56_wait_for_firmware_boot(struct cs35l56_base *cs35l56_base);
void cs35l56_wait_control_port_ready(void);
void cs35l56_wait_min_reset_pulse(void);
void cs35l56_system_reset(struct cs35l56_base *cs35l56_base, bool is_soundwire);
int cs35l56_irq_request(struct cs35l56_base *cs35l56_base, int irq);
irqreturn_t cs35l56_irq(int irq, void *data);
int cs35l56_is_fw_reload_needed(struct cs35l56_base *cs35l56_base);
int cs35l56_runtime_suspend_common(struct cs35l56_base *cs35l56_base);
int cs35l56_runtime_resume_common(struct cs35l56_base *cs35l56_base, bool is_soundwire);
void cs35l56_init_cs_dsp(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_dsp);
int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base);
int cs35l56_read_prot_status(struct cs35l56_base *cs35l56_base,
			     bool *fw_missing, unsigned int *fw_version);
int cs35l56_hw_init(struct cs35l56_base *cs35l56_base);
int cs35l56_get_speaker_id(struct cs35l56_base *cs35l56_base);
int cs35l56_get_bclk_freq_id(unsigned int freq);
void cs35l56_fill_supply_names(struct regulator_bulk_data *data);

#endif /* ifndef __CS35L56_H */