Commit 2b17ef40 authored by Mark Brown's avatar Mark Brown

Merge branches 'topic/sta350', 'topic/core', 'topic/dapm' and 'topic/cache' of...

Merge branches 'topic/sta350', 'topic/core', 'topic/dapm' and 'topic/cache' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-component
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.
};
......@@ -463,12 +463,12 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
#endif
/* codec register bit access */
int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
unsigned int mask, unsigned int value);
int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
unsigned short reg, unsigned int mask,
unsigned int reg, unsigned int mask,
unsigned int value);
int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
unsigned int mask, unsigned int value);
int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
......@@ -746,6 +746,7 @@ struct snd_soc_codec_driver {
unsigned int freq_in, unsigned int freq_out);
/* codec IO */
struct regmap *(*get_regmap)(struct device *);
unsigned int (*read)(struct snd_soc_codec *, unsigned int);
int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
unsigned int reg_cache_size;
......@@ -1125,8 +1126,8 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform(
/* codec IO */
unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
unsigned int snd_soc_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int val);
int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int val);
/* device driver data */
......
/*
* 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 */
......@@ -1327,10 +1327,6 @@ static int pm860x_probe(struct snd_soc_codec *codec)
pm860x->codec = codec;
ret = snd_soc_codec_set_cache_io(codec, pm860x->regmap);
if (ret)
return ret;
for (i = 0; i < 4; i++) {
ret = request_threaded_irq(pm860x->irq[i], NULL,
pm860x_codec_handler, IRQF_ONESHOT,
......@@ -1362,10 +1358,18 @@ static int pm860x_remove(struct snd_soc_codec *codec)
return 0;
}
static struct regmap *pm860x_get_regmap(struct device *dev)
{
struct pm860x_priv *pm860x = dev_get_drvdata(dev);
return pm860x->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_pm860x = {
.probe = pm860x_probe,
.remove = pm860x_remove,
.set_bias_level = pm860x_set_bias_level,
.get_regmap = pm860x_get_regmap,
.controls = pm860x_snd_controls,
.num_controls = ARRAY_SIZE(pm860x_snd_controls),
......
......@@ -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
......
......@@ -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
......
......@@ -139,8 +139,6 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
davinci_vc->cq93vc.codec = codec;
snd_soc_codec_set_cache_io(codec, davinci_vc->regmap);
/* Off, with power on */
cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
......@@ -154,11 +152,19 @@ static int cq93vc_remove(struct snd_soc_codec *codec)
return 0;
}
static struct regmap *cq93vc_get_regmap(struct device *dev)
{
struct davinci_vc *davinci_vc = codec->dev->platform_data;
return davinci_vc->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
.set_bias_level = cq93vc_set_bias_level,
.probe = cq93vc_probe,
.remove = cq93vc_remove,
.resume = cq93vc_resume,
.get_regmap = cq93vc_get_regmap,
.controls = cq93vc_snd_controls,
.num_controls = ARRAY_SIZE(cq93vc_snd_controls),
};
......
......@@ -608,14 +608,6 @@ static struct snd_kcontrol_new mc13783_control_list[] = {
static int mc13783_probe(struct snd_soc_codec *codec)
{
struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret;
ret = snd_soc_codec_set_cache_io(codec,
dev_get_regmap(codec->dev->parent, NULL));
if (ret != 0) {
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
return ret;
}
/* these are the reset values */
mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893);
......@@ -735,9 +727,15 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = {
}
};
static struct regmap *mc13783_get_regmap(struct device *dev)
{
return dev_get_regmap(dev->parent, NULL);
}
static struct snd_soc_codec_driver soc_codec_dev_mc13783 = {
.probe = mc13783_probe,
.remove = mc13783_remove,
.get_regmap = mc13783_get_regmap,
.controls = mc13783_control_list,
.num_controls = ARRAY_SIZE(mc13783_control_list),
.dapm_widgets = mc13783_dapm_widgets,
......
......@@ -208,13 +208,6 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
return err;
}
static int si476x_codec_probe(struct snd_soc_codec *codec)
{
struct regmap *regmap = dev_get_regmap(codec->dev->parent, NULL);
return snd_soc_codec_set_cache_io(codec, regmap);
}
static struct snd_soc_dai_ops si476x_dai_ops = {
.hw_params = si476x_codec_hw_params,
.set_fmt = si476x_codec_set_dai_fmt,
......@@ -238,8 +231,13 @@ static struct snd_soc_dai_driver si476x_dai = {
.ops = &si476x_dai_ops,
};
static struct regmap *si476x_get_regmap(struct device *dev)
{
return dev_get_regmap(dev->parent, NULL);
}
static struct snd_soc_codec_driver soc_codec_dev_si476x = {
.probe = si476x_codec_probe,
.get_regmap = si476x_get_regmap,
.dapm_widgets = si476x_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets),
.dapm_routes = si476x_dapm_routes,
......
This diff is collapsed.
/*
* Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
*
* Copyright: 2011 Raumfeld GmbH
* Author: Sven Brandau <info@brandau.biz>
*
* based on code from:
* Raumfeld GmbH
* Johannes Stezenbach <js@sig21.net>
* Wolfson Microelectronics PLC.
* Mark Brown <broonie@opensource.wolfsonmicro.com>
*
* 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 _ASOC_STA_350_H
#define _ASOC_STA_350_H
/* STA50 register addresses */
#define STA350_REGISTER_COUNT 0x4D
#define STA350_COEF_COUNT 62
#define STA350_CONFA 0x00
#define STA350_CONFB 0x01
#define STA350_CONFC 0x02
#define STA350_CONFD 0x03
#define STA350_CONFE 0x04
#define STA350_CONFF 0x05
#define STA350_MMUTE 0x06
#define STA350_MVOL 0x07
#define STA350_C1VOL 0x08
#define STA350_C2VOL 0x09
#define STA350_C3VOL 0x0a
#define STA350_AUTO1 0x0b
#define STA350_AUTO2 0x0c
#define STA350_AUTO3 0x0d
#define STA350_C1CFG 0x0e
#define STA350_C2CFG 0x0f
#define STA350_C3CFG 0x10
#define STA350_TONE 0x11
#define STA350_L1AR 0x12
#define STA350_L1ATRT 0x13
#define STA350_L2AR 0x14
#define STA350_L2ATRT 0x15
#define STA350_CFADDR2 0x16
#define STA350_B1CF1 0x17
#define STA350_B1CF2 0x18
#define STA350_B1CF3 0x19
#define STA350_B2CF1 0x1a
#define STA350_B2CF2 0x1b
#define STA350_B2CF3 0x1c
#define STA350_A1CF1 0x1d
#define STA350_A1CF2 0x1e
#define STA350_A1CF3 0x1f
#define STA350_A2CF1 0x20
#define STA350_A2CF2 0x21
#define STA350_A2CF3 0x22
#define STA350_B0CF1 0x23
#define STA350_B0CF2 0x24
#define STA350_B0CF3 0x25
#define STA350_CFUD 0x26
#define STA350_MPCC1 0x27
#define STA350_MPCC2 0x28
#define STA350_DCC1 0x29
#define STA350_DCC2 0x2a
#define STA350_FDRC1 0x2b
#define STA350_FDRC2 0x2c
#define STA350_STATUS 0x2d
/* reserved: 0x2d - 0x30 */
#define STA350_EQCFG 0x31
#define STA350_EATH1 0x32
#define STA350_ERTH1 0x33
#define STA350_EATH2 0x34
#define STA350_ERTH2 0x35
#define STA350_CONFX 0x36
#define STA350_SVCA 0x37
#define STA350_SVCB 0x38
#define STA350_RMS0A 0x39
#define STA350_RMS0B 0x3a
#define STA350_RMS0C 0x3b
#define STA350_RMS1A 0x3c
#define STA350_RMS1B 0x3d
#define STA350_RMS1C 0x3e
#define STA350_EVOLRES 0x3f
/* reserved: 0x40 - 0x47 */
#define STA350_NSHAPE 0x48
#define STA350_CTXB4B1 0x49
#define STA350_CTXB7B5 0x4a
#define STA350_MISC1 0x4b
#define STA350_MISC2 0x4c
/* 0x00 CONFA */
#define STA350_CONFA_MCS_MASK 0x03
#define STA350_CONFA_MCS_SHIFT 0
#define STA350_CONFA_IR_MASK 0x18
#define STA350_CONFA_IR_SHIFT 3
#define STA350_CONFA_TWRB BIT(5)
#define STA350_CONFA_TWAB BIT(6)
#define STA350_CONFA_FDRB BIT(7)
/* 0x01 CONFB */
#define STA350_CONFB_SAI_MASK 0x0f
#define STA350_CONFB_SAI_SHIFT 0
#define STA350_CONFB_SAIFB BIT(4)
#define STA350_CONFB_DSCKE BIT(5)
#define STA350_CONFB_C1IM BIT(6)
#define STA350_CONFB_C2IM BIT(7)
/* 0x02 CONFC */
#define STA350_CONFC_OM_MASK 0x03
#define STA350_CONFC_OM_SHIFT 0
#define STA350_CONFC_CSZ_MASK 0x3c
#define STA350_CONFC_CSZ_SHIFT 2
#define STA350_CONFC_OCRB BIT(7)
/* 0x03 CONFD */
#define STA350_CONFD_HPB_SHIFT 0
#define STA350_CONFD_DEMP_SHIFT 1
#define STA350_CONFD_DSPB_SHIFT 2
#define STA350_CONFD_PSL_SHIFT 3
#define STA350_CONFD_BQL_SHIFT 4
#define STA350_CONFD_DRC_SHIFT 5
#define STA350_CONFD_ZDE_SHIFT 6
#define STA350_CONFD_SME_SHIFT 7
/* 0x04 CONFE */
#define STA350_CONFE_MPCV BIT(0)
#define STA350_CONFE_MPCV_SHIFT 0
#define STA350_CONFE_MPC BIT(1)
#define STA350_CONFE_MPC_SHIFT 1
#define STA350_CONFE_NSBW BIT(2)
#define STA350_CONFE_NSBW_SHIFT 2
#define STA350_CONFE_AME BIT(3)
#define STA350_CONFE_AME_SHIFT 3
#define STA350_CONFE_PWMS BIT(4)
#define STA350_CONFE_PWMS_SHIFT 4
#define STA350_CONFE_DCCV BIT(5)
#define STA350_CONFE_DCCV_SHIFT 5
#define STA350_CONFE_ZCE BIT(6)
#define STA350_CONFE_ZCE_SHIFT 6
#define STA350_CONFE_SVE BIT(7)
#define STA350_CONFE_SVE_SHIFT 7
/* 0x05 CONFF */
#define STA350_CONFF_OCFG_MASK 0x03
#define STA350_CONFF_OCFG_SHIFT 0
#define STA350_CONFF_IDE BIT(2)
#define STA350_CONFF_BCLE BIT(3)
#define STA350_CONFF_LDTE BIT(4)
#define STA350_CONFF_ECLE BIT(5)
#define STA350_CONFF_PWDN BIT(6)
#define STA350_CONFF_EAPD BIT(7)
/* 0x06 MMUTE */
#define STA350_MMUTE_MMUTE 0x01
#define STA350_MMUTE_MMUTE_SHIFT 0
#define STA350_MMUTE_C1M 0x02
#define STA350_MMUTE_C1M_SHIFT 1
#define STA350_MMUTE_C2M 0x04
#define STA350_MMUTE_C2M_SHIFT 2
#define STA350_MMUTE_C3M 0x08
#define STA350_MMUTE_C3M_SHIFT 3
#define STA350_MMUTE_LOC_MASK 0xC0
#define STA350_MMUTE_LOC_SHIFT 6
/* 0x0b AUTO1 */
#define STA350_AUTO1_AMGC_MASK 0x30
#define STA350_AUTO1_AMGC_SHIFT 4
/* 0x0c AUTO2 */
#define STA350_AUTO2_AMAME 0x01
#define STA350_AUTO2_AMAM_MASK 0x0e
#define STA350_AUTO2_AMAM_SHIFT 1
#define STA350_AUTO2_XO_MASK 0xf0
#define STA350_AUTO2_XO_SHIFT 4
/* 0x0d AUTO3 */
#define STA350_AUTO3_PEQ_MASK 0x1f
#define STA350_AUTO3_PEQ_SHIFT 0
/* 0x0e 0x0f 0x10 CxCFG */
#define STA350_CxCFG_TCB_SHIFT 0
#define STA350_CxCFG_EQBP_SHIFT 1
#define STA350_CxCFG_VBP_SHIFT 2
#define STA350_CxCFG_BO_SHIFT 3
#define STA350_CxCFG_LS_SHIFT 4
#define STA350_CxCFG_OM_MASK 0xc0
#define STA350_CxCFG_OM_SHIFT 6
/* 0x11 TONE */
#define STA350_TONE_BTC_SHIFT 0
#define STA350_TONE_TTC_SHIFT 4
/* 0x12 0x13 0x14 0x15 limiter attack/release */
#define STA350_LxA_SHIFT 0
#define STA350_LxR_SHIFT 4
/* 0x26 CFUD */
#define STA350_CFUD_W1 0x01
#define STA350_CFUD_WA 0x02
#define STA350_CFUD_R1 0x04
#define STA350_CFUD_RA 0x08
/* biquad filter coefficient table offsets */
#define STA350_C1_BQ_BASE 0
#define STA350_C2_BQ_BASE 20
#define STA350_CH_BQ_NUM 4
#define STA350_BQ_NUM_COEF 5
#define STA350_XO_HP_BQ_BASE 40
#define STA350_XO_LP_BQ_BASE 45
#define STA350_C1_PRESCALE 50
#define STA350_C2_PRESCALE 51
#define STA350_C1_POSTSCALE 52
#define STA350_C2_POSTSCALE 53
#define STA350_C3_POSTSCALE 54
#define STA350_TW_POSTSCALE 55
#define STA350_C1_MIX1 56
#define STA350_C1_MIX2 57
#define STA350_C2_MIX1 58
#define STA350_C2_MIX2 59
#define STA350_C3_MIX1 60
#define STA350_C3_MIX2 61
#endif /* _ASOC_STA_350_H */
......@@ -1760,10 +1760,6 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec)
struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret;
ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
if (ret != 0)
return ret;
ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2);
if (ret != 0)
return ret;
......@@ -1802,9 +1798,17 @@ static unsigned int wm5102_digital_vu[] = {
ARIZONA_DAC_DIGITAL_VOLUME_5R,
};
static struct regmap *wm5102_get_regmap(struct device *dev)
{
struct wm5102_priv *priv = dev_get_drvdata(dev);
return priv->core.arizona->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_wm5102 = {
.probe = wm5102_codec_probe,
.remove = wm5102_codec_remove,
.get_regmap = wm5102_get_regmap,
.idle_bias_off = true,
......
......@@ -1589,10 +1589,6 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec)
priv->core.arizona->dapm = &codec->dapm;
ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
if (ret != 0)
return ret;
arizona_init_spk(codec);
arizona_init_gpio(codec);
......@@ -1633,9 +1629,17 @@ static unsigned int wm5110_digital_vu[] = {
ARIZONA_DAC_DIGITAL_VOLUME_6R,
};
static struct regmap *wm5110_get_regmap(struct device *dev)
{
struct wm5110_priv *priv = dev_get_drvdata(dev);
return priv->core.arizona->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_wm5110 = {
.probe = wm5110_codec_probe,
.remove = wm5110_codec_remove,
.get_regmap = wm5110_get_regmap,
.idle_bias_off = true,
......
......@@ -1505,8 +1505,6 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
if (ret != 0)
return ret;
snd_soc_codec_set_cache_io(codec, wm8350->regmap);
/* Put the codec into reset if it wasn't already */
wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
......@@ -1608,11 +1606,19 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec)
return 0;
}
static struct regmap *wm8350_get_regmap(struct device *dev)
{
struct wm8350 *wm8350 = dev_get_platdata(dev);
return wm8350->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_wm8350 = {
.probe = wm8350_codec_probe,
.remove = wm8350_codec_remove,
.suspend = wm8350_suspend,
.resume = wm8350_resume,
.get_regmap = wm8350_get_regmap,
.set_bias_level = wm8350_set_bias_level,
.controls = wm8350_snd_controls,
......
......@@ -1318,8 +1318,6 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec)
priv->wm8400 = wm8400;
priv->codec = codec;
snd_soc_codec_set_cache_io(codec, wm8400->regmap);
ret = devm_regulator_bulk_get(wm8400->dev,
ARRAY_SIZE(power), &power[0]);
if (ret != 0) {
......@@ -1361,11 +1359,19 @@ static int wm8400_codec_remove(struct snd_soc_codec *codec)
return 0;
}
static struct regmap *wm8400_get_regmap(struct device *dev)
{
struct wm8400 *wm8400 = dev_get_platdata(dev);
return wm8400->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_wm8400 = {
.probe = wm8400_codec_probe,
.remove = wm8400_codec_remove,
.suspend = wm8400_suspend,
.resume = wm8400_resume,
.get_regmap = wm8400_get_regmap,
.set_bias_level = wm8400_set_bias_level,
.controls = wm8400_snd_controls,
......
......@@ -3999,8 +3999,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994->hubs.codec = codec;
snd_soc_codec_set_cache_io(codec, control->regmap);
mutex_init(&wm8994->accdet_lock);
INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap,
wm1811_jackdet_bootstrap);
......@@ -4434,11 +4432,19 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
return 0;
}
static struct regmap *wm8994_get_regmap(struct device *dev)
{
struct wm8994 *control = dev_get_drvdata(dev->parent);
return control->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
.probe = wm8994_codec_probe,
.remove = wm8994_codec_remove,
.suspend = wm8994_codec_suspend,
.resume = wm8994_codec_resume,
.get_regmap = wm8994_get_regmap,
.set_bias_level = wm8994_set_bias_level,
};
......
......@@ -1051,11 +1051,6 @@ static struct snd_soc_dai_driver wm8997_dai[] = {
static int wm8997_codec_probe(struct snd_soc_codec *codec)
{
struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret;
ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
if (ret != 0)
return ret;
arizona_init_spk(codec);
......@@ -1086,9 +1081,17 @@ static unsigned int wm8997_digital_vu[] = {
ARIZONA_DAC_DIGITAL_VOLUME_5R,
};
static struct regmap *wm8997_get_regmap(struct device *dev)
{
struct wm8997_priv *priv = dev_get_drvdata(dev);
return priv->core.arizona->regmap;
}
static struct snd_soc_codec_driver soc_codec_dev_wm8997 = {
.probe = wm8997_codec_probe,
.remove = wm8997_codec_remove,
.get_regmap = wm8997_get_regmap,
.idle_bias_off = true,
......
......@@ -1120,26 +1120,31 @@ static int soc_probe_codec(struct snd_soc_card *card,
soc_init_codec_debugfs(codec);
if (driver->dapm_widgets)
snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
driver->num_dapm_widgets);
if (driver->dapm_widgets) {
ret = snd_soc_dapm_new_controls(&codec->dapm,
driver->dapm_widgets,
driver->num_dapm_widgets);
/* Create DAPM widgets for each DAI stream */
list_for_each_entry(dai, &codec->component.dai_list, list)
snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
if (ret != 0) {
dev_err(codec->dev,
"Failed to create new controls %d\n", ret);
goto err_probe;
}
}
codec->dapm.idle_bias_off = driver->idle_bias_off;
/* Create DAPM widgets for each DAI stream */
list_for_each_entry(dai, &codec->component.dai_list, list) {
ret = snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
if (!codec->write && dev_get_regmap(codec->dev, NULL)) {
/* Set the default I/O up try regmap */
ret = snd_soc_codec_set_cache_io(codec, NULL);
if (ret < 0) {
if (ret != 0) {
dev_err(codec->dev,
"Failed to set cache I/O: %d\n", ret);
"Failed to create DAI widgets %d\n", ret);
goto err_probe;
}
}
codec->dapm.idle_bias_off = driver->idle_bias_off;
if (driver->probe) {
ret = driver->probe(codec);
if (ret < 0) {
......@@ -2060,28 +2065,28 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
p = devm_pinctrl_get(dev);
if (IS_ERR(p)) {
dev_err(dev, "Failed to get pinctrl\n");
return PTR_RET(p);
return PTR_ERR(p);
}
cfg->pctl = p;
state = pinctrl_lookup_state(p, "ac97-reset");
if (IS_ERR(state)) {
dev_err(dev, "Can't find pinctrl state ac97-reset\n");
return PTR_RET(state);
return PTR_ERR(state);
}
cfg->pstate_reset = state;
state = pinctrl_lookup_state(p, "ac97-warm-reset");
if (IS_ERR(state)) {
dev_err(dev, "Can't find pinctrl state ac97-warm-reset\n");
return PTR_RET(state);
return PTR_ERR(state);
}
cfg->pstate_warm_reset = state;
state = pinctrl_lookup_state(p, "ac97-running");
if (IS_ERR(state)) {
dev_err(dev, "Can't find pinctrl state ac97-running\n");
return PTR_RET(state);
return PTR_ERR(state);
}
cfg->pstate_run = state;
......@@ -2691,7 +2696,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
int min = mc->min;
int mask = (1 << (fls(min + max) - 1)) - 1;
int err = 0;
unsigned short val, val_mask, val2 = 0;
unsigned int val, val_mask, val2 = 0;
val_mask = mask << shift;
val = (ucontrol->value.integer.value[0] + min) & mask;
......@@ -4073,6 +4078,7 @@ int snd_soc_register_codec(struct device *dev,
int num_dai)
{
struct snd_soc_codec *codec;
struct regmap *regmap;
int ret, i;
dev_dbg(dev, "codec register %s\n", dev_name(dev));
......@@ -4102,6 +4108,23 @@ int snd_soc_register_codec(struct device *dev,
codec->val_bytes = codec_drv->reg_word_size;
mutex_init(&codec->mutex);
if (!codec->write) {
if (codec_drv->get_regmap)
regmap = codec_drv->get_regmap(dev);
else
regmap = dev_get_regmap(dev, NULL);
if (regmap) {
ret = snd_soc_codec_set_cache_io(codec, regmap);
if (ret && ret != -ENOTSUPP) {
dev_err(codec->dev,
"Failed to set cache I/O:%d\n",
ret);
return ret;
}
}
}
for (i = 0; i < num_dai; i++) {
fixup_codec_formats(&dai_drv[i].playback);
fixup_codec_formats(&dai_drv[i].capture);
......
......@@ -426,7 +426,7 @@ static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm)
}
static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w,
unsigned short reg, unsigned int mask, unsigned int value)
int reg, unsigned int mask, unsigned int value)
{
bool change;
unsigned int old, new;
......
......@@ -31,8 +31,8 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
}
EXPORT_SYMBOL_GPL(snd_soc_read);
unsigned int snd_soc_write(struct snd_soc_codec *codec,
unsigned int reg, unsigned int val)
int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int val)
{
dev_dbg(codec->dev, "write %x = %x\n", reg, val);
trace_snd_soc_reg_write(codec, reg, val);
......@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(snd_soc_write);
*
* Returns 1 for change, 0 for no change, or negative error code.
*/
int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
unsigned int mask, unsigned int value)
{
bool change;
......@@ -92,7 +92,7 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits);
* Returns 1 for change else 0.
*/
int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
unsigned short reg, unsigned int mask,
unsigned int reg, unsigned int mask,
unsigned int value)
{
int change;
......@@ -117,7 +117,7 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked);
*
* Returns 1 for change else 0.
*/
int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
unsigned int mask, unsigned int value)
{
int change;
......@@ -204,14 +204,11 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
{
int ret;
/* Device has made its own regmap arrangements */
if (!regmap)
codec->control_data = dev_get_regmap(codec->dev, NULL);
else
codec->control_data = regmap;
return -EINVAL;
if (IS_ERR(codec->control_data))
return PTR_ERR(codec->control_data);
/* Device has made its own regmap arrangements */
codec->control_data = regmap;
codec->write = hw_write;
codec->read = hw_read;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment