sound/soc/codecs/tas675x.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas675x.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tas675x.c
Extension
.c
Size
71197 bytes
Lines
2195
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tas675x_reg_param {
	u8  page;
	u8  reg;
	u32 val;
};

struct tas675x_priv {
	struct device *dev;
	struct regmap *regmap;
	enum tas675x_type dev_type;
	/* Custom regmap lock; protects writes across books */
	struct mutex io_lock;

	struct gpio_desc *pd_gpio;
	struct gpio_desc *stby_gpio;
	struct regulator_bulk_data supplies[2];
	struct regulator *vbat;
	bool fast_boot;

	int audio_slot;
	int llp_slot;
	int vpredict_slot;
	int isense_slot;
	int bclk_offset;
	int slot_width;
	unsigned int tx_mask;

	int gpio1_func;
	int gpio2_func;

	unsigned long active_playback_dais;
	unsigned long active_capture_dais;
	unsigned int rate;
	unsigned int saved_rtldg_en;
#define TAS675X_DSP_PARAM_NUM	2
	struct tas675x_reg_param dsp_params[TAS675X_DSP_PARAM_NUM];

	/* Fault monitor, disabled when Fault IRQ is used */
	struct delayed_work fault_check_work;
#define TAS675X_FAULT_REGS_NUM	9
	unsigned int last_status[TAS675X_FAULT_REGS_NUM];
};

static const char * const tas675x_supply_names[] = {
	"dvdd",		/* Digital power supply */
	"pvdd",		/* Output powerstage supply */
};

/* Page 1 setup initialization defaults */
static const struct reg_sequence tas675x_page1_init[] = {
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC8), 0x20),	/* Charge pump clock */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0x2F), 0x90),	/* VBAT idle */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0x29), 0x40),	/* OC/CBC threshold */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0x2E), 0x0C),	/* OC/CBC config */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC5), 0x02),	/* OC/CBC config */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC6), 0x10),	/* OC/CBC config */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0x1F), 0x20),	/* OC/CBC config */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0x16), 0x01),	/* OC/CBC config */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0x1E), 0x04),	/* OC/CBC config */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC1), 0x00),	/* CH1 DC fault */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC2), 0x04),	/* CH2 DC fault */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC3), 0x00),	/* CH3 DC fault */
	REG_SEQ0(TAS675X_PAGE_REG(1, 0xC4), 0x00),	/* CH4 DC fault */
};

static inline const char *tas675x_state_name(unsigned int state)
{
	switch (state & 0x0F) {
	case TAS675X_STATE_DEEPSLEEP:	return "DEEPSLEEP";
	case TAS675X_STATE_LOAD_DIAG:	return "LOAD_DIAG";
	case TAS675X_STATE_SLEEP:	return "SLEEP";
	case TAS675X_STATE_HIZ:		return "HIZ";
	case TAS675X_STATE_PLAY:	return "PLAY";
	case TAS675X_STATE_FAULT:	return "FAULT";
	case TAS675X_STATE_AUTOREC:	return "AUTOREC";
	default:			return "UNKNOWN";
	}
}

static inline int tas675x_set_state_all(struct tas675x_priv *tas, u8 state)
{
	const struct reg_sequence seq[] = {
		REG_SEQ0(TAS675X_STATE_CTRL_CH1_CH2_REG, state),
		REG_SEQ0(TAS675X_STATE_CTRL_CH3_CH4_REG, state),
	};

	return regmap_multi_reg_write(tas->regmap, seq, ARRAY_SIZE(seq));
}

static inline int tas675x_select_book(struct regmap *regmap, u8 book)

Annotation

Implementation Notes