cs35l41_hda.h 1.74 KB
Newer Older
1 2
/* SPDX-License-Identifier: GPL-2.0
 *
3
 * CS35L41 ALSA HDA audio driver
4 5 6 7 8 9 10 11 12
 *
 * Copyright 2021 Cirrus Logic, Inc.
 *
 * Author: Lucas Tanure <tanureal@opensource.cirrus.com>
 */

#ifndef __CS35L41_HDA_H__
#define __CS35L41_HDA_H__

13
#include <linux/efi.h>
14 15 16 17 18
#include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <linux/device.h>
#include <sound/cs35l41.h>

19 20 21
#include <linux/firmware/cirrus/cs_dsp.h>
#include <linux/firmware/cirrus/wmfw.h>

22 23 24 25 26 27 28 29 30 31 32 33 34 35
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;

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
enum cs35l41_hda_spk_pos {
	CS35l41_LEFT,
	CS35l41_RIGHT,
};

enum cs35l41_hda_gpio_function {
	CS35L41_NOT_USED,
	CS35l41_VSPK_SWITCH,
	CS35L41_INTERRUPT,
	CS35l41_SYNC,
};

struct cs35l41_hda {
	struct device *dev;
	struct regmap *regmap;
	struct gpio_desc *reset_gpio;
52
	struct cs35l41_hw_cfg hw_cfg;
53
	struct hda_codec *codec;
54 55 56

	int irq;
	int index;
57
	int channel_index;
58
	unsigned volatile long irq_errors;
59
	const char *amp_name;
60
	const char *acpi_subsystem_id;
61
	int firmware_type;
62
	int speaker_id;
63
	struct mutex fw_mutex;
64 65
	struct work_struct fw_load_work;

66
	struct regmap_irq_chip_data *irq_data;
67
	bool firmware_running;
68 69
	bool request_fw_load;
	bool fw_request_ongoing;
70
	bool halo_initialized;
71
	bool playback_started;
72 73 74 75 76 77 78
	struct cs_dsp cs_dsp;
};

enum halo_state {
	HALO_STATE_CODE_INIT_DOWNLOAD = 0,
	HALO_STATE_CODE_START,
	HALO_STATE_CODE_RUN
79 80
};

81 82
extern const struct dev_pm_ops cs35l41_hda_pm_ops;

83 84
int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int irq,
		      struct regmap *regmap);
85
void cs35l41_hda_remove(struct device *dev);
86 87

#endif /*__CS35L41_HDA_H__*/