2021-12-17 11:57:05 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0
|
|
|
|
*
|
2022-01-17 16:08:30 +00:00
|
|
|
* CS35L41 ALSA HDA audio driver
|
2021-12-17 11:57:05 +00:00
|
|
|
*
|
|
|
|
* Copyright 2021 Cirrus Logic, Inc.
|
|
|
|
*
|
|
|
|
* Author: Lucas Tanure <tanureal@opensource.cirrus.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CS35L41_HDA_H__
|
|
|
|
#define __CS35L41_HDA_H__
|
|
|
|
|
2023-09-21 16:28:48 +00:00
|
|
|
#include <linux/acpi.h>
|
2022-06-30 00:23:31 +00:00
|
|
|
#include <linux/efi.h>
|
2021-12-17 11:57:05 +00:00
|
|
|
#include <linux/regulator/consumer.h>
|
|
|
|
#include <linux/gpio/consumer.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <sound/cs35l41.h>
|
|
|
|
|
2022-06-30 00:23:25 +00:00
|
|
|
#include <linux/firmware/cirrus/cs_dsp.h>
|
|
|
|
#include <linux/firmware/cirrus/wmfw.h>
|
|
|
|
|
2023-12-21 13:25:17 +00:00
|
|
|
#define CS35L41_MAX_ACCEPTABLE_SPI_SPEED_HZ 1000000
|
|
|
|
|
2022-06-30 00:23:31 +00:00
|
|
|
struct cs35l41_amp_cal_data {
|
|
|
|
u32 calTarget[2];
|
|
|
|
u32 calTime[2];
|
|
|
|
s8 calAmbient;
|
|
|
|
u8 calStatus;
|
|
|
|
u16 calR;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct cs35l41_amp_efi_data {
|
|
|
|
u32 size;
|
|
|
|
u32 count;
|
|
|
|
struct cs35l41_amp_cal_data data[];
|
|
|
|
} __packed;
|
|
|
|
|
2021-12-17 11:57:05 +00:00
|
|
|
enum cs35l41_hda_spk_pos {
|
2023-12-18 15:12:15 +00:00
|
|
|
CS35L41_LEFT,
|
|
|
|
CS35L41_RIGHT,
|
2021-12-17 11:57:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum cs35l41_hda_gpio_function {
|
|
|
|
CS35L41_NOT_USED,
|
|
|
|
CS35l41_VSPK_SWITCH,
|
|
|
|
CS35L41_INTERRUPT,
|
|
|
|
CS35l41_SYNC,
|
|
|
|
};
|
|
|
|
|
2023-12-21 13:25:17 +00:00
|
|
|
enum control_bus {
|
|
|
|
I2C,
|
|
|
|
SPI
|
|
|
|
};
|
|
|
|
|
2021-12-17 11:57:05 +00:00
|
|
|
struct cs35l41_hda {
|
|
|
|
struct device *dev;
|
|
|
|
struct regmap *regmap;
|
|
|
|
struct gpio_desc *reset_gpio;
|
2023-12-18 15:12:15 +00:00
|
|
|
struct gpio_desc *cs_gpio;
|
2022-04-13 08:37:13 +00:00
|
|
|
struct cs35l41_hw_cfg hw_cfg;
|
2022-06-30 00:23:24 +00:00
|
|
|
struct hda_codec *codec;
|
2021-12-17 11:57:05 +00:00
|
|
|
|
|
|
|
int irq;
|
|
|
|
int index;
|
2022-05-09 21:46:46 +00:00
|
|
|
int channel_index;
|
2022-05-09 21:46:41 +00:00
|
|
|
unsigned volatile long irq_errors;
|
2022-05-09 21:46:46 +00:00
|
|
|
const char *amp_name;
|
2022-06-30 00:23:26 +00:00
|
|
|
const char *acpi_subsystem_id;
|
2022-06-30 00:23:34 +00:00
|
|
|
int firmware_type;
|
2022-06-30 00:23:29 +00:00
|
|
|
int speaker_id;
|
2022-06-30 00:23:25 +00:00
|
|
|
struct mutex fw_mutex;
|
2022-06-30 00:23:34 +00:00
|
|
|
struct work_struct fw_load_work;
|
|
|
|
|
2022-05-09 21:46:41 +00:00
|
|
|
struct regmap_irq_chip_data *irq_data;
|
2022-06-30 00:23:25 +00:00
|
|
|
bool firmware_running;
|
2022-06-30 00:23:34 +00:00
|
|
|
bool request_fw_load;
|
|
|
|
bool fw_request_ongoing;
|
2022-06-30 00:23:25 +00:00
|
|
|
bool halo_initialized;
|
2022-06-30 00:23:34 +00:00
|
|
|
bool playback_started;
|
2022-06-30 00:23:25 +00:00
|
|
|
struct cs_dsp cs_dsp;
|
2023-09-21 16:28:48 +00:00
|
|
|
struct acpi_device *dacpi;
|
|
|
|
bool mute_override;
|
2023-12-21 13:25:17 +00:00
|
|
|
enum control_bus control_bus;
|
|
|
|
bool bypass_fw;
|
|
|
|
|
2022-06-30 00:23:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum halo_state {
|
|
|
|
HALO_STATE_CODE_INIT_DOWNLOAD = 0,
|
|
|
|
HALO_STATE_CODE_START,
|
|
|
|
HALO_STATE_CODE_RUN
|
2021-12-17 11:57:05 +00:00
|
|
|
};
|
|
|
|
|
2022-06-30 00:23:30 +00:00
|
|
|
extern const struct dev_pm_ops cs35l41_hda_pm_ops;
|
|
|
|
|
2021-12-17 11:57:05 +00:00
|
|
|
int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,
|
2023-12-21 13:25:17 +00:00
|
|
|
struct regmap *regmap, enum control_bus control_bus);
|
2022-01-17 22:00:55 +00:00
|
|
|
void cs35l41_hda_remove(struct device *dev);
|
2023-08-15 16:10:33 +00:00
|
|
|
int cs35l41_get_speaker_id(struct device *dev, int amp_index, int num_amps, int fixed_gpio_id);
|
2021-12-17 11:57:05 +00:00
|
|
|
|
|
|
|
#endif /*__CS35L41_HDA_H__*/
|