Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2439ea1f authored by Sven Brandau's avatar Sven Brandau Committed by Mark Brown
Browse files

ASoC: sta350: Add codec driver



The TI STA350 is an integrated 2.1-channel power amplifier that is
controllable over I2C. This patch adds an ASoC driver for it.

At a glance, this chip is very similar to the STA320 for which a driver
already exists. In details, however, the register maps contain subtle
differences which made a whole new driver easier to write and maintain.

[daniel@zonque.org: cleanups, DT property rework, rebased on asoc-next]
Signed-off-by: default avatarSven Brandau <brandau@gmx.de>
Signed-off-by: default avatarDaniel Mack <daniel@zonque.org>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent c9eaa447
Loading
Loading
Loading
Loading
+107 −0
Original line number Diff line number Diff line
STA350 audio CODEC

The driver for this device only supports I2C.

Required properties:

  - compatible: "st,sta350"
  - reg: the I2C address of the device for I2C
  - reset-gpios: a GPIO spec for the reset pin. If specified, it will be
		 deasserted before communication to the codec starts.

  - power-down-gpios: a GPIO spec for the power down pin. If specified,
		      it will be deasserted before communication to the codec
		      starts.

  - vdd-dig-supply: regulator spec, providing 3.3V
  - vdd-pll-supply: regulator spec, providing 3.3V
  - vcc-supply: regulator spec, providing 5V - 26V

Optional properties:

  -  st,output-conf: number, Selects the output configuration:
	0: 2-channel (full-bridge) power, 2-channel data-out
	1: 2 (half-bridge). 1 (full-bridge) on-board power
	2: 2 Channel (Full-Bridge) Power, 1 Channel FFX
	3: 1 Channel Mono-Parallel
	If parameter is missing, mode 0 will be enabled.

  -  st,ch1-output-mapping: Channel 1 output mapping
  -  st,ch2-output-mapping: Channel 2 output mapping
  -  st,ch3-output-mapping: Channel 3 output mapping
	0: Channel 1
	1: Channel 2
	2: Channel 3
	If parameter is missing, channel 1 is choosen.

  -  st,thermal-warning-recover:
	If present, thermal warning recovery is enabled.

  -  st,thermal-warning-adjustment:
	If present, thermal warning adjustment is enabled.

  -  st,fault-detect-recovery:
	If present, then fault recovery will be enabled.

  -  st,ffx-power-output-mode: string
	The FFX power output mode selects how the FFX output timing is
	configured. Must be one of these values:
	  -  "drop-compensation"
	  -  "tapered-compensation"
	  -  "full-power-mode"
	  -  "variable-drop-compensation" (default)

  -  st,drop-compensation-ns: number
	Only required for "st,ffx-power-output-mode" ==
	"variable-drop-compensation".
	Specifies the drop compensation in nanoseconds.
	The value must be in the range of 0..300, and only
	multiples of 20 are allowed. Default is 140ns.

  -  st,overcurrent-warning-adjustment:
	If present, overcurrent warning adjustment is enabled.

  -  st,max-power-use-mpcc:
	If present, then MPCC bits are used for MPC coefficients,
	otherwise standard MPC coefficients are used.

  -  st,max-power-corr:
	If present, power bridge correction for THD reduction near maximum
	power output is enabled.

  -  st,am-reduction-mode:
	If present, FFX mode runs in AM reduction mode, otherwise normal
	FFX mode is used.

  -  st,odd-pwm-speed-mode:
	If present, PWM speed mode run on odd speed mode (341.3 kHz) on all
	channels. If not present, normal PWM spped mode (384 kHz) will be used.

  -  st,distortion-compensation:
	If present, distortion compensation variable uses DCC coefficient.
	If not present, preset DC coefficient is used.

  -  st,invalid-input-detect-mute:
	If not present, automatic invalid input detect mute is enabled.



Example:

codec: sta350@38 {
	compatible = "st,sta350";
	reg = <0x1c>;
	reset-gpios = <&gpio1 19 0>;
	power-down-gpios = <&gpio1 16 0>;
	st,output-conf = <0x3>;			// set output to 2-channel
						// (full-bridge) power,
						// 2-channel data-out
	st,ch1-output-mapping = <0>;		// set channel 1 output ch 1
	st,ch2-output-mapping = <0>;		// set channel 2 output ch 1
	st,ch3-output-mapping = <0>;		// set channel 3 output ch 1
	st,max-power-correction;		// enables power bridge
						// correction for THD reduction
						// near maximum power output
	st,invalid-input-detect-mute;		// mute if no valid digital
						// audio signal is provided.
};

include/sound/sta350.h

0 → 100644
+52 −0
Original line number Diff line number Diff line
/*
 * Platform data for ST STA350 ASoC codec driver.
 *
 * Copyright: 2014 Raumfeld GmbH
 * Author: Sven Brandau <info@brandau.biz>
 *
 * This program is free software; you can redistribute  it and/or modify it
 * under  the terms of  the GNU General  Public License as published by the
 * Free Software Foundation;  either version 2 of the  License, or (at your
 * option) any later version.
 */
#ifndef __LINUX_SND__STA350_H
#define __LINUX_SND__STA350_H

#define STA350_OCFG_2CH		0
#define STA350_OCFG_2_1CH	1
#define STA350_OCFG_1CH		3

#define STA350_OM_CH1		0
#define STA350_OM_CH2		1
#define STA350_OM_CH3		2

#define STA350_THERMAL_ADJUSTMENT_ENABLE	1
#define STA350_THERMAL_RECOVERY_ENABLE		2
#define STA350_FAULT_DETECT_RECOVERY_BYPASS	1

#define STA350_FFX_PM_DROP_COMP			0
#define STA350_FFX_PM_TAPERED_COMP		1
#define STA350_FFX_PM_FULL_POWER		2
#define STA350_FFX_PM_VARIABLE_DROP_COMP	3


struct sta350_platform_data {
	u8 output_conf;
	u8 ch1_output_mapping;
	u8 ch2_output_mapping;
	u8 ch3_output_mapping;
	u8 ffx_power_output_mode;
	u8 drop_compensation_ns;
	unsigned int thermal_warning_recovery:1;
	unsigned int thermal_warning_adjustment:1;
	unsigned int fault_detect_recovery:1;
	unsigned int oc_warning_adjustment:1;
	unsigned int max_power_use_mpcc:1;
	unsigned int max_power_correction:1;
	unsigned int am_reduction_mode:1;
	unsigned int odd_pwm_speed_mode:1;
	unsigned int distortion_compensation:1;
	unsigned int invalid_input_detect_mute:1;
};

#endif /* __LINUX_SND__STA350_H */
+5 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ config SND_SOC_ALL_CODECS
	select SND_SOC_SSM2602_SPI if SPI_MASTER
	select SND_SOC_SSM2602_I2C if I2C
	select SND_SOC_STA32X if I2C
	select SND_SOC_STA350 if I2C
	select SND_SOC_STA529 if I2C
	select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
	select SND_SOC_TAS5086 if I2C
@@ -435,6 +436,10 @@ config SND_SOC_SSM2602_I2C
config SND_SOC_STA32X
	tristate

config SND_SOC_STA350
	tristate "STA350 speaker amplifier"
	depends on I2C

config SND_SOC_STA529
	tristate

+2 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ snd-soc-ssm2602-objs := ssm2602.o
snd-soc-ssm2602-spi-objs := ssm2602-spi.o
snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o
snd-soc-sta32x-objs := sta32x.o
snd-soc-sta350-objs := sta350.o
snd-soc-sta529-objs := sta529.o
snd-soc-stac9766-objs := stac9766.o
snd-soc-tas5086-objs := tas5086.o
@@ -221,6 +222,7 @@ obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o
obj-$(CONFIG_SND_SOC_SSM2602_SPI)	+= snd-soc-ssm2602-spi.o
obj-$(CONFIG_SND_SOC_SSM2602_I2C)	+= snd-soc-ssm2602-i2c.o
obj-$(CONFIG_SND_SOC_STA32X)   += snd-soc-sta32x.o
obj-$(CONFIG_SND_SOC_STA350)   += snd-soc-sta350.o
obj-$(CONFIG_SND_SOC_STA529)   += snd-soc-sta529.o
obj-$(CONFIG_SND_SOC_STAC9766)	+= snd-soc-stac9766.o
obj-$(CONFIG_SND_SOC_TAS5086)	+= snd-soc-tas5086.o
+1266 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading